Mongoose OS ESP32-PICO-KIT breakout was designed by
Espressif Systems
specifically for the
AWS Pop-up Loft Dedicated to Espressif. It provides a quick way to start IoT development on ESP32.
This quick start guide and reference materials include the following:
aws iot list-things
command works without errorsmos
tool on your computermos aws-iot-setup
command to provision your
device to AWS IoT
init.js
file to open it.
load('api_gpio.js');
load('api_mqtt.js');
let topic = 'mos/topic1';
let pin = 36;
GPIO.set_button_handler(pin, GPIO.PULL_UP, GPIO.INT_EDGE_NEG, 200, function() {
let message = JSON.stringify({ foo: 'bar' });
let ok = MQTT.pub(topic, message, 1);
print('Published:', ok);
}, null);
3. Open AWS IoT console, click on "Test" link on the left hand side.
mos/topic1
topic.
init.js
, copy/paste this code, click "Save + Reboot":
load('api_mqtt.js');
load('api_timer.js');
load('api_bh1730.js');
let topic = 'mos/topic1';
let bh1730 = BH1730.create(0x29);
Timer.set(1000, 1, function() {
let message = JSON.stringify({ lux: bh1730.read_lux() });
let ok = MQTT.pub(topic, message, 1);
print('Published:', ok);
}, null);
2. Open AWS IoT console, see JSON messages with light sensor measurements appear.
init.js
, copy/paste this code, click "Save + Reboot": Open
init.js
, copy/paste this code, click "Save + Reboot":
load('api_mqtt.js');
load('api_timer.js');
load('api_bh1730.js');
load('api_arduino_bme280.js');
let topic = 'mos/topic1';
let bh1730 = BH1730.create(0x29);
let bme = Adafruit_BME280.create();
bme.begin(0x76);
Timer.set(1000, 1, function() {
let message = JSON.stringify({
lux: bh1730.read_lux(),
temperature: bme.readTemperature(),
humidity: bme.readHumidity(),
pressure: bme.readPressure(),
});
let ok = MQTT.pub(topic, message, 1);
print('Published:', ok, message);
}, null);
2. Open AWS IoT console, see JSON messages with sensor measurements appear.
mos/topic1
and waits for MQTT messages with control commands. We are going to send those commands via the AWS IoT MQTT console.
init.js
, copy/paste this code, click "Save + Reboot":
load('api_mqtt.js');
load('api_neopixel.js');
let topic = 'mos/topic1';
let strip = NeoPixel.create(23, 5, NeoPixel.GRB);
MQTT.sub(topic, function(conn, topic, msg) {
print('Topic:', topic, 'message:', msg);
let obj = JSON.parse(msg);
strip.setPixel(obj.pixel, obj.r, obj.g, obj.b);
strip.show();
}, null);
2. Open AWS IoT console, and publish this message to topic
mos/topic1
:
{
"pixel": 0, "r": 40, "g": 120, "b": 220
}
3. See how LED lights up. Play with different values for pixel, red, green, blue.