reading temperature takes a long time
The 1 Wire Pi Plus and 1 Wire Pi Zero are a 1 Wire interface for the Raspberry Pi
7 days ago
Posted by:
opa-rudi
I am using the 1 Wire Pi Plus HAT with w1 subsystem. Reading the temperature file in /sys/bus/w1/devices/28-.../temperature takes about 5 seconds. Also writing the file for setting the resolution takes very long. So I guess it is an I2C issue. I am using RPI5 with Bookworm. Does anybody have an idea where the problem could be?
7 days ago
Posted by:
andrew
Hi
I have just tried setting up a clean installation of bookworm on a Pi 5 to test with the w1 subsystem. On my setup reading from a temperature sensor takes approximately 1 second in 12-bit mode and less than a second in 9-bit mode so I don't think it is an issue with the operating system or the w1 subsystem.
Do you have any other devices connected to the Raspberry Pi on the I2C bus that may be holding the bus open or any processes running in Linux that could be slowing it down?
If you have a spare SD card available it may be worth setting up a clean installation of Raspberry Pi OS to test with. That will let you know if the issue is hardware or software related.
If the problem persists on the new Raspberry Pi OS installation it could be a communication issue between the 1 Wire Pi Plus and the sensor. Try checking your wiring to make sure there are no bad connections and check that the wire does not run across any high voltage cables that could induce interference on the 1-Wire bus. Analog.com have a good article on creating reliable 1-Wire networks.
I have just tried setting up a clean installation of bookworm on a Pi 5 to test with the w1 subsystem. On my setup reading from a temperature sensor takes approximately 1 second in 12-bit mode and less than a second in 9-bit mode so I don't think it is an issue with the operating system or the w1 subsystem.
Do you have any other devices connected to the Raspberry Pi on the I2C bus that may be holding the bus open or any processes running in Linux that could be slowing it down?
If you have a spare SD card available it may be worth setting up a clean installation of Raspberry Pi OS to test with. That will let you know if the issue is hardware or software related.
If the problem persists on the new Raspberry Pi OS installation it could be a communication issue between the 1 Wire Pi Plus and the sensor. Try checking your wiring to make sure there are no bad connections and check that the wire does not run across any high voltage cables that could induce interference on the 1-Wire bus. Analog.com have a good article on creating reliable 1-Wire networks.
7 days ago
Posted by:
opa-rudi
6 days ago
Posted by:
opa-rudi
Ok, I think I found the issue. Normal reading takes approx. 0.8 seconds for one single sensor. (I had parallel readings done by a websocket server, that caused the latency). Because I have 10 sensors connected to the bus I have to read sequential 10 times over I2C, so a complete cycle will take about 8 seconds. That´s because of I2C/1Wire slowness and also because it couldn´t be read simultaniously, right?
6 days ago
Posted by:
andrew
1-Wire and I2C only support sequential transfers so reading 10 sensors will take 10 times longer than reading one sensor. That would explain why it is taking several seconds to read from all of your sensors.
Unfortunately there is no easy way to reduce the time it takes to read from all of the sensors other than reducing the resolution of the temperature sensors to 9 bit mode.
Unfortunately there is no easy way to reduce the time it takes to read from all of the sensors other than reducing the resolution of the temperature sensors to 9 bit mode.
5 days ago
Posted by:
opa-rudi
Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view.
Download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.