Hi everyone,
I recently picked up a DS18B20 temperature measurement module to log temperatures in a small Arduino project. The idea is to measure ambient temperature in different rooms and eventually expand it to multiple sensors on the same 1-Wire bus.
Setup Details:
-
Arduino Uno
-
DS18B20 module (3-pin version with onboard pull-up resistor)
-
Connected to 5V, GND, and digital pin 2 for data
-
Using the OneWire and DallasTemperature libraries
-
Simple sketch to read temperature every second and print to Serial
Now here are my issues:
-
The sensor sometimes returns -127°C or 85°C, which I know are error codes
-
Readings fluctuate by 1–2°C even in a stable room environment
-
When I connect a second DS18B20 module, only one of them reports consistently, the other drops out randomly
-
Occasionally, the Arduino freezes when reading multiple sensors
What I’ve tried so far:
-
Verified wiring and ensured common ground
-
Added a 4.7k pull-up resistor externally, even though the module claims to have one onboard
-
Tried both 5V and 3.3V supply
-
Adjusted delay between conversions (750ms vs 1000ms)
-
Tested with both parasitic power and normal VDD mode
My questions:
-
Is it normal for DS18B20 modules to need an external pull-up resistor even if one is included on the board?
-
How do you usually stabilize the readings so they don’t jump around by a degree or two?
-
For multiple sensors on one bus, is there a best practice for wiring length and layout to avoid dropouts?
-
Is there a recommended sampling rate for stable results (every second vs every few seconds)?
Thanks in advance for any advice, hoping to make this stable before I scale up to more sensors.
Hello,
I run in the same issue recently. First of all, there are fake sensors around.
You can identify yours by this Arduino sketch:
https://github.com/cpetrich/counterfeit_DS18B20
In my case the solution was to provide a stable +5 V supply to the sensor. The input of the Arduino should get at least 8 V for the internal regulator to work properly and to be able to give +5 V on the regulated 5V pin where the sensor supply attaches. You can use an external 12V/5V converter, as well. I did so, but the one I chose was too noisy, still causing the -127 reading. I replaced it to a better quality PSU and the problem has gone.
My aquarium cooler works flawlessly since I fixed the power supply issue.
0
1. I used normal mode (not parasitic mode) and yes you need a pull-up resistor to +5 V.
4. The sampling rate should be >750 ms IIRC, I used 1 seconds.
0