Hello everyone. I need help with the temperature sensor ds18b20. I put the sensors in parallel mode (normal mode) and I catch the value of the reading normally. The problem is: after a period of time (this period of time, some time is a short period and some time is for an average period of time), the ESP32 starts to lost the signal of the sensors (one after another) and retrieve the value -127,00 (I know that this value is lost signal information). I use 4 sensor in the same pin (1-wire bus). About the connection, I review this a lot of times and I sure that is correct. Follow my code:
#include <UnicViewAD.h>
#include <OneWire.h>
#include <DallasTemperature.h>
LCM Lcm(Serial);
LcmVar display1(10);
LcmVar display2(11);
LcmVar display3(12);
LcmVar display4(13);
OneWire sensorsPin = 25;
DallasTemperature sensors(&sensorsPin);
float lastTemperature1 = 0;
float lastTemperature2 = 0;
float lastTemperature3 = 0;
float lastTemperature4 = 0;
void setup()
{
sensors.begin();
Lcm.begin(115200);
delay(3000);
Serial.println("Quantity: " + String(sensors.getDeviceCount()));
}
void loop()
{
float currentTemperature1, currentTemperature2, currentTemperature3, currentTemperature4;
sensors.requestTemperatures();
currentTemperature1 = sensors.requestTemperaturesByIndex(0);
currentTemperature2 = sensors.requestTemperaturesByIndex(1);
currentTemperature3 = sensors.requestTemperaturesByIndex(2);
currentTemperature4 = sensors.requestTemperaturesByIndex(3);
if(lastTemperature1 != currentTemperature1)
{
lastTemperature1 = currentTemperature1;
display1.write(currentTemperature1);
}
if(lastTemperature2 != currentTemperature2)
{
lastTemperature2 = currentTemperature2;
display2.write(currentTemperature2);
}
if(lastTemperature3 != currentTemperature3)
{
lastTemperature3 = currentTemperature3;
display3.write(currentTemperature3);
}
if(lastTemperature4 != currentTemperature4)
{
lastTemperature4 = currentTemperature4;
display4.write(currentTemperature4);
}
Serial.println("Temperature: 1" + String(currentTemperature1));
Serial.println("Temperature: 2" + String(currentTemperature2));
Serial.println("Temperature: 3" + String(currentTemperature3));
Serial.println("Temperature: 4" + String(currentTemperature4));
}
About the time to read the values of the temperature. has an average reading time between one reading and another?
Thanks in advance!!!