Skip to content
Quick start Product guide

Generate sketch

WizDash builds an ESP32 sketch from the project’s connection settings and dashboard. You can open it directly in the Arduino IDE.

WizDash Projects screen with the project menu open; the project card has an Options button, and the menu lists Enter Dashboard, Connection Settings, Device Info, and Generate Arduino Code
Steps 1–2: on the Projects screen, tap Options on the project card. The project menu slides up from the bottom. Tap Generate Arduino Code.
  1. Open the app and go to the Projects screen.
  2. Find the project, then tap the Options button on the right side of its card.
  3. In the project menu that opens, tap Generate Arduino Code.
  4. In the Arduino Code dialog, set the optional peripherals you need. An MQTT project also has an OTA toggle.
  5. Tap Copy Code and paste it into the Arduino IDE, or tap Export File to save an .ino file.

If the connection settings are not complete, the app shows a “Connection setup incomplete” message and does not open the dialog. Tap Connection Settings in the same project menu first, then come back.

The sketch includes the connection flow for the mode you chose, and two functions for you to finish:

  • sendData collects the display keys into one JSON object and sends it to the app.
  • onCommand receives commands from the app and leaves the matching hardware action in a comment.

The sketch is a starting point. Without a chosen peripheral, readings are sample numbers, and the hardware actions for controls are marked TODO. Before flashing, check the pins, the JSON keys, and the WiFi or broker settings. On Android, the saved file goes to the Download folder.

WizDash full Arduino sketch viewer showing sendData() and onCommand() in WizDash_ESP32.ino
Tap “Tap to view full code” to inspect the complete WizDash_ESP32.ino sketch, including sendData() and onCommand() pre-populated with your widget JSON keys.

Before flashing, do two things in the Arduino IDE. The comment at the top of the generated sketch lists the same libraries.

  1. Choose the board. Open Tools → Board and select the ESP32 model that matches your board, such as ESP32 Dev Module, ESP32S3 Dev Module, or ESP32C3 Dev Module. If the ESP32 board package is not installed yet, install Espressif’s esp32 package in Boards Manager first.
  2. Install the libraries. Open Tools → Manage Libraries, then search for and install the libraries in the table below.
ConnectionLibraryAuthorUsed for
All modesArduinoJsonBenoit Blanchon, v7 or laterBuilds the JSON object in sendData and parses commands in onCommand
BLENimBLE-Arduinoh2zeroProvides the BLE service and advertising
WiFiWebSocketsMarkus SattlerServes WebSocket on port 81
MQTTPubSubClientNick O’LearyConnects to your own MQTT broker

WiFi, ESPmDNS, WiFiUdp, WiFiClientSecure, and the HTTPClient and Update that OTA uses are all built into the ESP32 board package. You do not need to install them separately.

The sketch fails to compile with ArduinoJson v6 or earlier. If the compiler reports a missing header, check that the libraries in the table are installed and meet the version requirement.

While generating the sketch, you can attach some widgets to common parts. The choice applies only to that generated file. It is not saved in the project.

PartWidgets it can drive
DHT11 temperature and humidity sensorThermometer, Humidity Ball
PotentiometerData Card shows the raw reading. Gauge and Level show a percentage.
Relay or external LEDOne Switch, active-low or active-high.
RGB LEDOne Color Picker, common cathode or common anode.
PMS3003, PMS5003, or PMS7003 dust sensorOne Data Card.

When you choose DHT11, you also need DHT sensor library (by Adafruit) and Adafruit Unified Sensor, in addition to the libraries above. The comment at the top of the sketch adds both once you choose it. The other peripherals use built-in ESP32 features (analogRead, digitalWrite, analogWrite, Serial2) and need no extra library.

If the dashboard has a Map widget and you attach a GPS module yourself, a comment in the sketch suggests the TinyGPS++ library. The sketch does not insert GPS reading code for you.

The available pins follow a classic ESP32-WROOM and avoid pins that have a special role at startup.

For an MQTT project, you can also include over-the-air update support when generating the sketch. See OTA updates.

WizDash Generate Arduino Code dialog upper section showing the OTA toggle, DHT11 peripheral filter chips, and .ino sketch preview
Peripherals & OTA (top): optionally include MQTT OTA and bind Thermometer or Humidity Ball widgets to a DHT11 pin.
WizDash Generate Arduino Code dialog lower section showing Potentiometer ADC1 pin selection and Digital output relay/LED pin mapping
Peripherals (bottom): map a Gauge or Data Card to an ADC1 potentiometer pin, or map a Switch to a digital output pin.