Mongoose OS on esp32

Heard about mongoose OS from http://tech.scargill.net/mongoose-os/ . Scargills blog is always worth a read if you are interested in sbc, iot, home automation and node-red.

Mongoose OS is an open source Operating System for the IOT, supporting ESP32, ESP8266, STM32, TI CC3200 (Amazon AWS IoT integrated). Code in C or JavaScript.

This sounded interesting, and seemed a middle way between the arduino and esp32-IDF routes of programing the esp32. Also as it is built with IOT in mind is a good place to learn a bit more.

Installed following https://mongoose-os.com/software.html

Tried

This launches a gui in a webpage. I could select the usb port that the esp32 was on, but when i tried to flash mongoose onto it I got:

The solution is to flash from the command line:

Much happier:

Then go back to the gui using

for final configuration (like the ssid and password).

One of the examples is a mqtt example that publishes the sys.free ram to a mqtt feed when the boot button is pressed on the esp32. With a bit of digging I found ‘api_adc.js’ that acts as a wrapper for the adc api, so I could use the YL-83 rain sensor on pin 32.

You can see the feed at after testing with drops of water.

 

 

ESP32 + analogRead()

The ESP32 is the new chip-on-the-block for Internet of Things, having both wi-fi and bluetooth. I have a breakout board from doit.am. They are coming down in price and can be found for under £7. This breaks out many(but not all) of the pins. I wanted to use a temperature sensor TMP36 and use analogRead() like in https://makerhacks.com/thermometer-esp8266-arduino/. That example was for the ESP8266.

However, being relatively new, the ESP32 does not support reading an analog input using that simple analogRead() that you find in the arduino ide.

Actually, I just worked out it dosen’t support analogWrite() at  the moment, analogRead() works fine. However, it gave me a chance to learn about other environments for the esp32.

So it’s off to download and install the “Espressif IoT Development Framework” https://github.com/espressif/esp-idf
esp32

Read the docs on ADC http://esp-idf.readthedocs.io/en/latest/api-reference/peripherals/adc.html

The ADC driver API currently only supports ADC1 (9 channels, attached to GPIOs 32-39).

The doit.am only goes to GPIO 35, so we have 4 to play with. Compiling and flashing the adc1_test, in /examples/peripherals/adc/main/adc1_test.c
ADC1_CHANNEL_4 is used, from the docs ADC1 channel 4 is GPIO32

The analog read worked, but the temperature sensor was a bit funny. So I tested it with a rain-detector, which seemed to give reasonable results.