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 "Install" to install the library
Install mDash library

3. Connect your device

Connect your device via USB cable. In the Arduino IDE, select the following setting options:

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

4. Open Shadow.ino sketch

In the Arduino IDE menu, select "File" → "Examples" → "Examples From Custom Libraries" → "mDash" → "Shadow". NOTE: Please, use "Shadow" sketch for this tutorial!

5. Compile and flash

To compile and upload your sketch to your board, click the "Upload" button.

Upload button on Arduino IDE

6. Register new device

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

  • Login to https://mdash.net
  • Click "add device" to add a new device
  • Click "manage device" cog button and a management dialog will appear
  • Click on the device password to copy it to the clipboard

7. Open Serial Monitor

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

Arduino IDE Serial Monitor

8. Configure device

At this point, your device is neither configured for WiFi nor mDash yet. Let's fix it by entering the WiFi and mDash credentials. In the Serial Monitor input field, enter the following command and click "Send":

set wifi.sta.ssid YOUR_WIFI_NETWORK_NAME
Arduino IDE Serial Monitor

Then set the WiFi password:

set wifi.sta.pass YOUR_WIFI_PASSWORD

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

Switch back to the Serial Monitor and enter:

set device.id MDASH_DEVICE_ID
set device.pass MDASH_DEVICE_PASSWORD

9. Reboot device

Now the WiFi and mDash credentials are saved into the configuration file mdash.cfg on the 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 should now appear 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" to get a .BIN file. You might need to save off your sketch into a different one before exporting the binary file otherwise, the IDE might not allow you to export.

12. OTA update

On mDash device dashboard, click "Firmware OTA update" button and a file selection dialog will appear. Navigate to your Arduino sketch directory, and choose the recently exported .bin file Done! Just wait until the OTA is finished.