4 minute read

ESPForth is one of the easiest and least expensive ways to learn Forth.

esp32Forth Serial Monitor is a version of Forth written by CH Ting. Ting is remarkable in the volume of documentation he provides, as well as the number of versions of Forth he has created. In this article I want to highlight a version that I believe is interesting for two specific reasons:

  1. It runs on a Forth Virtual Machine (FVM) using the Arduino software framework
  2. It runs on ESP32 Arduino boards such as the NodeMCU ESP32, Adafruit ESP32 HUZZAH32 and the ESP32-DEVKIT. Most of these boards are $5-$15 with an amazing amount of processing power. When looking for a board for ESPForth, you want to ensure it is compatible with the Arduino IDE.

FVM on the Arduino software

Using the Arduino software provides a simple, yet powerful IDE for the user to implement Forth. It doesn’t require additional hardware so the user can immediately begin to use Forth. This also allows one to create Forth words calling Arduino framework software such as digitalRead, digitalWrite, and pinMode.

This also means if you run into problems, doing a search will probably point in the right direction. And you can test code in the Arduino IDE using C++, then re-write it in Forth to ensure you have a solid understanding of the software and the hardware. I did this initially and it was a great help to write Blink using C++ then rewrite it in Forth.

It is well-documented by Ting. When learning Forth, it helps to have someone that wants to teach it and he’s very good in writing in a understandable way. And finally, if you discover that Forth is not for you, you’ve acquired low cost tools which can be re-purposed or used using the existing Arduino framework!

This version of Forth runs on a FVM, which means it is interpreted by a Forth virtual machine that is running on the ESP32. It can be thought of as a software microcontroller (FVM) running on a hardware microcontroller (ESP32). This level of abstraction allows Ting to create new versions of Forth very quickly, however, it means this version won’t be as fast as a Forth running natively on the microcontroller. The ESP32 is quite fast and powerful, so for many applications this isn’t a significant issue.


  • ESP32 board (one of the following)
  • Arduino IDE
    • Download and install
    • Open application
  • Espressif Arduino ESP32 framework
    • Download and install per instructions on site
  • esp32Forth or the version above from CH Ting’s site. My version has some minor changes that are documented in the README. The pdf is a version of Ting’s documentation with some additional notes by me. It’s best to clone the repository, otherwise download zip file and move to a folder on your system
  • Optional – preferred text editor such as Sublime Text or Atom. I use an external editor instead of the Arduino, as my preferred editor, Sublime Text is far better. I continue to use the Arduino tool set including the Serial Monitor. You will need to check the box “use external editor” in preferences.

Running ESPForth

  1. Open Arduino IDE
  2. Install Arduino core for the ESP32
  3. Once the ESP32 core is installed, be sure to go to Tools -> Board -> ESP32 and select your specific board.
  4. Open the esp32Forth.ino file using Arduino (optional and) your text editor. (If using external text editor, mark the “Use external editor” check box in the Arduino Preferences file.)
  5. Connect your ESP32 to your computer and set the parameters for the board (all under Arduino → Tools):
  6. Board: the right ESP32 board (this should set the rest of the paramaters)
    • Upload Speed:
    • Flash Frequency:
    • Partition Scheme:
    • Core Debug Level:
    • Port:
  7. To have the file data/load.txt loaded by espForth, you will need to use the ESP32 Sketch Data Upload tool. Here is a good tutorial as to how to use it: Random Nerd Tutorials:Install ESP32 Filesystem Uploader in Arduino IDE
  8. Open the Arduino Serial Monitor and you will see the following:
    espForth on boot or reset

    espForth on boot or reset

    espForth after entering words

    espForth after entering words

One more change I made was in the baud rate communication speed. I moved it up to 2000000 from 115200 as it works, and why not go as fast as possible?

Start with Ting’s examples

The best way to get started programming Forth is to play with his examples in his Word document. His examples are well-documented and they can quickly bring you up to speed as to the style and process of writing Forth. The examples are also in my github repository in the pdf in the section Chapter 4. Forth Lessons (is no longer being loaded, retained for documentation purposes)

Comments powered by Talkyard.