Arduino is a platform of open source hardware and software for using microcontrollers.
It is known as an educational system for beginners, but is widely used among hobbyists, professionals and commercial entities at all levels.
Arduino IDE is a software package for writing, compiling and uploading code to a microcontroller. It is an “Integrated Development Environment (IDE)”, including an editor and several tools.
Arduino CLI is a command-line version of the same software.
File - Preferences - Show verbose output during x compilation x upload
Check compilation and upload to get detailed messaging and learn:
Display a list of all installed boards, human name and FQBN:
$ arduino-cli board listall
Display current config settings, print out ~/.arduino15/arduino-cli.yaml:
$ arduino-cli config dump
Arduino, Arduino CLI, include path
Arduino mpu 6050
Where are the human names of the platforms displayed in the Boards Manager menu?
Why are there two core/library/package/platform for ESP32 Nano? What is the difference? Which do I use?
Why is my sk8mini no longer compiling?
When using Tools - Pin Numbering - “By Arduino pin (default)”
function digitalPinToGPIONumber(_pin) is added and compile fails
When using Tools - Pin Numbering - “By GPIO number (legacy)”
it compiles successfully, but throttle motor does not respond
My code uses D3 and D6 as pin numbers. Where are these defined?
A microcontroller is a type of integrated circuit (IC), a chip.
A microcontroller is programmable.
1. Upload, burn, or flash a program into the chip's memory.
2. Power-up the chip in normal mode, and your program starts running automatically.
Each microcontroller contains a logic processor which runs a specific language.
The manufacture provides a compiler, and instructions for loading a compiled program into the microcontroller.
It may seem like a hassle to deal with all of the details and quirks of programming the many various microcontrollers available.
The Arduino IDE, and several similar products, attempt to simplify this situation for beginner developers by providing tools that operate universally across all microcontroller products.
Ideally you can write a C++ program for the ATmega328P microcontroller, and then later run that same program on an ESP32 microcontroller.
The Arduino IDE takes care of all the chip-specific details behind the scenes and lets the developer concentrate on the program logic.
Unfortunately, programs like this often become gate-keepers, hiding the truth from ordinary folks. “You don't need to know that.” Sooner or later, as a result of problem solving, developers are forced to spend inordinate amounts of time figuring out what the IDE is doing, in order to debug the problem.
sketch = a c++ program in a text file with extension “.ino”, in a folder with the same name.
Packages, cores, libraries, tools
package vs core vs platform
components:
“List all boards that have the support platform installed.”
“Search for a board in the Boards Manager using the specified keywords.”
“Upload the bootloader on the board using an external programmer.”
“completion script”
“platform”
Boards Manager - the compiler and uploader work differently depending on the board.
The “board” refers to the PCB, the microcontroller.
With the IDE, you are always working with one microcontroller. The microcontroller is connected to a serial port. You use the Boards Manager to specify the mfg/model of the microcontroller.
1. Plug your microcontroller into a serial port on your computer. 2. In the IDE menu, goto Tools - Boards Manager.
Tools menu:
$: arduino-cli upload ... Error during Upload: Platform 'arduino:avr' not found: platform arduino:avr is not installed Try running `arduino-cli core install arduino:avr` $: arduino-cli core list ID Installed Latest Name arduino:esp32 2.0.13 2.0.13 Arduino ESP32 Boards esp32:esp32 2.0.13 2.0.13 esp32 $: arduino-cli core install arduino:avr Downloading packages... arduino:avr-gcc@7.3.0-atmel3.6.1-arduino7 downloaded arduino:avrdude@6.3.0-arduino17 downloaded arduino:arduinoOTA@1.3.0 downloaded arduino:avr@1.8.6 downloaded Installing arduino:avr-gcc@7.3.0-atmel3.6.1-arduino7... Configuring tool.... arduino:avr-gcc@7.3.0-atmel3.6.1-arduino7 installed Installing arduino:avrdude@6.3.0-arduino17... Configuring tool.... arduino:avrdude@6.3.0-arduino17 installed Installing arduino:arduinoOTA@1.3.0... Configuring tool.... arduino:arduinoOTA@1.3.0 installed Installing platform arduino:avr@1.8.6... Configuring platform.... Platform arduino:avr@1.8.6 installed $: arduino-cli core list ID Installed Latest Name arduino:avr 1.8.6 1.8.6 Arduino AVR Boards arduino:esp32 2.0.13 2.0.13 Arduino ESP32 Boards esp32:esp32 2.0.13 2.0.13 esp32
| Platform name in Boards Manager | folder |
|---|---|
| ESP32 Arduino (Arduino) | /home/john/.arduino15/packages/esp32/hardware/esp32/2.0.13/boards.txt |
| Arduino AVR Boards | /home/john/.arduino15/packages/arduino/hardware/avr/1.8.6/boards.txt |
| ESP32 Arduino | /home/john/.arduino15/packages/arduino/hardware/esp32/2.0.13/boards.txt |
Where are the human names of the platforms displayed in the Boards Manager menu?
File - Preferences: /home/john/.arduino15/preferences.txt
Boards Manager - where is this list of “packages”?
Library Manager - where is this list of libraries?
Each of these folders contains a file named boards.txt. boards.txt contains a number of key=value parameters grouped into sections. It includes a name= keyword that identifies the name as displayed in the board menu in the IDE.
nano_nora.name=Arduino Nano ESP32 This board is found in two packages. ~/.arduino15/packages/esp32/hardware/esp32/2.0.13/boards.txt - this one has many boards ~/.arduino15/packages/arduino/hardware/esp32/2.0.13/boards.txt - this has only the one board
The CLI needs the FQBN for the board. Where is that specified?
I have 5 Nano ESP32 boards installed. WTF?
| Arduino Nano | arduino:avr:nano |
| Arduino Nano ESP32 | esp32:esp32:nano_nora |
| Arduino Nano ESP32 | arduino:esp32:nano_nora |
| Nano32 | esp32:esp32:nano32 |
| UM NanoS3 | esp32:esp32:nanos3 |
Directories created by initial apt install:
~/.arduino15/preferences.txt - defaults used by Arduino IDE, see Files - Preferences
~/.arduino15/arduino-cli.yaml - defaults used by arduino-cli
Directores specified in preferences.txt:
Boards Manager installs into ~/.arduino15/packages. So far, three packages have been installed:
Libarary Manager installs into ~/Arduino
My ports:
My boards:
“Failed to get PID of a device on /dev/ttyS4, using standard reset sequence.”
My board, the ESP32-CAM-MB is plugged into the USB port.
Arduino IDE, Tools, Port shows one available USB port.
I am a member of the dialout group, so I have permissions on that port.
$ ls -al /dev/ttyS5 crw-rw---- 1 root dialout 4, 68 Oct 15 14:56 /dev/ttyS4 $ groups john adm dialout cdrom sudo dip plugdev lpadmin lxd sambashare wireshark
The ESP32-CAM-MB requires the ? drivers. Those are supposed to be installed automatically with this Ubuntu distribution.
One core is written for each microcontroller chip.
| microcontroller | core |
|---|---|
| ATmega328P | AVR |
| SAMD21 | SAMD |
Uploading software to a microcontroller is done with serial communications.
FTDI - FTDI is a company name. They make a chip for serial communications that is used in many boards.
CH340C - USB to serial converter chip, made by SeeedStudio
reset
boot mode
enter the bootloader
serial communications - data transfer, 1 wire, 1 bit at a time, 2 parties: transmitter and receiver, 2 pins: RX, TX. wires from master's TX to listener's RX. Baud rate, stop bit, parity bit. Choice of signal methods: TTL or RS232.
USB - not considered “serial communications”, USB to serial converter
RS232 - a serial communication, +/-13V
TTL - Transistor-transistor-logic, a serial communication, 0 to 3.3V/5V
UART - Universally Asynchronous Receiver/Transmitter, a transmission method
CP2102,, Silicon Labs, SINGLE-CHIP USB TO UART BRIDGE, requires drivers https://www.sparkfun.com/datasheets/IC/cp2102.pdf
FT232RL,, FTDI, (my board is from HiLetGo, is NOT genuine FTDI, and I have NOT gotten it to work with ESP32-CAM)
CH340G, CH340C - USB to serial chip, used by ESP32-CAM-MB (mine is from Aideepen, and it works)
Atmega16U2 - an MCU programmed as a USB-to-serial converter (used by Arduino Uno R3)
FTDI, , 6 pins: DTR, RX, TX, VCC, CTS, GND
chips and boards, ICs and PCBs
boards: converter, adapter, module, programmer, breakout, developer,
Math, Computer Science
If, then, else
Must be assembled and linked, using an assembler and linker.
Logic can be implemented in assembly language programming. Not logic itself. Test, branch on condition. Expressed via flowchart instead of pseudo-code. branch = jump = goto
Compare x to 3 if greater, goto a label if lesser, goto a different label if equal, goto still another label