We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 03e4ae0 commit 6a2a095Copy full SHA for 6a2a095
examples/simpletest.py
@@ -0,0 +1,20 @@
1
+# Simple demo of printing the temperature from the first found DS18x20 sensor every second.
2
+# Author: Tony DiCola
3
+import time
4
+
5
+import board
6
7
+from adafruit_onewire.bus import OneWireBus
8
+from adafruit_ds18x20 import DS18X20
9
10
11
+# Initialize one-wire bus on board pin D5.
12
+ow_bus = OneWireBus(board.D5)
13
14
+# Scan for sensors and grab the first one found.
15
+ds18 = DS18X20(ow_bus, ow_bus.scan()[0])
16
17
+# Main loop to print the temperature every second.
18
+while True:
19
+ print('Temperature: {0:0.3f}C'.format(ds18.temperature)))
20
+ time.sleep(1.0)
0 commit comments