These sensors seem extremely finicky to wiring. Are you using a breadboard or have you soldered them already?
I recently made a fermentation and kegerator monitor for a friend and struggled a lot until I soldered it all together.
These sensors seem extremely finicky to wiring. Are you using a breadboard or have you soldered them already?
I recently made a fermentation and kegerator monitor for a friend and struggled a lot until I soldered it all together.
@BulldogLowell
I have the sensor soldered to a stereo audio jack, and I have the audio jack receptacle on the PCB. Looks like this:
Have you tried decreasing the rate at which you are polling the sensor? In some reading modes, it can take up to 750ms for the sensor to take a reading and then be ready to respond to a query. Maybe try something like 10 seconds.
If you think bad sensors may be the problem, get one from another vendor. Personally, I have DS18B20ās from Sparkfun, Digikey and custom length from Alibaba. I may be lucky, but Iāve not had issues with any of them. If you have more than one from the vendor, I think its possible they might be bad, but I would think that is unlikely.
Have you cut off the audio jack and tried directly wiring? If I were you, this would probably be my next step after decreasing the sample time.
Hi,
Just out of curiosity, did you figure out where the issue was in your setup?
getting a bunch of DS18B20 soon and wondering if I should be afraid of where I buy them.
thanks!
Gustavo.
Hi Gustavo,
We have not solved the problem yet, this has been a pretty terrible one. We got new PCBs made and are testing them out this week to see if it solved the issue, We also got some DS18B20s from a different manufacturer to test if the new PCB doesnāt solve the problem. Iāll let you know.
ouch, thanks for getting back and I hope you are able to resolve it!
Gustavo.
Hi
Mybe I can help.
I got my DS18B20s stable by doing the following changes to the DS18B20 code.
The main difference being the SINGLE_THREADED_BLOCK() code path which i only use when NOT connected to the cellular net (!Cellular.ready()). As it seems that the connection process toggles 1ms usercode/1ms system code and that messes up the 1-wire timing.
Other than that Iām using the following āsystem modesā:
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);
void DS18B20::startConversion_internal(){
ds->reset();
if(_UseSkipROM)
ds->skip();
else
ds->select(addr);
ds->write(0x44); // start conversion, with parasite power on at the end
}
void DS18B20::startConversion(bool SingleThreaded){
if(!SingleThreaded)
startConversion_internal();
else
{
SINGLE_THREADED_BLOCK(){
startConversion_internal();
}
}
}
float DS18B20::readTemperature_internal()
{
// we might do a ds.depower() here, but the reset will take care of it.
if(ds->reset() != 1)
return -999;
if(_UseSkipROM)
ds->skip();
else
ds->select(addr);
ds->write(0xBE); // Read Scratchpad
for (int i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds->read();
/* Serial1.print("DS Read Data:");
Serial1.print(data[i], HEX);
Serial1.println(" ");*/
}
_dataCRC = (OneWire::crc8(data, 8));
// Serial1.println(_dataCRC, HEX);
_readCRC = (data[8]);
// Serial1.println(_readCRC, HEX);
// Convert the data to actual temperature
// because the result is a 16 bit signed integer, it should
// be stored to an "int16_t" type, which is always 16 bits
// even when compiled on a 32 bit processor.
int16_t raw = (data[1] << 8) | data[0];
if (type_s) {
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10) {
// "count remain" gives full 12 bit resolution
raw = (raw & 0xFFF0) + 12 - data[6];
}
} else {
byte cfg = (data[4] & 0x60);
// at lower res, the low bits are undefined, so let's zero them
if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
//// default is 12 bit resolution, 750 ms conversion time
}
return (float)raw / 16.0;
}
float DS18B20::readTemperature(bool SingleThreaded){
if(SingleThreaded)
{
SINGLE_THREADED_BLOCK(){
return readTemperature_internal();
}
}
return readTemperature_internal();
}
float DS18B20::getTemperature(bool SingleThreaded){
startConversion(SingleThreaded);
delay(750); // Delay the maximum time needed for 12 bit conversion (750 ms)
return readTemperature(SingleThreaded);
}
Of all the examples presented, MrZANEās should work.
The others have dubious timing issues and likely read the DS18B20 before it is finished conversion.
If you use the CRC you will reject the occasional reading.
So we FINALLY figured this thing out. It turned out that our sensors were defectiveā¦ so you need to be VERY careful who your supplier is for these sensors.
We did a test and got a few from Adafruit, they work 100% perfectly. Our sensors that we ordered directly from a Chinese manufacturer do not (they can work anywhere from a few minutes, to a few hours, to a few days, then will randomly either stop working completely, will begin to drop out for hours or days, and sometimes will come back into a working state temporarily).
I am very interested if you guys could give me a legitimate supplier for these. Adafruits sensors are way to expensive, and Iām sure there are other good ones out there somewhere.
Thanks again for all of the help so far.
I also experienced that AliExpress sensors are stopping working after 0.5 day.
I know itās an old thread, but in case anyone is having similar issues, what solved for me was:
Hope this helps someone.
David, and what about the limit in the input voltage por the digital pin?