nickcornaglia

PicoTest-MicropythonTemperature

Jan 18th, 2022 (edited)
1,283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. import machine
  3. import time
  4.  
  5. sensor_temp = machine.ADC(4)
  6. conversion_factor = 3.3 / (65535)
  7. t = u"\u00b0"
  8.  
  9. while True:
  10.     reading = sensor_temp.read_u16() * conversion_factor
  11.     Ctemp = 27 - (reading - 0.706)/0.001721
  12.     Ftemp = (Ctemp*(9/5))+32
  13.     println(Ctemp + t + "C - " + Ftemp + t + "F")
  14.     time.sleep(2)
Add Comment
Please, Sign In to add comment