import machine
import utime
# Define the ADC pin
adc = machine.ADC(28) # Pin GP28 (Analog Pin)
conversion_factor = 3.3 / (65535) # ADC conversion factor
while True:
# Read analog value from NTC sensor
reading = adc.read_u16()
voltage = reading * conversion_factor
# Convert voltage to resistance using NTC curve equation
# You need to replace the coefficients with your specific NTC curve data
resistance = 10000 / ((3.3 / voltage) - 1)
# Convert resistance to temperature using Steinhart-Hart equation
# You need to replace the coefficients with your specific NTC curve data
A = 0.001129148
B = 0.000234125
C = 0.0000000876741
steinhart = resistance / 10000
steinhart = 'math.log'("steinhart")
steinhart /= A
steinhart += B
steinhart += C
steinhart = 1.0 / steinhart
steinhart -= 273.15 # Convert Kelvin to Celsius
# Print temperature
print("Temperature:", steinhart, "C")
# Delay between readings
utime.sleep(1)