duxliteratum
Posts: 10
Joined: Sun Sep 26, 2021 5:11 am

Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Sun Sep 26, 2021 5:48 am

3 brand new sensors waterproof DS18B20 sensors from adafruit and a brand new Pi 3 A+

I was an idiot and hooked up a ribbon cable wrong way round on the Pi so the pins were in reverse on the adafruit cobbler.

I then followed this guide and hooked pin 39 (ground) to the red wire, pin 35(GPIO19) to the black wire, and pin 34 (Ground) to the yellow (data) wire. I have no idea what affect this might have had on the Pi. I futzed around placing these cables in a few permutations of those same pins and obviously none of the temperature sensors showed up in /sys/bus/w1/devices.

Now, I figured out that I had things swapped, hooked things up according to the diagram and still got no sensors posting.

So I removed all of the sensors and followed this guide to try every permutation of regular power, parasitic power, and dtoverlay configuration that I could think of. None of these result in sensors that show up with a directory starting with "28" in /sys/bus/w1/devices.

Now I'm stuck wondering if I've damaged the sensors, the Pi, or am simply missing something stupid about how to set up these sensors or the various drivers.

Current wiring:
Image

Current last line of /boot/config.txt:

Code: Select all

dtoverlay=w1-gpio,pullup=1,gpiopin=22

duxliteratum
Posts: 10
Joined: Sun Sep 26, 2021 5:11 am

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Sun Sep 26, 2021 3:30 pm

To be clear, my current wiring is the parasitic power configuration (both red (power) and blue (ground) are wired to ground, while the pull up resistor is connecting the data line to 3.3v) with data going into GPIO22.

pcmanbob
Posts: 11798
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Sun Sep 26, 2021 5:44 pm

So assuming you have enabled the 1-wire interface using raspi-config,

The default pin is gpio 4 but you appear to have the data pin connected to gpio 22.

I would also suggest you connect the Vcc pin on the DS18B20 to the 3.3V header pin .

I would also suggest you only connect one sensor while you are trying to get your setup working.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
bensimmo
Posts: 5456
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Sun Sep 26, 2021 7:05 pm

Go back to stage one, scrap the pull up.
You're setting to 22 and I do see the wire going there, ( to pcmanbob), which is good.
Do remember to reboot. (just a check some people do forget.)

User avatar
bensimmo
Posts: 5456
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Sun Sep 26, 2021 7:08 pm

Adafruit have a guide, I think.

Just checking, they spec blue as GND?
Yellow as data and red as VCC?

Your blue looks to be connecting to red on the two power rails, your resistor look to be the wrong side of the yellow at the bottom, it should be online across the short width of the board, it looks to be along the long width?

Edit zoomed in some more, the resistor seems fine for data, hard to see though.

But all the marked lined VCC and GND on the DS are at GND?
Screenshot_20210926_201251.jpg
Screenshot_20210926_201251.jpg (156.23 KiB) Viewed 699 times
Ah sorry you're setup in parasitic, scrap that and go 'normal', try parasitic once working.

User avatar
bensimmo
Posts: 5456
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Sun Sep 26, 2021 7:21 pm

You could check you lines.
Check the gpio goes high and low as needed, just jumping the connection on the to gpio22 etc to ground and 3V3 (or to GND if you pull it high).
Basically a switch.

Also the bendy wires of the DS can sometimes not make a good contact in the breadboard.

JohnsUPS
Posts: 260
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Mon Sep 27, 2021 1:01 am

Unless its just the picture, the resistor appears to be 470 ohms, not 4700.

ame
Posts: 3742
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Mon Sep 27, 2021 6:40 am

duxliteratum wrote:
Sun Sep 26, 2021 3:30 pm
To be clear, my current wiring is the parasitic power configuration (both red (power) and blue (ground) are wired to ground, while the pull up resistor is connecting the data line to 3.3v) with data going into GPIO22.
Have you tried it without parasitic power? It would be worth doing that first. Then if you know everything is working you can try parasitic power mode again.

Edit: Never mind. I see you tried that.

pcmanbob
Posts: 11798
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Mon Sep 27, 2021 7:07 am

I would suggest you start over,

Get rid of the ribbon cable and just hook one DS18B20 up directly to the gpio pins like this.

Image

Remove this line form config.txt

Code: Select all

dtoverlay=w1-gpio,pullup=1,gpiopin=22
make sure the 1-wire interface is enabled using " sudo raspi-config ", I would disable it reboot then re-enable it and reboot.

then run the following and see if your sensor is detected.

Code: Select all

cd /sys/bus/w1/devices

ls

cd 28-XXXXXXXXXXXX (change the X’s to your own address)

cat w1_slave
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
bensimmo
Posts: 5456
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Mon Sep 27, 2021 12:49 pm

Awaiting op, but a closer look at the resistor does seem to show it wrong.
Which would be a good catch :-)

duxliteratum
Posts: 10
Joined: Sun Sep 26, 2021 5:11 am

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Mon Sep 27, 2021 5:41 pm

