Send JSON String of BMP280 to smartphone using BLE notify in ESP32

This is something new for me I am converting the BMP280 Sensor data in JSON string and want to store it in char buffer in ESP32 device which using BLE notify and send it to a smartphone so that I will be able to display the data in application NRF Connect.

Any Kind of sample on this will be very useful.

There is a very efficient library for json for Arduino here, with many examples.

Also, the assistant helps you create your code. For example, if you want this :

"sensor": "BMP280",
"time": 1351824120,
"data": 1024.3

The assistant provides this serializing code:

const size_t capacity = JSON_OBJECT_SIZE(3);
DynamicJsonBuffer jsonBuffer(capacity);

JsonObject& root = jsonBuffer.createObject();
root["sensor"] = "BMP280";
root["time"] = 1351824120;
root["data"] = 1024.3;


Of course, you would replace the pressure value by the sensor's reading and the time by some data from a RTC.

1 Like