Pico Explorer Base and Pico Temp sensor problem

Hi,
I am experimenting with Pico and the explorer base using Pimoroni Micropython in the latest version.
I have the follwing problem:
As soon as the picoexplorer.init(buf) command is executed in the program, the internal temp sensor of the Pico returns temperature values of around 89 degrees Celsius.
If I comment that line out and start the program again, the reading is immediately back to normal.
But then of course the display does not work.
So the init() seems to mess up the data from the internal sensor.

Has anyone experienced the same problem and found a solution?
Regards
Thomas

Not sure I know what is happening here, but could you please provide a bit more information? Which temperature sensor are you using, and what does the code up to that point look like?

You can post code in proper formatting by putting three backticks ( ` ) before and after it.

It will look like this

Hi Shoe,
I am using the internal temperature sensor of the Pico.
The code is this:


import utime
import machine
from breakout_bme68x import BreakoutBME68X, STATUS_HEATER_STABLE
from pimoroni_i2c import PimoroniI2C
import picoexplorer
#from adafruit_bitmap_font import bitmap_font


PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}

i2c = PimoroniI2C(**PINS_PICO_EXPLORER)
bme = BreakoutBME68X(i2c)

temp_sensor = machine.ADC(4)
cf=3.3/(65535)

# Initialise Picoexplorer with a bytearray display buffer
buf = bytearray(picoexplorer.get_width() * picoexplorer.get_height() * 2)
picoexplorer.init(buf)

But also this minimalistic program has the same result:

import picoexplorer

temp_sensor = machine.ADC(4)
cf=3.3/(65535)

# Initialise Picoexplorer with a bytearray display buffer
buf = bytearray(picoexplorer.get_width() * picoexplorer.get_height() * 2)

sensor = temp_sensor.read_u16()*cf        # Pico internal tempsensor
temp_pico = 27-(sensor-0.706)/0.001721
int_temp = "Int Temp: {:4.1f}C".format(temp_pico)
print(int_temp)

picoexplorer.init(buf)

sensor = temp_sensor.read_u16()*cf        # Pico internal tempsensor
temp_pico = 27-(sensor-0.706)/0.001721
int_temp = "Int Temp: {:4.1f}C".format(temp_pico)
print(int_temp)

Where the output is

>>> %Run -c $EDITOR_CONTENT
Int Temp: 32.7C
Int Temp: 89.8C

Doing the Explorer init before setting up the temp sensor seems to make the readings behave for me?

import picoexplorer

# Initialise Picoexplorer with a bytearray display buffer
buf = bytearray(picoexplorer.get_width() * picoexplorer.get_height() * 2)
picoexplorer.init(buf)

temp_sensor = machine.ADC(4)
cf=3.3/(65535)

sensor = temp_sensor.read_u16()*cf        # Pico internal tempsensor
temp_pico = 27-(sensor-0.706)/0.001721
int_temp = "Int Temp: {:4.1f}C".format(temp_pico)
print(int_temp)

Hello Hel!
Thanks, that helped me as well, I now get the correct values!

But why does the initialisation of the explorer library influence the reading of internal values of the Pico unrelated to the explorer base?
In my opinion that should not happen.

Best Regards
Thomas

Glad that helped but not sure why that fixes it I’m afraid, probably a bug? You could open a Github issue so our software folks can take a look?

Looks like the explorer init function does some intialisation on some of the ADC channels, and I’m guessing it trips up the temp ADC channel.

On this rare occasion I actually possess the relevant hardware so if you do open a Github issue, I might be able to come up with a PR for it :)

1 Like