bensimmo wrote:
Mon Sep 27, 2021 12:49 pm
Awaiting op, but a closer look at the resistor does seem to show it wrong.
Which would be a good catch :-)
I am colorblind -- the resistor has 4 bands and was provided directly by adafruit with the DS18B20 so they might have gotten it wrong...I could take a better picture, since it's a little hard for me to read the color codes.

duxliteratum
Posts: 10
Joined: Sun Sep 26, 2021 5:11 am

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Mon Sep 27, 2021 5:47 pm

pcmanbob wrote:
Mon Sep 27, 2021 7:07 am
I would suggest you start over,

Get rid of the ribbon cable and just hook one DS18B20 up directly to the gpio pins like this.

Image

Remove this line form config.txt

Code: Select all

dtoverlay=w1-gpio,pullup=1,gpiopin=22
make sure the 1-wire interface is enabled using " sudo raspi-config ", I would disable it reboot then re-enable it and reboot.

then run the following and see if your sensor is detected.

Code: Select all

cd /sys/bus/w1/devices

ls

cd 28-XXXXXXXXXXXX (change the X’s to your own address)

cat w1_slave
Thanks for the good suggestion, this is what I'm going to do -- try wiring directly to the pins on the Pi with the "default" pullup configuration wiring into the top 3.3v and with data into pin GPIO pin 4. I'll post results tonight hopefully, my day job takes up a lot of time -- dissertations don't typically write themselves.

I just tried rpi-updating to a kernel some guy in 2019 said worked for him and managed to corrupt the boot directory, so I'm starting with a fresh install of raspbian as well.

User avatar
bensimmo
Posts: 5456
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Mon Sep 27, 2021 7:49 pm

.. It keeps posting when it edit and I canny delete them...
Last edited by bensimmo on Mon Sep 27, 2021 7:55 pm, edited 1 time in total.

User avatar
bensimmo
Posts: 5456
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Mon Sep 27, 2021 7:53 pm

It looks yellow-purple*-brown-gold
Which is 4, 7, x10 and 5% tolerance.
That's 470 ohms
But if that brown (marked) is red then all is fine at 4700 ohms
Screenshot_20210927_204946.jpg
Screenshot_20210927_204946.jpg (39.52 KiB) Viewed 567 times
*actually hard to tell the colour, but it's not important.

User avatar
bensimmo
Posts: 5456
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Mon Sep 27, 2021 7:53 pm

.. It keeps posting when it edit and I canny delete them...

duxliteratum
Posts: 10
Joined: Sun Sep 26, 2021 5:11 am

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Tue Sep 28, 2021 6:48 am

Ok, so I got a fresh raspbian install, wired up to the "default":

Image

and used raspi-config to set 1-wire to "enabled" before rebooting and taking a look at /sys/bus/w1/devices which ONLY contained w1_bus_master1

After rebooting with 1-wire enabled, lsmod has

Code: Select all

w1_gpio 		16384  0
wire			36864 w1_gpio
I let everything sit for a while and then came back later and took a look in the same directory and found some of the random "nothing" addresses

00-200000000000
00-600000000000
00-a00000000000

definitely no directories starting with 28

FYI, the kernel is 5.10.60-v7+ #1449 and the pi is a Pi 3 A+.

I'm seriously scratching my head...have I completely misunderstood the pin ordering?

Oh, and I got a fresh resistor from my local store...4.7k ohm with 2% tolerance

I'm going to grab some alligator clips so I can clip the connections together without the breadboard, in case that somehow is the issue, though I doubt it...

Has anyone gotten this working with a recent kernel on a pi 3 A+?
Last edited by duxliteratum on Tue Sep 28, 2021 7:04 am, edited 2 times in total.

User avatar
rpdom
Posts: 19156
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Tue Sep 28, 2021 7:03 am

It could be that the wires to the sensor have been connected the wrong way when it was made. It has been known to happen.

First I would try pulling the sensor wires out of the breadboard and just leaving the resistor connected. In theory you should not see any entries in /sys/bus/w1/devices, especially no "00-" devices. That will mean the gpio is working correctly.

The next bit would be to guess the connections to the sensor. Good luck with that. I've been lucky with all the ones I've bought which have had the red, black and yellow wires connected correctly.

One thing to note when testing is if the sensor starts to get hot or even warm then the +3v3 and 0v connections are the wrong way round. The sensors seem to be able to survive that for a while, so just hold it in your hand when trying different connections and pull it out of the breadboard if it starts to get at all warm.
Unreadable squiggle

duxliteratum
Posts: 10
Joined: Sun Sep 26, 2021 5:11 am

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Tue Sep 28, 2021 7:07 am

rpdom wrote:
Tue Sep 28, 2021 7:03 am
It could be that the wires to the sensor have been connected the wrong way when it was made. It has been known to happen.

First I would try pulling the sensor wires out of the breadboard and just leaving the resistor connected. In theory you should not see any entries in /sys/bus/w1/devices, especially no "00-" devices. That will mean the gpio is working correctly.

