Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DS18B20 Temperature Sensor #175

Open
Airmonkdev opened this issue Apr 8, 2024 · 6 comments
Open

DS18B20 Temperature Sensor #175

Airmonkdev opened this issue Apr 8, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@Airmonkdev
Copy link

Hi,
is it possible to add the DS18B20 Temperature Sensor to the supported device?
I'd really appreciate.

Regards and keep up the great work,
Marco

@uli-rpi
Copy link

uli-rpi commented Apr 8, 2024

@Airmonkdev
Copy link
Author

Hi,
thanks for response! COuld you please help me understand better?
I'd like to have the possibility to connect a DS18B20 to my remote Raspberry and get a new exposed temperature device on my Homebridge like what can we do with DHT sensors.

@ebaauw
Copy link
Owner

ebaauw commented Apr 8, 2024

I think it should be possible, but the setup is somewhat elaborate. I don't have such sensor myself, but it seems it's exposed over 1-wire using a system file.

Can you confirm that you can get to work the Python example to read the DS18B20 from https://abyz.me.uk/rpi/pigpio/examples.html? Could you please list the contents of /sys/bus/w1/devices/28*/w1_slave?

@ebaauw ebaauw added the enhancement New feature or request label Apr 8, 2024
@Airmonkdev
Copy link
Author

Hi Ebaauw,
thanks for reply!
The output of the command "ls /sys/bus/w1/devices/28*/w1_slave" is:
/sys/bus/w1/devices/28-011581d14bff/w1_slave

I'm trying to run the Python example you point me but it seems it stuck while connecting to remote Rapy (pi = pigpio.pi()) with both env variable configured with the remote ip address and ip as parameter of pi() function.

Sound strange because I was able to create a contact sensor and it works fine, I can see my door opened and closed on my iPhone :)

@ebaauw
Copy link
Owner

ebaauw commented Apr 8, 2024

Make sure you run pidpiod with -l so it accepts remote connections. Unless you specify 127.0.0.1 explicitly, it somehow sees localhost as a remote connection as well, due to some weird IPv4/IPv6 address conversion. Check with pigs hwver that pigpiod is running and accessible from another host (using the PIGPIO_ADDR environment variable).

What's the contents of the file (cat /sys/bus/w1/devices/28*/w1_slave or, if it contains non-printable characters, od -c /sys/bus/w1/devices/28*/w1_slave

@Airmonkdev
Copy link
Author

Airmonkdev commented Apr 9, 2024

Hi, I found my issue and now I'm able to read the temperature with the python script:
the first issue I had was file access and I solved adding the line "/sys/bus/w1/devices/28-/w1_slave r" on file "/opt/pigpio/access" on my remote Raspy.
After that I also had to modify little bit the Pythion script because it was listing the wrong files so now it is fine with pi.file_list("/sys/bus/w1/devices/**28-
/**w1_slave").
Other than that I just had to add some .decode() on the data returned, here there is the working script:
DS18B20-1.zip
... the output of the script is this (every 3sec):
28-011581d14bff 21.1
28-011581d14bff 21.1
28-011581d14bff 21.1
....

And here there is the output of the command "cat /sys/bus/w1/devices/28*/w1_slave":
51 01 4b 46 7f ff 0c 10 ab : crc=ab YES
51 01 4b 46 7f ff 0c 10 ab t=21062

Thanks for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants