Post

ENG | Arduino, Getting started

Introduction

What is Arduino

Arduino is an open-source electronics platform based on easy-to-use hardware and software. It consists of a microcontroller board and an Integrated Development Environment (IDE) for writing and uploading code. Arduino boards can be programmed to interact with various sensors, actuators, and other electronic components, making them versatile for prototyping and building small projects. Arduino is not a computer - it has very limited computing power and memory.

Arduino Picture Photo of Arduino Uno, Nano (clones) and Mini

Arduino contains Atmel ATmega 328P microcontoller, voltage regulators providing 5V and 3.3V and USB to Serial interface convertor. GPIO PINs provide I²C, SPI, Serial port, few programmable analog inputs/outputs and few digital inputs/outputs. Some variants have ATmega 168 or lack USB to serial interface.

Target Audience

Arduino articles are meant to be somewhat concise, if steps are easy. There are plenty of really in-depth resources for beginners. On the other hand, unlike other arduino articles, I want to document all problems I had and focus on troubleshooting.

Installation and first test

Steps are really easy:

  1. Download and install Arduino IDE
  2. Find some working USB cable and connect Arduino
    • Warning: LEDs on some Arduino clones are models were scrapped from Death Star lasers 😎
  3. If Arduino’s serial port does not appear in “Serial ports” or “Other devices”, repeat step 2
    Arduino in Devices Manager
  4. If it appears under Other devices as Unknown USB2.0-Serial, let Windows find drivers
  5. Launch Arduino IDE, wait for it to install other stuff
  6. Do some basic setup
    • Select port in Tools->Port (e.g COM3)
    • Select Arduino board in Tools -> Board -> Arduino AVR Boards -> Arduino Uno (or whatever you have)
  7. Test it using one of examples:
    • File -> Examples -> 01. Basics -> Blink
    • Click on upload icon ➡️ which compiles and uploads program Arduino IDE
  8. Enjoy blinking LED or maybe not yet Arduino IDE
    Hopefully when I made photo for this article intro, I noticed that Arduino Nano might not be dead, it has ATmega168 chip instead of ATmega328 🤦‍♂️. Easy to overlook in a dim light. So double check exact version, sometimes there are more options (ATMega328 vs ATMega168, old bootloader, 16MHz vs 8MHz, …)

Installation on Linux (Fedora 39)

  1. Download as ZIP file and unpack it
  2. Add user (named pavel) to dialout group (this step may specific to Fedora)
    1
    
    sudo usermod -a -G dialout pavel
    
  3. Make this change effective (I installed updates and restarted PC)
  4. Run arduino ide
    1
    2
    
    cd ~/dev-arduino/arduino-ide_2.3.2_Linux_64bit/
    ./arduino-ide
    
  5. Basically follow the same steps as in Windows installation, it’s actually easier as it does not install various serial port drivers.

Arduino versions

At the moment I have several

  • Arduino Uno (clone): Not my favorite. It has weird pin headers and wiring is a mess. Unless tiny protoboard is thrown on top of it, then it works for trying one device quickly.
  • Arduino Nano (clone): I have old one with AtMega168 chip. It has limited memory capacity, but works for prototyping on breadboard. Or at least as a 5V/3.3V power supply :-)
  • Arduino Nano Every: This, on the other hand, has the most memory (both flash and RAM). Extremely annoying feature is that it lacks pin description - having it on bottom side is useless.
  • Arduino Pro Mini: This one is good for stand-alone, battery-powered applications when power LED is mechanically disabled. It does not have USB port and needs USB-Serial converter for programming.

Side note

  • Raspberry Pi Pico: this microcontroller is cheaper, faster, maybe even easier to use with MicroPython and I don’t think I’ll use Arduino for some permanent projects that are powered from USB.

Bonus stuff

Arduino Nano Every Pinout

Because Arduino Nano Every has pin description printed at the bottom, here’s the pinout for reference, which is useful when it’s placed on breadboard. USB connector is UP.

Row Left Right
1 D13/SCK D12/MISO
2 3V3 D11/MOSI
3 AREF D10/SS
4 A0 D9
5 A1 D8
6 A2 D7
7 A3 D6
8 A4/SDA D5
9 A5/SCL D4
10 A6 D3
11 A7 D2
12 5V GND
13 RST RST
14 GND D0/RXD
15 VIN D1/TXD
1
2
3
4
5
6
7
8
9
10
MOSI   : SPI Master Out -> Slave In
MISO   : SPI Master In  <- Slave Out
SS(CS) : SPI Slave (Chip) Select
SCK    : SPI Clock

SDA    : I²C Serial Data
SCL    : I²C Serial Clock Line

TXD    : UART Transmit Data
RXD    : UART Recieve Data

Serial Port Terminal Emulator

After trying

CoolTerm seems works the best.

PuTTY is painful to configure (for logging) and may interpret some control bytes, perform line end conversions and mangle binary data. It does not detect serial ports present.

I had trouble using Serial Port Terminal Emulator, once it did not seem to communicate. Logging works, but for example EEPROM dump must be done when in receive group HEX format is selected and log file then contains header and hexadecimal output as text with 16 bytes per row.

Well … it seems that sending binary data over serial port is horrible idea anyways.

Soldering tips

TL;DR: 350°C temperature

Final words

I had one project nearly finished and sleeping since 2016 to re-learn something about electronics: my goal was to build a data logger with low power consumption and run time of weeks or months. And device that monitors temperature, humidity, air pressure, battery voltage.

Basics were quite easy, but low power consumption posed a challenge. It’s likely that not all considerations were optimal and for example using EEPROM is much better option. However I have many notes on which I can build and many other notes missing from this project. Even thou this is written from two thirds, I’m afraid that polishing article may take more time than writing it, so it’s going to be separated into short articles.

Backlog of future articles:

  • Arduino Pin states
  • Arduino “secrets” (measuring vcc)
  • Weather station
    • Using temperature sensors (BM280, …)
    • Storage
    • Power: batteries, low voltage shutdown
    • Monitoring power consumption (INA219)
    • Using RTC: DS3231 (or alternatives), setting time, reading time, setting alarm
    • Using transistors as a switch
    • Lowering power consumption
      • Power LED (TODO: link to logger v2, mention it here)
      • SD card and voltage regulator on reader
      • ADCs (TODO: link to logger v2)
      • ?
    • Summary, links, …

TODO: move this to separate introduction, once ready

This post is licensed under CC BY 4.0 by the author.