Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
MicroPython Temperature Sensor for the NodeMCU ESP8266.
from machine import ADC
adc = ADC(0) # assign to the analog to digital 0 pin # returns TMP 36 value
def temp(value):
return value/10
def fahrenheit(celsius):
return (celsius * (9/5)) + 32
reading =
celsius_temp = temp(reading)
fahrenheit_temp = fahrenheit(celsius_temp)
print("TMP36 reading {}\nDegrees Celsius{}\nDegrees Fahrenheit {}".format(
reading, celsius_temp, fahrenheit_temp))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment