This app exposes more functionality to the RPC features of Mongoose OS.
It's compatible exclusively with the ESP32 dev boards (Wemos LOLIN32, mostly) and ESP8266 dev boards (Wemos D1 Mini, mostly).
The app has been developed as a support for the CoderDojo Ninjas' projects at Croke Park, Dublin.
At this time, experiments can be conducted via browser: a web page is presented with various options to play with some relevant RPC calls.
The application is eventually supposed to work with a yet unnamed mobile app, similar to Blynk, but for local, direct communication.
- Install and start mos tool
- Follow instructions in Mongoose OS Docs
- Point a browser to the board address, and start experimenting!
The app provides the following extensions to the standard Mongoose OS RPC Calls
Enables the passed pin for ADC input
Call:
{"pin": num}
Returns:
{"enable": true/false}
Reads the input for the passed pin as ADC value
Call:
{"pin": num}
Returns:
{"value": <pin level (0-1023 or 0-4095)>}
Sets the passed pin for PWM output, with optional frequency (default 50 Hz) and duty cycle (0.0 - 1.0, default 0.5 - square wave)
Call:
{"pin": num[,"frequency":N,"duty":N]}
Returns:
{"success": true/false}
Rotate the servo motor (tested on typical SG90) on the passed pin by the specified angle (0-180)
Call:
{"pin": num,"angle":N}
Returns:
{"success": true/false}
Enables/Disables the TouchPad interface of ESP32.
Call:
{"enable": Bool}
Returns:
{"enable": true/false}
Reads the touch value from the given GPIO pin. The value is unfiltered.
Call:
{"pin": num}
Returns:
{"touch_pin": <ID of the Touch pin>, "value": <raw value of touch>}
Enables the passed I2C address, default is 48 (a.k.a. 0x30), and initializes it with the given frequency (typically 1000 Hz).
Call:
{["address": n1,]"motor": 0-1,"frequency": n2}
Returns:
The initialized motor object to use in subsequent calls or
{}
if unsuccessful.
Writes to the given I2C address (that should match the one passed to D1Motor.Enable, default to 0x30), the motor (0-1), direction (0 - Brake, 1 - CCW, 2 - CW, 3 - Stop) and speed (0-100)
Call:
{["address": n1,]"motor": 0-1,"dir": 0-3,"speed": 0-100}
Returns:
{"success": true/false}
Switches the WiFi connection from AP (default) to STA, optionally setting SSID and password, or back to AP from STA.
Call:
{"enable":Bool[,"ssid":"name","pass":"xxx"]}
Returns:
{"enable": true/false}
The app enables the mDNS capability: this to ease future remote access without the need to know the actual IP address of the microcontroller board. It also uses GPIO 0 as a WiFi reset: when briefly taken to 0, network connection is reset to Access Point.
The CoderDojo logo is used according to their terms
The D1Motor code tries to talk with a Wemos D1 Motor Shield: unfortunately, this piece of hardware comes with a buggy firmware, so the application won't work with it out of the box.
Luckily, someone has taken care of this: a nice project at Hackaday.io has released an updated firmware that solves the issue!
Its installation requires a USB-TTL converter, like this, and a bit of tinkering, but it's otherwise easily doable.