-
-
Save eydam-prototyping/071e6044d80f4842317d84d89c4b5f5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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