Hi,
I have a Arduino Nano RP2040 Connect utlising a 10K thermistor & 10K resistor. Its input is on A0. The MicroPython code I'm using continously displays 24C (varying only +/- 0.02C) in Thonny's serial monitor. It does this even when I completely disconnect the thermistor.
(As a test, I'm able to get good temperature readings with an Arduino sketch on an identical ciruit on another Nano RP2040.)
My programmer is conversant in Python, but new to MicroPython, and microcontrollers.
We're a bit baffled. Any suggestions of what's wrong?
TIA
The code is:
from machine import ADC, Pin
import math
import time
adc = ADC(Pin(26)) # create ADC object on ADC pin
RT0 = 10000
B = 3950
VCC = 3.3
R = 10000
T0 = 25 + 273.15
while True:
# read value, 0-65535 across voltage range 0.0v - 3.3v. equivalent to - VRT = analogRead(A0)
VRT = adc.read_u16()
VRT = (3.3 / 1023.00) * VRT # Conversion to voltage
VR = VCC - VRT
RT = VRT / (VR / R) * -1
ln = math.log(RT / RT0)
TX = (1 / ((ln / B) + (1 / T0))) # Temperature from thermistor
TX = TX - 273.15 # Conversion to Celsius
print("Temperature: ", TX)
time.sleep_ms(500) # sleep for 500 milliseconds
Circuit:
Correction to circuit - its a 1/4 watt resistor. Not 1.4 watt.