This is an example Mongoose OS app that connects to Losant via MQTT.
- ESP8266
- ESP32
Before beginning, you must have the mos
tool installed. For more info, see the mos installation instructions.
- First, clone the losant app
$ git clone https://github.com/mongoose-os-apps/losant-mqtt
- Build the firmware: (esp8266 or esp32)
$ mos build --arch esp8266
- Flash the device: (esp8266 or esp32)
$ mos flash
- Configure WiFi:
mos wifi WIFI_SSID WIFI_PASSWORD
You must replace the following values:
- WIFI_SSID
- WIFI_PASSWORD
- Login to Losant service. Create and app and credentials for your device:
- Configure MQTT connection to Losant:
mos config-set mqtt.client_id=LOSANT_DEVICE_ID \
mqtt.user=LOSANT_ACCESS_KEY \
mqtt.pass=LOSANT_ACCESS_SECRET
You obtain the LOSANT_DEVICE_ID
, LOSANT_ACCESS_KEY
, and LOSANT_ACCESS_SECRET
values from Losant.
- To stream logs to the terminal:
$ mos console
- Press "Flash" button to trigger data sending:
$ mos
- Switch back to Losant page, watch data graph: