Great to hear you have everything working now. And many thanks for letting us know, and what the solution is.my now working code ...
Interesting. I thought ADC pins not being configured correctly was something which had been resolved with recent software, and I'm surprised the old firmware did that correctly while the new doesn't, which seems to be the case if worked on 1.20 but not 1.22 without this initialisation to turn pull-resistors off.modified code:
>>>
p27 = Pin(27, Pin.IN)
p28 = Pin(28, Pin.IN)
thermistor28 = machine.ADC(p28)
thermistor27 = machine.ADC(p27)
Now, both firmware versions adc functions work equally for my sensors.
Or maybe the issue rests on whether a pin or pin number is used rather than an ADC channel number. I'll have to take a look at what the following do, which are all equivalents, should IMO do the same -
Code:
p = machine.ADC(1)p = machine.ADC(27)p = machine.ADC(Pin(27))p = machine.ADC(Pin(27, Pin.IN))
That doesn't look great to me, seems to be something of a nasty hack, and I am surprised you aren't having to use the same hack for both thermistors.Fah28 = Cel28 * 1.8 + 32 + 2.0
It would be worth testing across a range of temperatures to determine how well it holds up, how it varies against temperatures which aren't using that hack.
There likely will need to be differing 'fudge factors' for each pin, circuitry, and sensor, which may behave differently, but the proper solution would be to provide a calibrated means of determining temperatures rather than the 'recommended default' presuming a VREF of 3.3V and 't = (27 - (reading - 0.706)/0.001721)'' and equivalents for external temperature sensors.
Statistics: Posted by hippy — Wed Jan 24, 2024 4:04 pm