Hello Everyone,
I was wondering whether we can put multiple sensors to a single device. It might feel a bit confusing. So, I'll try to explain. Right now if I load the "multi_device" example code to a single ESP32 board, it actually creates 4 different devices in the esp-rainmaker app. It makes sense if there are multiple different types of devices connected to the ESP32. But in my case, I am trying to monitor a couple of sensor Outputs (for example one temperature and one humidity sensor). It would be very convenient if I have only one device in my esp-rainmaker app for one ESP32 board and that device will show both the sensor output inside a single device in two different lines.
Right now based on the example code if I use two ESP32 boards, in the rainmaker app it will show me four devices (ESP1-- Temp, ESP1--Hu, ESP2-- Temp, ESP2-- Hu). But I want one device for one ESP32 board (ESP1-- Temp, Hu)
Hopefully, I was able to explain the scenario. Is it possible to perform such kind of operation? I would really appreciate it if someone can give me detailed info on it.
Thank you.
Multiple sensor data in a single Rainmaker App device
-
- Posts: 307
- Joined: Wed Feb 20, 2019 7:02 am
Re: Multiple sensor data in a single Rainmaker App device
Hello,
You may use a single device and multiple parameters if that suits your use case. Here's a sample (but untested) code for reference:
Let me know if this serves your purpose.
You may use a single device and multiple parameters if that suits your use case. Here's a sample (but untested) code for reference:
Code: Select all
esp_rmaker_device_t *device = esp_rmaker_device_create("Sensor", "my.sensor", NULL);
if (device) {
esp_rmaker_device_add_param(device, esp_rmaker_name_param_create(ESP_RMAKER_DEF_NAME_PARAM, "Sensor"));
esp_rmaker_param_t *t_param = esp_rmaker_param_create("Temperature", "my.temperature", esp_rmaker_float(DEF_TEMPERATURE), PROP_FLAG_READ);
esp_rmaker_device_add_param(device, t_param);
esp_rmaker_param_t *h_param = esp_rmaker_param_create("Humidity", "my.humidity", esp_rmaker_float(DEF_HUMIDITY), PROP_FLAG_READ);
esp_rmaker_device_add_param(device, h_param);
}
Re: Multiple sensor data in a single Rainmaker App device
Hello Piyush,
Again thanks a lot . I'll give it a try and let you know.
Again thanks a lot . I'll give it a try and let you know.
Who is online
Users browsing this forum: No registered users and 6 guests