BBC Micro Bit and TMP36


I’ve been playing around with my BBC Micro Bit and a TMP36 temp sensor. The micro python code I’ve been finding is

tmp = pin1.read_analog()
temp = ((tmp * (3300.0/1024.0))-500.0)/10.0

For a 3.3 micro controller you use, mV=(input)*(3300/1024)
And for a 5V Micro controller you use mV = (input) * (5000/1024)
I’m thinking for the Micro Bit it should be mV = (input) * (3000/1024) , as it uses 3V not 3.3V?
+3V is what is feeding the TMP36. Using 3000 instead of 3300 gives me more accurate readings. Using 3300 gives me way high readings.
And just a heads up for anybody else trying this. Doing it while running on battery is a waist of time, IMHO. As the battery voltage drops, your temp reading goes up and reads higher than what it should. Running while powered through the USB port gets consistent readings. Your voltage to the TMP36 is via a 3V regulator on the Micro Bit.