Skip to main content

Raspberry PI Zero W and DS18B20

 I use Raspberry PI 3 (Model B Plus Rev 1.3) to monitor temperature with DS18B20 around the house for few years now. Configuration is simple: I use multiple DS18B20 sensors (currently it is 7) that are connected in parallel with one 4.7kohm pullup resistor between Vdd  (3.3v) and DQ (Data) connectors.


 I don't use "parasite power" mode. In my experience 3 wires connection is more reliable. I'm not going to walk you through all setup. There are multiple different manuals in internet and most of them are very detailed. 

Couple of days ago I decided to replace Raspberry PI 3 with Raspberry PI Zero W. Raspberry PI Zero W has lower power consumption so I can use regular prone charger instead of special Raspberry PI power supply that provides 2.5A output. Currently I'm using  Samsung Charger that produces 1A.

My first thought was "There is no difference between Pi 3 and Zero from configuration perspective. What can be easier, I did it multiple times". 

But when I put together the test rig on breadboard PI Zero surprised my with unexpected behavior. Usually after enabling one wire interface in the config (using raspi-config) or adding dtoverlay=w1-gpio into /boot/config.txt and rebooting DS18B20 device showed up in /sys/bus/w1/devices/ as 28-xxxxxxxxxxxx. However, this time Raspbian showed something new. instead of usual devices I found something like 00-40000000000. 

I connected the test rig to RPI3 - it was working fine and showing the proper device. So, test rig was OK. Than I thought that my Raspbian install was broken, so I pulled SD card from RPI 3 and inserted it to RPI Zero W. No luck, working system from RPI3 that was working fine, shoed me same  00-40000000000 numbers on RPI Zero W. I bounced back to SD card that originally was in RPI Zero W and did a system update. No luck. 

At this moment I was stuck with configuration that is working on RPI 3, but not on RPI Zero W. After extensive googling I found few forums where people having same issues, but no solution.

I decided to blame GPIO pin on RPI Zero W, I assumed it is dead, so I added gpiopin="17" after dtoverlay=w1-gpio in /boot/config.txt to changethe GPIO 4 pin (that is default) to GPIO 17.


And after reboot magic happened. I found a proper device in /sys/bus/w1/devices/ 


When I checked the  w1_slave file I found the value I expected. t=22875 that is 22.875 C°

 Currently it is running on my desk for more than 12 hours and results are stable. 



Next step is to replace RPI 3 with RPI Zero W in production :) . I will post the update.

Hope this article will help someone. 

Update: Feb 7, 2021.
Good news and bad news. 
RPI Zero W works with DS18B20 without issue if GPIO changed from default 4 to another one, in my case it was GPIO 17. 
But......   As I mentioned above, currently I use 7 sensors to measure temperature in different locations of my house. So, 3 of these 7 sensors reside outside of the living area - attic, garage and external. These 3 are connected over cable that is 10+ meters long. It is working with RPI 3, but RPI Zero W showed proper output only on the sensors that are in close proximity. 

For now I hot back to old way, RPI 3. It is pretty cold outside so I will probably leave it for now.






Comments

Popular posts from this blog

Backyard utility shed part 1 (preparation and base)

Since my family and I moved outside of the city one of my dreams was to build the shed.  I never did that big construction project and this is what I was eager to try. In addition building the shed will create additional space in garage that has to be decluttered. Main idea was to build the shed big enough to put in riding mower and garden cart. Also it creates good place to store bicycles and other summer staff during the winter.   First I had to decide on the size. In RM (rural municipality) I live, permit is required for objects bigger than 120 sq.ft. Since I wanted to avoid any headaches with permits and inspections my choice was to go below the limit. Next step I had to compare 3 options:      1.  Ready to go plastic shed     2.  Wooden shed kit     3.  DIY wooden shed. Option 1 did not work for 3 reasons      1. B iggest shed I found is 10ft x 8ft (that is 40 sq.ft less than I need) and cost was about ...