question

Marcel avatar image
Marcel asked

Strange behavior 1Wire tem. sensor DS18B20 on Venus 2.82 large 30

Hello all.


I observed a strange behavior regarding my DS18B20 1Wire temperature sensor after installing this on a raspberry pi 3B+ with Venus OS 2.82 large 30 as operating system.


After a reboot or shutdown both the 1Wire, and rpi CPU temperature sensor value “flicker” on the screen of the device list. I you look closely during the "flickering" you can see that they both measure a temperature value and then they are disconnected again. This goes on for 30 seconds or so, both sensors are not connected then according to the device list. See the attached video for details. VID_20220329_130316.mp4
For the rest everything is working just fine. Just no temperature readings from the CPU and/or 1Wire sensor.


The solution for this up till now is to reboot the system. Sometimes this works in one go, but most off the time I have to reboot 4 or 5 times. Then it works again as intended. Once working it keeps working. No problem there.


Another thing: if there is no DS18B20 connected to the system then there is no rpi CPU temperature either in the device list.


My questions:

Do other people have witnessed this strange behavior regarding “flickering” temperature values in the device list also? And also no CPU temperature when there is no DS18B20 connected.

What can or should I do to fix (both?) problems? What to check or what to look for? Already checked the sensor itself and replaced it for a other one. Same problem/behavior. All wiring is ok. not to long and I used shielded twisted pair cable. Used a 4.7K resistor over VCC 3.3 volt and the data line. Will a smaller resistor value be a solution maybe?


Again: if its working then it keeps working. I just don't know where to look for the problem. Any advice, pointers or hints are welcome!


Thanks in advance!


Marcel

Help
2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

johnny-brusevold avatar image johnny-brusevold commented ·

@Marcel

First try replacing the overlay file w1-gpio.dtbo compiled for your kernel version

https://github.com/raspberrypi/firmware/blob/oldstable/boot/overlays/w1-gpio.dtbo


If that does not help, try changing the resolution of the sensor

9 bit: 0.5 ° c

10 bit: 0.25 ° c

11 bit: 0.125 ° c

12 bit: 0.0625 ° c


to read the resolution

cd /sys/bus/w1/devices/
cat 28-*/resolution


to set resolution to 11 bit (sets all sensors connected at the same time)

cd /sys/bus/w1/devices/
for dir in 28-*; do echo 11 > "$dir"/resolution; echo "$dir"; done


shutdown -h now

disconnect the power for a few seconds

0 Likes 0 ·
Marcel avatar image Marcel johnny-brusevold commented ·

@Johnny Brusevold


Hello Johnny. So we meet again :-) Still very grateful for all your help. Hope you can help me out with this one also.

Tried your suggestion regarding changing the overlay file: gpio.dtbo. After replacing it with the old one I did a reboot. No succes. Still the same behavior.

When I tried to do your next suggestion:

  1. cd /sys/bus/w1/devices/
  2. cat 28-*/resolution

to change the resolution of the sensor I get this:

screenshot-from-2022-03-29-18-49-40.png

So...it seems I don't have such file or directory. So I could not even try to change it. Any suggestions?

0 Likes 0 ·
5 Answers
johnny-brusevold avatar image
johnny-brusevold answered ·

@Marcel

You will probably need to restart a few times to get the temperature reading in the remote console before you can possibly lower the resolution of the sensor.

double check the connections and resistor

I had the same problem a while ago, but can not remember which version of venus-os I had installed.

The only difference I see here is that I use a native compiled kernel instead of the original kernel in venus-os

Maybe you've been unlucky and got a faulty sensor


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Marcel avatar image
Marcel answered ·

@Johnny Brusevold

Thanks for your quick reply. I will check all wire connections again. also change the sensor again. Already did that by the way but will test it again on another raspberry. I'v got 6 DS18B20 sensors running on that one without a problem.

I did read somewhere that longer cables are more sensitive to interference. So I will hookup that same sensor straight to RPI. Just to see if the problem goes away. Because I don't think the sensor itself is a problem. Always worked well and once detected in the device list it was running without a problem the whole day.

If that does not work then I will lower the value of the resistor a bit, I think you can safely go to 2K ohm.

If I find something I will report back. Thanks again for you suggestions and help

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Marcel avatar image Marcel commented ·

Update.


For all the people who are Noops like me: check your path to temperature measurement in dbus-i2c.py

I don't know how but somehow the path changed from hwmon1 to hwmon0. Probably did it myself when I was trying to find out what was wrong. After changing it to the correct path everything worked like it should. I do have a temperature measurement from rpi CPU and also from the 1Wire temperature sensor. No flickering or "not connected" messages. Not after reboot or complete shutdown.

So do: nano /opt/victronenergy/dbus-i2c

Check the part in red:

# update W1 temp

def update_W1():

