Flashing the ESP32 DevKit V1 with Mongoose OS
You will need…
- an ESP32 development board with appropriate USB cable
- computer with the
mos
tool installed
I’ll be using the DOIT ESP32 DevKit V1 for the ESP, and as I’m running Linux the mos
tool can be installed using the my package manger.
sudo add-apt-repository ppa:mongoose-os/mos sudo apt update sudo apt install mos
Once installed, mos
can be launched from the terminal by simply running
mos
Flashing the board
Your browser should now have opened to http://127.0.0.1:1992
where you’ll be greeted by this window
If you now plug your dev board into the computer, the device should show up in the first dropdown box. As on Linux, my board shows up as /dev/ttyUSB0
. If everything went well the top section will turn green and the next two dropdowns will unlock. For platform you want to select ESP32
and for app demo-js
and click flash.
You’ll be able to see the progress of the flashing in the console. Once the ESP starts logging the uptime to the console, the system is flashed and running the demo app. By default, the demo starts the ESP32 as a WiFi access point with the SSID (network name) “Mongoose_[six random characters]”, password “Mongoose” and an IP address on 192.168.4.1. The last step, however, will get the ESP connected to your own WiFi network by simply entering your SSID and password and clicking set.
Click done and you’ll be presented with the demo-js
app source code. The demo app flashes the on board LED (or tries to), connects to WiFi, publishes to an MQTT server, and prints the uptime to the console every second.
Programming
I say the the board tries to flash the LED, well if you look at the top of the code you’ll see this line
let led = Cfg.get('pins.led');
This is Mongoose OS asking the board which pin it thinks the LED is connected to. A little further down the code you’ll see the line
print('LED GPIO:', led, 'button GPIO:', button);
which helpfully prints the pins it think the LED and button are connected to when the board is powered on. Here is the result:
[Feb 4 12:34:21.951] LED GPIO: 21 button GPIO: 0
The button it has correct, but the LED on my board is actually connected to digital pin 2. Change the line from before to now read:
let led = 2;
and press the save and reboot button.
Within a couple of seconds the board will reboot and the LED will hopefully be blinking.
Stay tuned
In my next post I’ll look at how to further configure the board and use libraries to interface with a temperature sensor and publish the temperature to a local MQTT server.
Leave A Comment