vitormhenrique / OctoPrint-Enclosure

OctoPrint Enclosure Plugin
GNU General Public License v3.0
396 stars 201 forks source link

Multiple DS18B20 working with OctoPrint-Enclosure - anyone got this working? #445

Closed LightningShark25 closed 2 years ago

LightningShark25 commented 2 years ago

Hi has anyone managed to get multiple DS18B20 working with Octopi/Octoprint? I got one sensor working correctly by adding the dtoverlay to the boot/config.txt

I want to use a second sensor connected to a different GPIO pin

The following page https://pinout.xyz/pinout/1_wire suggests this is possible atleast with raspberry PI.

dtoverlay w1-gpio gpiopin=4 pullup=0 # header pin 7 dtoverlay w1-gpio gpiopin=17 pullup=0 # header pin 11

This didn't work for me, neither sensor shows up after a reboot. Probably some syntax or something silly Anyone else succeeded?

pintail120 commented 2 years ago

yes I did this yesterday, walk in the park I used gpio pin 4 for both DS18B20 Did you populate the serial of the DS18B20 ?

need to add this below: sudo nano /boot/config.txt dtoverlay=w1-gpio,gpiopin=4

pi@octopi:~ $ dmesg | grep w1-gpio pi@octopi:~ $ sudo modprobe w1-gpio [I think this turns on the pullup R] pi@octopi:~ $ sudo modprobe w1-therm [I think this turns on the pullup R] pi@octopi:~ $ cd /sys/bus/w1/devices pi@octopi:/sys/bus/w1/devices ls 28-ba7a82116461 w1_bus_master1 [if you do not get the serial, then there are no coms to the DS18B20] Enter the above serial into enclosure plugin

nfored commented 2 years ago

Please be aware with Python 3 DS18b20 don't work.

This is what you will get

2021-10-29 12:09:15,377 - octoprint.plugins.enclosure - WARNING - An exception of type IndexError occurred on log_error. Arguments: ('list index out of range',) Traceback (most recent call last): File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/init.py", line 986, in get_sensor_data temp = self.read_18b20_temp(sensor['ds18b20_serial']) File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/init.py", line 1203, in read_18b20_temp lines = self.read_raw_18b20_temp(serial_number) File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/init.py", line 1218, in read_raw_18b20_temp device_folder = glob.glob(base_dir + str(serial_number) + '*')[0] IndexError: list index out of range 2021-10-29 12:09:15,379 - octoprint.plugins.enclosure - WARNING - An exception of type TypeError occurred on log_error. Arguments: ('cannot unpack non-iterable NoneType object',) Traceback (most recent call last): File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_enclosure/init.py", line 811, in check_enclosure_temp temp, hum = self.get_sensor_data(sensor) TypeError: cannot unpack non-iterable NoneType object

pintail120 commented 2 years ago

why does it not work on python3

LightningShark25 commented 2 years ago

@pintail120 so you used the same GPIO pin 4 for both sensors? I did all the other config you used - the difference was I was trying two different GPIO pins. I'll try putting them on the same GPIO pin4 - thanks!

When it fails I get something similar in my octoprint log to @nfored but I'm not on the upgraded python 3. I suspect those messages appear when the sensors are not available??

pintail120 commented 2 years ago

Yes same data pin for both. The DS18B20 has a unique serial number, it uses its data pin like a bus, therefore only the correct DS18B20 will respond when addressed. I have read somewhere that the DS18B20 will only work on gpio4, not sure how true that is but it was on one of the links I read.

This is my version of python: pi@octopi:~ $ pi@octopi:~ $ pi@octopi:~ $ python Python 2.7.16 (default, Oct 10 2019, 22:02:15) [GCC 8.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information.

PS please do not use my serial I indicated above, you need to find both the serial numbers of your ds18b20 and enter them into enclosure plugin.

nfored commented 2 years ago

I think only pin 4 is technically a 1 wire pin, much like only a single set of pins can do i2c.

LightningShark25 commented 2 years ago

If you check the link I included in the original post you will see that onewire on other pins is possible. I just didn't get it working properly Either way if it works properly on GPIO 4 then its an easy fix. Will report back when I get a chance..

vitormhenrique commented 2 years ago

using pin 4 is the way to go, with multiple on the same pin, only getting the serial number for each, have you tested it?

pintail120 commented 2 years ago

yes, it works perfectly two ds18b20 on pin 4 very happy

On Thu, 4 Nov 2021 at 14:25, Vitor de Miranda Henrique < @.***> wrote:

using pin 4 is the way to go, with multiple on the same pin, only getting the serial number for each, have you tested it?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vitormhenrique/OctoPrint-Enclosure/issues/445#issuecomment-961046312, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALPGJZ5U7N4ISNVRD6O5E23UKKJVPANCNFSM5G6LKDHA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

LightningShark25 commented 2 years ago

Can confirm 2 sensors on PIN 4 working no issues. Not quite what I was trying to do - but no fuss. Thanks guys