Open pabloandresm opened 3 years ago
ok, point taken...
You probably can check the serial number with
hexdump -v -e '7/1 "%02x-" 1/1 "%02x" "\n"' /sys/devices/w1_bus_master1/<family-id>/id
For the Raspberry Pi Pico, you can use the following CircuitPython script:
import board
from adafruit_onewire.bus import OneWireBus
ow_bus = OneWireBus(board.GP16)
print('-'.join(["%02x" % i for i in devices[0].rom]))
And this in MicroPython for the Raspberry Pi Pico/RP2040, assuming pin 16 as above:
# print hex IDs of all ds18x20 sensors found on a pin
from machine import Pin
from onewire import OneWire
from ds18x20 import DS18X20
ds = DS18X20(OneWire(Pin(16)))
for i, sensor in enumerate(ds.scan()):
print(i, ":", '-'.join(["%02x" % j for j in sensor]))
Other implementations might use something like Pin('PE0')
to define a pin.
I've copied a Python code fragment in issue https://github.com/cpetrich/counterfeit_DS18B20/issues/20#issuecomment-2005291905 That could be used as a basis for porting the arduino code to Python.
Very nice investigation and code.
It is a shame that there is no C or Python code for Raspberry Pi. If yould be a very nice too have.
thanks