Register null data into bucket


#1

I have this simple part of my code to send data from an ds18b20 to thinger.io:

   void setup() {
          thing["temp"] >> [](pson & out) {
                   sensors.requestTemperatures();
                  out["TEMPERATURA"] = sensors.getTempCByIndex(0);
          };
          sensors.begin();
    }

    void loop(void) {
            thing.handle();
    }

My question is how to send a null or error value wen the sensor is disconected.
ds18b20 sends -127 in error cases, how could I show it in a dashboard or bucket?

Thanks in advance!


#2

I would try something like this:

thing["temp"] >> [](pson & out) {
                   sensors.requestTemperatures();
                   int tempRead = sensors.getTempCByIndex(0);
                   if (tempRead != -127)
                   {
                     out["TEMPERATURA"] = tempRead;
                   }
          };

In this way the “thing” will send a value only if its different to -127.

Hope this helps


Problem ploting Data
#3

Thanks a lot, it’s the best solution, I also could make a default range.