raspberrypi / firmware

This repository contains pre-compiled binaries of the current Raspberry Pi kernel and modules, userspace libraries, and bootloader/GPU firmware.
5.11k stars 1.68k forks source link

1-Wire in Parasite Power configuration (1-Wire using 2 wires) does not work (again) #1796

Open iz8mbw opened 1 year ago

iz8mbw commented 1 year ago

Hello. It seems 1-Wire in Parasite Power doesn't work again, reports always 85 degrees.

Some info for you:

root@rpi3:~# uname -a
Linux rpi3 6.1.19-v8+ #1637 SMP PREEMPT Tue Mar 14 11:11:47 GMT 2023 aarch64 GNU/Linux
root@rpi3:~# cat /etc/debian_version
11.6
root@rpi3:~# dtoverlay -l
No overlays loaded
root@rpi3:~#
root@rpi3:~# dmesg | grep -i wire
[    9.279917] Driver for 1-wire Dallas network protocol.
[    9.287128] gpio-4 (onewire@4): enforced open drain please flag it properly in DT/ACPI DSDT/board file
[    9.317419] w1_master_driver w1_bus_master1: Attaching one wire slave 3b.00000014fe14 crc 17
root@rpi3:~# cat /boot/config.txt | grep w1-gpio
dtoverlay=w1-gpio,gpiopin=4,pullup=on

As you can see w1 reports 85 degrees:

root@rpi3:/sys/devices/w1_bus_master1/3b-00000014fe14# cat w1_slave
50 05 ff ff f0 ff ff ff 5c : crc=5c YES
50 05 ff ff f0 ff ff ff 5c t=85000
iz8mbw commented 1 year ago

@popcornmix @pelwell

iz8mbw commented 1 year ago

Just made a test: I changed from 3V3 to 5V the power supply to pin GPIO4 and now 1-Wire works (always using a 4.7khom resistor between GPIO4 and power supply). Well, why now 3V3 is not more enough? Sensors are more precise at 3V3 respect to 5V.

(the cable that connect the 1Wire sensor to Raspberry Pi is only 10 cm long)

dp111 commented 1 year ago

I suspect the issue is the host isn't driving the bus high to charge the capacitor at the correct time. This may have worked in the past by luck or the timing just being slightly different.

See https://www.analog.com/media/en/technical-documentation/data-sheets/DS18S20-PAR.pdf Page 3.

On Tue, 21 Mar 2023 at 18:31, Fabio @.***> wrote:

Just made a test: I changed from 3V3 to 5V the power supply to pin GPIO4 and now 1-Wire works (always using a 4.7khom resistor). Well, why now 3V3 is not more enough?

— Reply to this email directly, view it on GitHub https://github.com/raspberrypi/firmware/issues/1796#issuecomment-1478398672, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFIUOSAT3ZHP34FISY33W5HXYLANCNFSM6AAAAAAWCZ2RGY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

iz8mbw commented 1 year ago

I don't know if this can the be the motivation. With 3.3 V I'm unable to read sensor temperature but as I wrote the 1-Wire bus can see the chip, can see the serial number and can see the chip resolution but when I interrogate it for temperature it answer with 85000 (85 °C). I'll try to change the resistor from 4.7 kohm to 3.9 kohm and switch back from 5 V to 3.3 V.

dp111 commented 1 year ago

Did you see the bit in the link which says the temperature conversion takes extra current and so needs a stronger pull so they recommend that the host drives the bus high to provide the power?

On Wed, 22 Mar 2023, 08:05 Fabio, @.***> wrote:

I don't know if this can the be the motivation. With 3.3 V I'm unable to read sensor temperature but as I wrote the 1-Wire bus can see the chip, can see the serial number and can see the chip resolution but when I interrogate it for temperature it answer with 85000 (85 °C). I'll try to change the resistor from 4.7 kohm to 3.9 kohm and switch back from 5 V to 3.3 V.

— Reply to this email directly, view it on GitHub https://github.com/raspberrypi/firmware/issues/1796#issuecomment-1479071600, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFIX4R4EPRYXLUFZTIBTW5KXFVANCNFSM6AAAAAAWCZ2RGY . You are receiving this because you commented.Message ID: @.***>

pelwell commented 1 year ago

That's what the w1_gpio driver attempts to do, by forcing the pin to be an output driven high for a while.

dp111 commented 1 year ago

That's good. It might be worth checking the timing is correct.

On Wed, 22 Mar 2023 at 13:13, Phil Elwell @.***> wrote:

That's what the w1_gpio driver attempts to do, by forcing the pin to be an output driven high for a while.

— Reply to this email directly, view it on GitHub https://github.com/raspberrypi/firmware/issues/1796#issuecomment-1479547494, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFIXK2JAXIBXPPFE5R43W5L3G3ANCNFSM6AAAAAAWCZ2RGY . You are receiving this because you commented.Message ID: @.***>

iz8mbw commented 1 year ago

If you need test on new kernel/firmware I can do it.