Skip to content

Instantly share code, notes, and snippets.

@eydam-prototyping

eydam-prototyping/REPL Secret

Created Feb 16, 2021
Embed
What would you like to do?
>>> import onewire
>>> import ds18x20
>>> import machine
>>> ow = onewire.OneWire(machine.Pin(4)) # Bus initialisieren auf GPIO4
>>> ds = ds18x20.DS18X20(ow)
>>> roms = ds.scan() # nach angeschlossenen Slaves suchen
>>> roms
[bytearray(b'(!a\x85\x13\x19\x01\xb5')] # Liste mit Slaves, hier nur einer
>>> import ubinascii
>>> ubinascii.hexlify(roms[0]) # die Seriennummer lesbar
b'28216185131901b5'
>>> ds.convert_temp() # allen angeschlossenen Slaves den Befehl zum messen geben
>>> ds.read_temp(roms[0]) # Temperatur auslesen
22.625
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment