Problem ploting Data


#1

Hi!

I´m using a Node MCU D1 mini and a ds18b20 temperature sensor. The sensor works fine, I´m able to plot the data in the graphs but every now and then it displays a -127 or a 85 and then returns to show the real data. Can anyone give me a hint of where is the problem?

Best Regards,

Tomás


Ignoring outlining data
#2

It seems an issue with the sensor, not an issue with platform.

I suggest to filter the sensor readings in order to discard these values.


#3

Hi Ega!

Thanks for the response. Do you suggest from the code or some kind of electronic filter?

Cheers!

TOmas


#4

From the code, even there is another post that makes reference that when this sensor has an error, send this value (-127), I didn’t knew this, just read 5 minutes ago

Here is what I would try

Hope this helps


#5

And if you share your code (in the right way), I can see what can be done according your particular case.


#6

Thanks ega!

I´ve actually done this but it doesn´t get better. I will try with > < and decrease the range of reading. Will post the result!

Cheers


#7

You can even try to restringe the range of the measurement, I mean only accept values if they are ± 20 (for example, this thereshold should be determinated by the speed of the phenomena changes and the lapse between the measurements) from the last reading, but must be carefull because you can get a missreading as reference (for example the first time when you turn on or reset the device) and loss all the good readings.

I had done something like this, and counted how many consecutive missreadings have, and if the amount of missreadings exceeds a thereshold, I took another reading as reference.

Hope this helps


#8

Sorry to jump into this thread, I have had a similar issue with my sensor recording error readings of around -10’C and humity of 150%. I have used Ega’s suggestion to filter out the errors, but this has only partially solved my issue

.

There is another error reading approx 10 degrees less than the actual temp briefly and the -10’c error, resurfaced briefly as -9’c. I am still wondering how it would be possible to filter these out as well?


// Import libraries
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <ThingerESP8266.h>
#include "DHT.h"

// Define and initialise the sensor
#define DHTPIN D2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
#define USERNAME "robecq"
#define DEVICE_ID "NodeMCU1"
#define DEVICE_CREDENTIAL "Whatam1doing"

#define SSID "Lollipop"
#define SSID_PASSWORD "Melbourne"

ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

void setup() {
  
  // Setup WiFi
 thing.add_wifi(SSID, SSID_PASSWORD);
  // Define the 'thing' with a name and data direction
  thing["dht11"] >> [](pson& out){
// filters out abnormal readings
  int tempRead = dht.readTemperature(0);
    if (tempRead > -10) { out["celsius"] = dht.readTemperature(0);
  int humRead = dht.readHumidity(0);
    if (humRead < 100) { out["humidity"] = dht.readHumidity (0);
    // Add the values and the corresponding code
    out["humidity"] = dht.readHumidity();
    out["celsius"] = dht.readTemperature();
    }
    }
  };
}


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


#9

I would try this way

  thing["dht11"] >> [](pson& out){
// filters out abnormal readings
  int tempRead = dht.readTemperature(0);
    if (tempRead > -10) {
     out["celsius"] = tempRead;
    }

  int humRead = dht.readHumidity(0);
    if (humRead < 100) { 
        out["humidity"] = humRead;
    }
  };

By this way the sensor read is compared and keep the value, the previous code read the value, compared and after that read the sensor again and give the value, so it can publish any value because it is not filtered.

Even there is a way to filter and only accept values between a range (±10, for example), but you need to declare a global variable and compare the readings from the sensor with that value, so it can be filtered, but I would try another sensor because it’s weird that behavior that follows the tendence but introduces a gap of about 12 degrees.

Hope this helps