mDash QuickStart for Arduino

1. Setup Arduino IDE

Make sure you have Arduino IDE v.1.8.5 or later. If you have not installed Arduino with ESP32 support yet, please follow Installing the ESP32 Board in Arduino IDE

2. Install mDash library

  • In the Arduino IDE menu, select "Sketch" → "Include Library" → "Manage Libraries"
  • In the search field, type mDash and press Enter
  • Click on Install to install the library
Install mDash library

3. Connect your device

Connect your device via USB cable. In the Arduino IDE, setup the board:

  • Choose "Tools" → "Board" → "ESP32 Dev Module"
  • Choose "Tools" → "Partitioning Scheme" → "Minimal SPIFFS"
  • Choose "Tools" → "Port" serial port
Setup the board

4. Choose Shadow.ino sketch

In the Arduino IDE menu, select "File" → "Examples" → "Examples From Custom Libraries" → "mDash" → "Shadow". NOTE: it is important to use "Shadow" sketch!

5. Compile and flash

Click on the "Upload" button to compile and upload the sketch to your board

Upload button on Arduino IDE

6. Register new device

Register new device on mdash.net and get its password (token)

  • Login to https://mdash.net
  • Click on "add device" button to add a new device
  • Click on a device settings link. A management dialog should appear
  • Click on a device password to copy it to the clipboard

7. Open Serial Monitor

Open Serial Monitor ("Tools" → "Serial Monitor"). Choose port speed 115200:

Arduino IDE Serial Monitor

8. Configure device

At this point, your device is not configured for WiFi, and it is not configured for mDash. Let's enter WiFi and mDash credentials. In the Serial Monitor input field, enter the following and press enter:

set wifi.sta.ssid YOUR_WIFI_NETWORK_NAME
Arduino IDE Serial Monitor

Then set WiFi password:

set wifi.sta.pass YOUR_WIFI_PASSWORD

Switch to the mDash UI in order to get device ID and password:

Switch to the Serial Monitor and enter:

set device.id MDASH_DEVICE_ID
set device.pass MDASH_DEVICE_PASSWORD

9. Reboot device

Now WiFi and mDash credentials are saved into the configuration file mdash.cfg on a device's filesystem.

Notice that the sketch does not contain WiFi or cloud credentials. That means that a compiled sketch could be used to OTA (over-the-air) update multiple similar devices. However, if you'd like to hardcode device credentials into the firmware, change mDashBegin() call to mDashStartWithWifi(WIFI_NAME, WIFI_PASS, DEVICE_ID, DEVICE_TOKEN).

Reboot your device by entering a reboot command in the Serial Monitor:

reboot

10. Device online

Your device must become online on the mDash device list

Mdash device online

11. Compile new firmware

Now it is time to perform over-the-air firmware update! In Arduino IDE menu, select "Sketch" > "Export compiled binary"

12. OTA update

On mDash device dashboard, click on "OTA update" link. A file selection dialog appears. Navigate to your Arduino sketch directory, and choose the recently exported .bin file Done! Just wait until the OTA is finished.