import machine
import time
ad_pin = machine.ADC(4)
#TODO: Write a function to convert the value to voltage
def calculate_voltage(ad):
voltage = (((pow(2,16)-1)*ad)//3.3)
return voltage
#TODO: Write a function to convert the voltage to temperature
def calculate_temperature(voltage):
temp = (27-((voltage-0.706)//1.721))
return temp
while True:
#Reading the 16-bit AD value
ad = ad_pin.read_u16()
volatege = calculate_voltage()
temp = calculate_temperature(voltage)
print("Temperature",temp)
time.sleep(2)