Where I discuss different methods of automating the process of compiling/linking/loading code for an embedded microcontroller.
For automation to work well, it needs to work on multiple platforms along with other automation. For example, I use git as my versioning system, and GitHub for Dashboard, the repository for this entry. The problem I had with Option 2 ESP32 and Make below was that it is difficult to incorporate environmental variables. Environmental variables are values used locally to define specific aspects of your development environment. I use the environmental variables, AVR_PORT and AVR_MCU in my AVR_C code to set the microcontroller and serial port. On my Mac in my .zshrc file, I have
Where I examine the differences between writing a monolithic program versus a much more modular program.
While I display some of the code on this page, the absolute truth of working code is on github. Use it to fully understand and/or implement what I describe below. The github site also contains the latest information in its README.
Many of the examples of programming the ESP32 are monolithic programs, the data gathering code is combined with the setup code and the web display code. A monolithic approach is not a good programming practice for several reasons. I’ll go into detail as to why you won’t want to program in this manner, as well as how to write code in a more modular fashion.
Where I demonstrate identifying and solving specific issues with developing code for the ESP32 using the Arduino framework.
While my entries are primarily related to using arduino-cli, I will use the IDE for a couple of reasons:
Moved to here - Automation
This is a raw dump of my exploring using the arduino-cli with the ESP32. I wanted to find something that was better than the Arduino IDE, however, not as complex as VS Code/PlatformIO. Using arduino-cli, allows me to use my programming editor, Sublime Text as my code editor as well as some simple automation (coming later).
# install from github
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
# verify installation
arduino-cli version
# if the system is unable to find arduino-cli, see note below.
bash: command not found: arduino-cli
# add an alias to make it easier to use (add to the .bashrc file)
alias ac="arduino-cli"
# setup configuration file
arduino-cli config init
Config file written: /home/username/.arduino15/arduino-cli.yaml
# Documentation for file: https://arduino.github.io/arduino-cli/0.19/configuration/
# if using a 3rd party board, add to yaml file
board_manager:
additional_urls:
- https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
arduino-cli core update-index
arduino-cli board listall
arduino-cli core install esp32:esp32
Platform esp32:esp32@2.0.2 already installed
Upon installing, arduino-cli, a great way to test it is to verify its version using arduino-cli version. However if the system is unable to find arduino-cli, you will get this:
A short entry to explain how to code using MicroPython on the ESP32.
In my introduction to Micropython, I mentioned how I wrote MicroPython for the ESP32 on a Mac. As I stated, Phillip van Allen has a nice process, however I like my process more. This entry will review how I develop code as it might be helpful to others.
I use a paid application called Serial for serial communication with devices. There are free products, however, I found when using Serial, I’m more productive and I’m able to setup custom settings for each device to maximize throughput while taking care of the idiosyncrasies of each device. I’m also able to connect and disconnect Serial from the device easily and quickly, which is why my approach works so well.
Where I continue to use the Labrador to test the PWM functionality of the ESP32.
We continue to use the Labrador to evaluate how the HUZZAH32 operates. In this case, we’ll dive into how to use the H/W PWM functions as compared to doing it in software.
The PWM functionality is called LEDC by Espressif, the manufacturer of the ESP32. This stands for LED control and it works quite well for fading, controlling brightness etc of an LED. That said, we can understand it far better if we observe the signals using the Labrador.
Where I use the Labrador to test specific functions of the ESP32 running MicroPython.
The best way to begin to understand a board is to play with it. In more technical terms, this means writing software and learning how the board responds. The higher the capability of the board, the greater the need for examining the board with high functioning tools. In our case, we are going to keep things very inexpensive, however, extremely capable and powerful.
Where I investigate using MicroPython on the HUZZAH32.
I have spent quite a few years using Python to develop applications. I like the language, however I believed it wasn’t a good candidate for microcontrollers. Given the strong development behind both CircuitPython and MicroPython, I though it would be a good idea to test it and determine via testing and not assumptions.
I followed the steps Wolf Paulus provides on his website and had no problems. I am using macOS Big Sur with the Apple native USB drivers. Which means I’m using /dev/tty.usbserial-01F4D567 and not /dev/tty.SLAB_USBtoUART. I haven’t had any problems…yet.
Where I find a much, more evolved version of ESPForth. While investigating a bug I found in ESPForth (now called ESPForth6), I ran across a new version of ESPForth 7.0, which I’ll refer to as ESPForth7.
Each time I used ESPForth6, I would experience a bug with the word “constant”.
So I began to investigate ESPForth. Arduino-Forth who had been using FlashForth has now begin to investigate it. Which led me to the sites above. The good news is that I downloaded the ino file for ESPForth 7.05 and it compiled and loaded the first time.
Where I write an Arduino program to test pins on a specific board in order to confirm a Forth HAL for the same board.
When writing software which will control a circuit, it is best to confirm the behavior of circuit using known or familar test software before attempting to write with a new language. For example, I am developing a HAL/Primitive/User layer for the ESP32 using ESPForth. As the board, the Adafruit HUZZAH32 has an Arduino framework already developed for it, it is a good idea to test the board using the Arduino C++ code before testing it with the ESPForth words.