Moving from a standard ESP32 (the ESP32-WROOM-32, the original chip from 2016) to an ESP32-S3 represents a major generational leap, even though both chips retain a maximum clock frequency of 240 MHz across two cores. Here are the key technical and practical arguments that justify this migration.
The article explains the procedure for retrieving the ESP32forth source code, compiling it, and uploading it to an ESP32 board (such as the ESP32 WROOM 32) connected via USB. It details how to add support for ESP32 boards using the Espressif URL, configure hardware settings (CPU frequency at 240 MHz, 4 MB flash memory, and upload speed), and use the BOOT button if the transfer fails.
I am embarking on a major endeavor: offering a version of ESP32forth designed to be compiled using Visual Studio Code and PlatformIO.
This version is derived from Brad Nelson’s latest release, 7.0.7.21.
Why this new version?
While attempting to adapt ESP32forth for the ESP32 board via the Arduino IDE, I encountered several limitations—most notably regarding memory allocation. Using the Arduino IDE resulted in:
a laborious compilation process (taking over two minutes on my PC),
inconsistent compilation errors,
and code that would crash once uploaded to the board.
A few months ago, I asked Google’s AI, Gemini, what tool I could use as an alternative to the Arduino IDE. The answer: Visual Studio Code, paired with the PlatformIO extension.
Setting up and configuring this new environment (with Gemini’s help) took one hour.
Adapting the original `.ino` file—converting it into a `.cpp` file—took another hour.
The first successful compilation took just 15 seconds. You can watch a video showing the entire compilation and upload process—completed in 15 seconds—here:
A week ago, I began optimizing the code for the ESP32-S3 board. I implemented `Serial1` support and integrated `RECORDFILE` functionality, along with an improved memory dump feature.
Yesterday, I considered several minor enhancements for the ESP32forth kernel. Consequently, I decided to "fork" Brad Nelson’s version and rename it "ESP32forth VSC" (VSC standing for Visual Studio Code). I have also created a software repository, accessible here:
This version is compiled using Visual Studio Code + PlatformIO. The compilation takes 15 seconds, compared to over two minutes in the Arduino IDE. See video:
I switched from Arduino IDE to Visual Studio Code to compile my ESP32 programs. Here, I'm compiling code that took several minutes with the Arduino IDE. Visual Studio Code compiles the same code in 15 seconds!
In this video, I'm using the new RMT 2 API, which allows me to control WS2812b addressable LEDs. Here, I'm using a ring of 60 LEDs. I'm simulating a clock:
RED LED = hours
GREEN LED = minutes
CYAN LED = seconds
The program runs in a separate FORTH task, freeing up the FORTH interpreter for other uses.
This library is intended to simplify the coding of the RMT interface.
Initially, RMT was designed for receiving infrared remote control signals. It has since been used for many other purposes. My RMT20 library incorporates the new commands from the API developed by Espressif.
I am currently in the testing phase, so I cannot guarantee that everything will work.
I have already written preliminary documentation, which is also available at the link above.
For the moment, I am testing this library with a 60-LED ring. You will be kept informed of the testing progress.
This manual aims to explain how to integrate new functions from specialized hardware and software libraries. This integration requires the creation of special files, including userwords.h , which will serve as our starting point.
Discover this GSM transmission module. The SIM800L module allows you to communicate via SMS, transmit and receive data, all through the mobile phone network.
This article is the first in a series that explains how to control this GSM module using ESP32forth.
Here's the problem: I splurged on a SIM800L module, a small board that allows you to send and receive SMS messages.
So, this module is controlled via the serial port. On an ESP32-S3 board, the external serial ports are on pins 17 and 18. Except that these aren't UART2 ports but UART1 ports (marked TX1 and RX1 on the schematic).
However, ESP32forth's serial vocabulary only includes serial and serial2. So, I modified ESP32forth.ino to add serial1 support.
Except there are a whole bunch of parameters in the code to perform conditional compilation.
This is where you discover the joys of reverse engineering code you didn't write yourself. And in a language you don't fully understand.
So, I enlisted the help of two AIs (Google-Gemini and Claude-AI). I gave them my code to analyze. Claude is more sophisticated than Gemini. He doesn't invent variables and flags that don't exist. He read and analyzed the code in 10 seconds and suggested solutions.
But Brad Nelson wrote code using negative logic: #ifndef..... So, my high school studies in combinational logic came flooding back... (De Morgan's theorem and all that jazz).
And I redid the detection logic and took into account serial1 and serial2:
CONCLUSION: AI provides enormous help in analyzing and finding solutions to code. The two AIs mentioned earlier aren't yet super-efficient in FORTH, but when I mention ESP32forth, they seem to know their stuff.
If you're not using an AI, start. Whether you're developing in assembly or another language, even if it doesn't invent innovative code, it can still analyze and correct certain functions quite well. And to top it all off, the code is pre-written. A simple copy/paste avoids having to rewrite everything...
I provided it with the functions written in C and asked for the translated version in macro X. I haven't tested them all yet, but so far, no major bugs. In short, a task that would have taken several days was completed in a few hours.
Finally, one last positive point: when I come across incomprehensible code, I copy and paste it and simply ask, "What is the purpose of this code?" For reverse engineering, this is a significant advantage.
It's a project I've had in mind for a while now. Actually, it started after I saw a YouTube video demoing what an ESP32 board can do in this area.
ESP32 boards are quite good at DSP (Digital Signal Processing). And since I'm a bit tired of turning LEDs on and off with GPIO pins, I'd like to tackle a real, very concrete project.
This manual is intended to help you understand how to use the ARDUINO IDE program to compile ESP32forth for EPS32 boards and incidentally all other programs in C language for the range of boards in the ARDUINO environment.
The major advantage of displaying images of this type is the ability to prepare graphic backgrounds, such as graduated test patterns, which can then be used with all other graphic elements.
In this video, the SLAVE1 board was placed 15 meters from the MASTER board. It is powered by a self-contained unit via a lithium battery. Upon power-up, the three LEDs light up rapidly to confirm the program initialization.
All LED activation commands are transmitted by the MASTER board, overlaid on the video.
ESP-NOW communication is handled via peer-to-peer, meaning without the need for a Wi-Fi router.
In the previous article, we saw that message transmission between MASTER and SLAVE1 works perfectly. We will now discuss how to manage any practical application with ESP32forth using the ESP-NOW protocol.
The espnow_recv_cb_xt value contains the CFA of the FORTH code to be executed once the parameters processed by ESP-NOW have been placed on the stack. On the FORTH side, here's an example of processing:
: my-cb-espnow { len dataAddr macAddr -- } cr ." --- ESP-NOW RECEIVED ---" cr ." Length: " len . cr ." Data: " dataAddr . cr ." MAC Source: " macAddr .mac cr ." -------------------" cr ." Msg: " dataAddr len type ; ' my-cb-espnow espnowRegisterRecv
Even though using several AIs was long and laborious, the discussions allowed us to pinpoint the problem and find this elegant and functional solution.
Of the three AIs tested, GitHub Copilot and Mistral AI provide very detailed answers.
For Google Gemini, I gave it the complete code of eForth****.ino. Despite this code, Gemini referenced C code that didn't exist in the .ino file.
Mistral AI was the AI that gave me the closest solution to the final result by addressing the interrupt handling aspect.
In conclusion, if you're developing in FORTH, don't hesitate to ask your favorite AI for solutions:
First, always specify which version of FORTH you're using;
If that version has source code, provide a link to it;
Make a simple and explicit request, such as: "I want the word XXXXX to modify a piece of data in a two-dimensional array."...
But above all, understand the code returned by the AI. Some AIs invent FORTH primitives that don't exist.
Personally, I prefer local variables in my FORTH definitions. This allows for better readability of the FORTH code.