-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
19 lines (14 loc) · 718 Bytes
/
main.py
File metadata and controls
19 lines (14 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# PiicoDev TMP117 minimal example code
# This program reads the temperature from the PiicoDev TMP117 precision temperature sensor
# and displays the result in Degrees Celsius, Farenheit and Kelvin
from PiicoDev_TMP117 import PiicoDev_TMP117
from PiicoDev_Unified import sleep_ms # cross-platform compatible sleep function
tempSensor = PiicoDev_TMP117() # initialise the sensor
while True:
# Read and print the temperature in various units
tempC = tempSensor.readTempC() # Celsius
tempF = tempSensor.readTempF() # Farenheit
tempK = tempSensor.readTempK() # Kelvin
# Convert temperature into a string and print the data
print(str(tempC) + " °C")
sleep_ms(1000) # delay 1 second