Please help with my project. 85 degrees problem

Dear friends: I’m working on my project, that consist in 9 DS18B20 sensors connected to a Lolin32 board. I need to read 9 temperatures at same time.
The problem is that many times it appears the 85 value. I tried everything to avoid bad wiring connections or similar problems, but 85 is still there.
I would prefer to filter the value. I need the 85 value not to be sent to MQTT server (cayenne) but I don’t know how to do it.
I tried lines similar to
while (temp == 85.0 || temp == (-127.0))
but I can’t write it in the correct syntax. Is there any way to filter these values?
How can I do it?
Many thanks in advance
best regards

Can you post your current code?

Hi Adam, here is the code:

#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP32.h> 
#include <OneWire.h>
#include <DallasTemperature.h>
#include <DNSServer.h>
#include <WebServer.h>
#include <WiFiManager.h>  
#include <WiFi.h>          //

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.

char username[] = "xxx";
char password[] = "xxx";
char clientID[] = "xxx";

#define ONE_WIRE_BUS 22
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress tempSensorA = { 0x28, 0xD6, 0x81, 0x37, 0x38, 0x19, 0x01, 0x5B };  
DeviceAddress tempSensorB = { 0x28, 0xCB, 0x18, 0x3B, 0x38, 0x19, 0x01, 0x1C }; 
DeviceAddress tempSensorC = { 0x28, 0x93, 0xF4, 0x28, 0x38, 0x19, 0x01, 0xD8 };
DeviceAddress tempSensorD = { 0x28, 0xFF, 0xB6, 0xA3, 0x01, 0x17, 0x03, 0x71 };
DeviceAddress tempSensorE = { 0x28, 0xFF, 0x91, 0x6F, 0x81, 0x14, 0x02, 0x9A };
DeviceAddress tempSensorF = { 0x28, 0xD3, 0xBC, 0x31, 0x38, 0x19, 0x01, 0xD1 };
DeviceAddress tempSensorG = { 0x28, 0xFF, 0x29, 0xC7, 0x24, 0x17, 0x03, 0x96 };
DeviceAddress tempSensorH = { 0x28, 0x2A, 0x82, 0x00, 0x38, 0x19, 0x01, 0xD4 };
DeviceAddress tempSensorI = { 0x28, 0x6D, 0xE2, 0x1D, 0x38, 0x19, 0x01, 0x90 };

#define DATA_CHANNEL1 6 //Virtual channel for publishing sensor data.

#define DATA_CHANNEL2 7 //Virtual channel for publishing sensor data.

#define DATA_CHANNEL3 8 //Virtual channel for publishing sensor data.

#define DATA_CHANNEL4 9 //Virtual channel for publishing sensor data.

#define DATA_CHANNEL5 10 //Virtual channel for publishing sensor data.

#define DATA_CHANNEL6 11 //Virtual channel for publishing sensor data.

#define DATA_CHANNEL7 12 //Virtual channel for publishing sensor data.

#define DATA_CHANNEL8 13 //Virtual channel for publishing sensor data.

#define DATA_CHANNEL9 14 //Virtual channel for publishing sensor data.

unsigned long lastMillis = 0;

void setup() {
  Serial.print("Calificador DL ver.2.2");
    //Local intialization. Once its business is done, there is no need to keep it around
    WiFiManager wifiManager;
    //reset saved settings
    //set custom ip for portal
    //wifiManager.setAPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));

    //fetches ssid and pass from eeprom and tries to connect
    //if it does not connect it starts an access point with the specified name
    //and goes into a blocking loop awaiting configuration
    //or use this for auto generated name ESP + ChipID

    //if you get here you have connected to the WiFi
    Serial.println("connectadoooo :)");

  Cayenne.begin(username, password, clientID);
//  sensor_t sensor;
   //set the resolution to 10 bit
  //sensors.setResolution(tempSensorA, 10);
  //sensors.setResolution(tempSensorB, 10);
  //sensors.setResolution(tempSensorC, 10);


void loop() {
   Cayenne.virtualWrite(0, millis());
   Cayenne.celsiusWrite(DATA_CHANNEL1, sensors.getTempC(tempSensorA));

   Cayenne.celsiusWrite(DATA_CHANNEL2, sensors.getTempC(tempSensorB));

   Cayenne.celsiusWrite(DATA_CHANNEL3, sensors.getTempC(tempSensorC));

   Cayenne.celsiusWrite(DATA_CHANNEL4, sensors.getTempC(tempSensorD));
   Cayenne.celsiusWrite(DATA_CHANNEL5, sensors.getTempC(tempSensorE));

   Cayenne.celsiusWrite(DATA_CHANNEL6, sensors.getTempC(tempSensorF));

   Cayenne.celsiusWrite(DATA_CHANNEL7, sensors.getTempC(tempSensorG));

   Cayenne.celsiusWrite(DATA_CHANNEL8, sensors.getTempC(tempSensorH));
   Cayenne.celsiusWrite(DATA_CHANNEL9, sensors.getTempC(tempSensorI));



thank you!

You can put an if statement around each of the values you are sending. Ex:

if (tempSensorA != 80 || tempSensorA != (-127.0)){
  Cayenne.celsiusWrite(DATA_CHANNEL1, sensors.getTempC(tempSensorA));

Many thanks, Adam.
I tried that code but didn´t pass verification
calibrador_ver3.0:117:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]

if (tempSensorA != 80 || tempSensorA != (-127.0)){


calibrador_ver3.0:117:51: error: invalid operands of types ‘DeviceAddress {aka unsigned char [8]}’ and ‘double’ to binary ‘operator!=’

if (tempSensorA != 80 || tempSensorA != (-127.0)){

Any idea?
Thanks in advance. Regards

I’m not sure if I understand the problem, but if you are having inconsistent readings with that many sensors it will help to reduce the 4.7k resistor in value. I needed a 2.2k with 5 sensors. Especially if the leads are shielded or longer.

1 Like

I’ll try it. Many thanks for your help John

Well, tried but didn’t work. I connected a 1.2 k, 1.5k and 1.8 k ohm and the problem remains the same. Any other idea?

Since the resistor didn’t work, try the software again.

if (sensors.getTempC(tempSensorA) != 80 || sensors.getTempC(tempSensorA) != (-127.0)){
  Cayenne.celsiusWrite(DATA_CHANNEL1, sensors.getTempC(tempSensorA));

many thanks, Adam. It seems to be working!

1 Like

Hi again. 85 and -127 are back

¿any idea? Many thanks and merry Xmas!

anche io ho avuto gli stessi problemi,cavi lunghi e anche con schermature buone se ci sono vicino strumenti che emettono armoniche , tipo inverter o roba simile, avrai sempre questi problemi, prova ad accorciare i cavi.
altro problema che riscontro spesso è l 'alimentazione. io ad arduino ne ho messe anche 12 di sonde onewire e se non lo alimento a 9v mi danno errori come stai descrivendo tu, non conosco il lolin32 ma prova come ti ho suggerito magari è l uovo di colombo