fd = open('/sys/bus/w1/devices/28-01192111f640/hwmon/hwmon0/temp1_input','r')

value = float(fd.read())

value = round(value / 1000.0, 1)

dbusservice['W1-temp']['/Temperature'] = value

fd.close


Make sure that your sensor ID is correct (28-01192111f640 is my sensor ID, yours is different) and also that the path to hwmon0 is indeed correct! Could be hwmon1 or hwmon2. Just check is this path exists. When not then change it into what you find in:

ls /sys/bus/w1/devices/28-************/hwmon/

Hope this helps anybody in the future that was just like me struggling with this.

Marcel.

0 Likes 0 ·
Marcel avatar image
Marcel answered ·

@Johnny Brusevold

Hi Johnny.

One last question. I got it all working now. Good and stable read-out on both rpi cpu temperature and that DS18B20 1Wire sensor.

I connected a other 1Wire sensor to the rpi. So now I have 2 sensors running. I need that second one for a hotwater tank.
The thing is that that other sensor does not show up in the device list. I added the following (in red) in the dbus-i2c.py file in /opt/victronenergy/dbus-i2c:

# update W1 temp

# DS18B20 sensor Utility room.

def update_W1():

fd = open('/sys/bus/w1/devices/28-01192111f640/hwmon/hwmon0/temp1_input','r')

value = float(fd.read())

value = round(value / 1000.0, 1)

dbusservice['W1-temp']['/Temperature'] = value

fd.close

# update W1 temp

# DS18B20 sensor Heatpump boiler tank.

def update_W1():

fd = open('/sys/bus/w1/devices/28-0119213b729d/hwmon/hwmon1/temp1_input','r')

value = float(fd.read())

value = round(value / 1000.0, 1)

dbusservice['W1-temp']['/Temperature'] = value

fd.close

Is there anything else that I should change? I put the correct Sensor ID in place and also checked the path.

So: fd = open('/sys/bus/w1/devices/28-0119213b729d/hwmon/hwmon1/temp1_input','r')
has the correct ID and hwmon1 is also correct. The second sensor is not showing up in the device list. I've got the feeling that I have to do something with that "W1-temp" part but I do not know what.

Or am I making a mistake and this is only working for one sensor?

Thanks again

Marcel.


4 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Marcel avatar image Marcel commented ·
Found it out myself. adapted a few things in that dbus-i2c.py file and now have multiple sensors. So its working. Learning every time!
0 Likes 0 ·
lemmens avatar image lemmens Marcel commented ·
@Marcel

Hi Marcel.

May I ask how you get multiple 1Wire sensors working?

0 Likes 0 ·
Marcel avatar image Marcel lemmens commented ·

Yes, you may. But remember that I'm not an expert!! I found out myself by a lot of reading and trying. So no guaranties!

Are you familiar with the command line (or Filezilla?) I have a Linux computer so cant explain it for Windows. Sorry.

But It should be the same. Instead of using filezilla use Winscp. Browse to this path on your RPI:

/opt/victronenergy/dbus-i2c

and open the file dbus_i2c. Just have a look what is different with my file. I did put some comments in yellow in it, so its pretty straight forward I think. Before you change your own file save it first so you have a back-up!

See the dbus-i2c file attached. Be aware: it's a .odt file so dont just copy it to your directory! Also this is my config for my sensors so it wont work on your system.

In short: just add some extra lines/entry's in your file below the ones that already exist. Don't forget to check if the path exist for hwmon. Could be hwmon0, 1 or 3 so check it. Again....see the comments in my file in yellow.

Somehow I cant attach the file. Will try it in another way.

0 Likes 0 ·
johnny-brusevold avatar image johnny-brusevold lemmens commented ·

@Lemmens

I'm not an expert either, but this works for me. Take a look at the file and you will probably find out how to do it. Tagged with 'added by me' 4 places. Possibly there are better ways to do it.

dbus-i2c.py

0 Likes 0 ·
Marcel avatar image
Marcel answered ·

@Lemmens

Just cant attache a file. Sorry. Get the error: something went wrong. Please try again.


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

benc-ipind avatar image
benc-ipind answered ·

I randomly experience the same issue on a reboot or power up after a shut down.

I have the RPi CPU temp and a single 1Wrie sensor.

I have two DIY VE.Direct USB cables plugged in as well.

I find I have to unplug the USB cables, let it boot, wait for the temps to report in and then plug the USB cables back in.

I don't have the hwmon path issue you described above.

I'm going to update to the latest VenusOS and install Rikkert's for that deploys the DBus service via Kwindrem's SetupHelper.

It auto discovers the 1Wire sensor and sets it up.

I'll still need to mod /u-boot/config.txt as my 1 Wire sensor is on GPIO 17 due to have an RTC module installed, which uses GPIO4.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources

Additional resources still need to be added for this topic