The next bit would be to guess the connections to the sensor. Good luck with that. I've been lucky with all the ones I've bought which have had the red, black and yellow wires connected correctly.

One thing to note when testing is if the sensor starts to get hot or even warm then the +3v3 and 0v connections are the wrong way round. The sensors seem to be able to survive that for a while, so just hold it in your hand when trying different connections and pull it out of the breadboard if it starts to get at all warm.
I don't know if it confirms anything, but I just reversed the power and ground on one sensor and it heated up rapidly.

Perhaps I should get another brand new sensor to check that the sensors weren't all killed by my first potentially stupid configuration

duxliteratum
Posts: 10
Joined: Sun Sep 26, 2021 5:11 am

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Tue Sep 28, 2021 7:16 am

Woah, on a whim, I swapped through the 3 sensors I have...the one I was testing was apparently a dud, because I get readings from the other two!

Yahoo!

duxliteratum
Posts: 10
Joined: Sun Sep 26, 2021 5:11 am

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Tue Sep 28, 2021 7:20 am

Hmm, interesting, the first sensor that worked is giving me a good reading (around 25C which is the interior temp here) but when I add the second in series, It stays stuck at 85000, maybe it needs more voltage

Update: switching to the 5V header changes the reading on the 85000 sensor to 127937 and it feels a little warm to the touch, so maybe it's wired improperly?
Last edited by duxliteratum on Tue Sep 28, 2021 7:25 am, edited 1 time in total.

User avatar
rpdom
Posts: 19156
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Tue Sep 28, 2021 7:24 am

85.000°C is the standard "Something didn't work" reading from DS18B20s.

Sometimes I get an occasional reading like that. I've tweaked my software to ignore it and take another reading. If it persists it gives up and I will see there haven't been any good readings from that sensor.

Mostly I've had that reading when there have been loose connections on my wiring.
Unreadable squiggle

duxliteratum
Posts: 10
Joined: Sun Sep 26, 2021 5:11 am

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Tue Sep 28, 2021 7:34 am

rpdom wrote:
Tue Sep 28, 2021 7:24 am
85.000°C is the standard "Something didn't work" reading from DS18B20s.

Sometimes I get an occasional reading like that. I've tweaked my software to ignore it and take another reading. If it persists it gives up and I will see there haven't been any good readings from that sensor.

Mostly I've had that reading when there have been loose connections on my wiring.
It may be that I ruined this one as well or maybe they both came as duds -- it seems that on its own, the 85000 sensor doesn't produce a reading at all, it needs something about the working sensor to actually produce a reading...

So that's 1 working sensor out of 3...so the question is how many more sensors should I order from adafruit (or a better source?) to achieve a reasonable expectation of 3 total working sensors?

pcmanbob
Posts: 11798
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Tue Sep 28, 2021 7:40 am

While its ok to power the DS18B20 from 5V you must use the 3.3V for the pull up on the data pin via the 4.7K resistor , if you use 5V as the pull up you will end up damaging your pi.

Image

I would test each DS18B20 on its own , only once you know that they work reliably you can connect them in parallel.

Image

The water proof sensor are know to be a problem , it think its because there are so many fakes / factory rejects they seem to be getting it to lots of supply lines.

What I did was buy some DS18B20 in TO-92 packages, that's just the sensor with three legs , then I ran them on a test bench set-up for about 2 weeks to prove they were good, then I removed the sensors from the waterproof versions and reused the wiring / hardware rebuilding them with the tested sensors using new heat sink compound , hot glue and heat shrink sleeving.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

cleverca22
Posts: 4723
Joined: Sat Aug 18, 2012 2:33 pm

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Tue Sep 28, 2021 7:46 am

duxliteratum wrote:
Tue Sep 28, 2021 7:20 am
Update: switching to the 5V header changes the reading on the 85000 sensor to 127937 and it feels a little warm to the touch, so maybe it's wired improperly?
i cant find the original msg, but i have seen reports before of the waterproof sensors having the color coding of the wires all over the place

the report i saw, said that the sensor got very hot when wired backwards, but once the wiring was corrected, it just worked


it may help to measure a known-good sensor with a multimeter in diode mode, to try and see what each pin should look like, and then compare to the unknown sensors

User avatar
rpdom
Posts: 19156
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Troubleshooting DS18B20 sensor on Raspberry 3 A+ with Buster Lite

Tue Sep 28, 2021 7:49 am

pcmanbob wrote:
Tue Sep 28, 2021 7:40 am
The water proof sensor are know to be a problem , it think its because there are so many fakes / factory rejects they seem to be getting it to lots of supply lines.
I heard that a lot of the fakes have identical serial numbers. That's fine until you have more than one sensor connected.

The waterproof ones I've got are probably fakes. They do all have different serial numbers, but they all read different temperatures (within a couple of degrees Celcius), wheras the various i2c sensors I'm now starting to use instead are much more accurate and read to within about 0.025°C of each other when in the same location. (I've tried SHT20, BME280, BMP280, AHT10 so far).
Unreadable squiggle

Return to “Troubleshooting”