Data Formats
The mobile app will be the final destination for data and the source for control signals. It will receive data either from an MQTT message broker topic or over Bluetooth (BLE). The data format will be JSON (opens in a new tab).
Data transmission between all components (boards, Node-RED, MQTT Broker, and Mobile App) works best with data sent as serialized JSON. While the code uses JSON objects, all languages have JSON libraries to convert JSON objects to serialized JSON and then deserialize the JSON back to JSON objects.
The sensor data from the Nano and Pico to the ESP32 and the control signals from the ESP32 to the Nano and the Pico will both follow the JSON structure shown:
{
pin: [String],
value: [integer],
}
The boards will use pin numbers as the key since programming that on the boards is unavoidable. The mapping of pins to sensors or devices will be maintained in the app where it can be configured easily without requiring code changes.
If the app has the same pin configured for multiple sensors or devices the data may be incorrectly displayed. Currently an alert is provided to highlight the use of the same pin across sensors or devices. In subsequent versions a check may be enforced.