I’m simply trying to read temps from a DS18B20 temp sensor. I’ve worked with them a long time, and it’s generally working okay. But ID and ROM are NOT dependable using the lib I have.
If I’m monitoring via Serial…
I plug it in and something like 15-20% of the time, the chip type returns junk, rather than the proper chip type.
Also, the ROM address itself doesn’t come back right. It’s wrong more times than not!
What am I doing wrong?? HELP!
-Jeff
---- Sample debugging output ---
Serial monitor opened successfully:
ROM1: [**28 FF 15 99 00 00 00 00**]
1: Chip type [28:DS18B20]
ROM2: [00 00 00 00 00 00 00 00]
2: Chip type [0:Unknown]
ROM3: [00 00 00 00 00 00 00 00]
3: Chip type [0:Unknown]
Serial connection closed. Attempting to reconnect...
Serial monitor opened successfully:
ROM1: [**28 FF 15 99 00 16 02 00**]
1: Chip type [28:DS18B20]
ROM2: [00 00 00 00 00 00 00 00]
2: Chip type [0:Unknown]
ROM3: [00 00 00 00 00 00 00 00]
3: Chip type [0:Unknown]
#include <DS18B20.h>
const int ONE_WIRE_BUS_1 = D4;
const int ONE_WIRE_BUS_2 = D5;
const int ONE_WIRE_BUS_3 = D6;
DS18B20* tempSensor1Ptr;
DS18B20* tempSensor2Ptr;
DS18B20* tempSensor3Ptr;
//---------------------------------------------------------
void setup() {
Serial.begin(14400);
digitalWrite(ONE_WIRE_BUS_1, LOW ) ;
pinMode(ONE_WIRE_BUS_1, INPUT);
digitalWrite(ONE_WIRE_BUS_2, LOW ) ;
pinMode(ONE_WIRE_BUS_2, INPUT);
digitalWrite(ONE_WIRE_BUS_3, LOW ) ;
pinMode(ONE_WIRE_BUS_3, INPUT);
char myAddr[64+1];
tempSensor1Ptr = new DS18B20(ONE_WIRE_BUS_1, true);
tempSensor1Ptr->getROM( myAddr ) ;
Serial.printlnf("ROM1: [%s]", myAddr ) ;
Serial.printlnf("1: Chip type [%x:%s]", tempSensor1Ptr->getChipType(), tempSensor1Ptr->getChipName() );
tempSensor2Ptr = new DS18B20(ONE_WIRE_BUS_2, true);
tempSensor2Ptr->getROM( myAddr ) ;
Serial.printlnf("ROM2: [%s]", myAddr ) ;
Serial.printlnf("2: Chip type [%x:%s]", tempSensor2Ptr->getChipType(), tempSensor2Ptr->getChipName() );
tempSensor3Ptr = new DS18B20(ONE_WIRE_BUS_3, true);
tempSensor3Ptr->getROM( myAddr ) ;
Serial.printlnf("ROM3: [%s]", myAddr ) ;
Serial.printlnf("3: Chip type [%x:%s]", tempSensor3Ptr->getChipType(), tempSensor3Ptr->getChipName() );
}
void loop() {
}