Enviro Weather (Pico W Onboard) Wind Direction readings incorrect

Getting ready to deploy Enviro Weather (Pico W Aboard) with weather station kit. Has been deployed for over 1 year outside using firmware: pimoroni-enviro-v1.20.4-micropython-enviro-v0.0.10.uf2 - without wind and rain sensor hardware attached.

Brought unit inside to attach wind and rain sensors. Worked well… but distance of test stand to wifi router much further than outside install spot so occasionally had wifi problems requiring reboots (which are unacceptable when deployed)

Installed the latest released firmware: pimoroni-enviro-v1.22.2-micropython-enviro-v0.2.0.uf2

System worked but wind direction indicator was all off. Though I might have a hardware problem so set up a breadboard break out for the rj11 cable. When I measured the voltages from the wind direction sensor… they are all fungu according to the wind_direction function in weather.py.

I went back to enviro-v1.20.4-micropython-enviro-v0.0.10.uf2 and after the board initialized, the voltages from the wind direction sensor were correct.

After further investigation, the sensor voltage readings of enviro-v1.20.4-micropython-enviro-v0.0.10.uf2 look similar to enviro-v1.22.2-micropython-enviro-v0.2.0.uf2 prior to enviro-v1.20.4-micropython-enviro-v0.0.10.uf2 initialization.

My conclusion is that enviro-v1.22.2-micropython-enviro-v0.2.0.uf2 is not initializing Analog(26) the wind_direction_pin correctly when the Enviro Weather starts up.

Tried to trace the code back between the 2 releases but could not find anything obvious. Did search of this forum and the forums on Github and did not see any reports of this issue.

Looking for suggestions to fix, or will have to return to enviro-v1.20.4-micropython-enviro-v0.0.10.uf2 and implement some remote power cycling mechanism to reboot the board when it hangs if I cannot find a solution for enviro-v1.22.2-micropython-enviro-v0.2.0.uf2.

Fun and games with loading code narrowed the problem down. I used the following MicroPython code with out running other applications code to compare voltage readings.

Test 1
from pimoroni import Analog
wind_direction_pin = Analog(26)
print (wind_direction_pin.read_voltage()

Test 2
from machine import ADC
wind_direction_pin = ADC(26)
print (wind_direction_pin.read_u16())

Voltages were measured on the Enviro Weather Board at GP26/ADC0 J1 Connector B2-Wind Vane with the originally supplied Weather Station Kit.

With Pimoroni Enviro Firmware V0.1.0 the bug does not exist.

With Pimoroni Enviro Firmware V0.2.0, the bug does exist. ADC0 (GP26) does not read the correct voltages as specified in Enviro Board code for Enviro Weather (Pico W Aboard).

I tested standard MicroPython builds for the Pico 1 W and came up with the following:

For code builds RPI_PICO_W-20231005-v1.21.0.uf2 and prior, the bug does not exist.

For code builds RPI_PICO_W-20231227-v1.22.0.uf2 thru RPI_PICO_W-20240602-v1.23.0.uf2, the bug exists.

For code builds RPI_PICO_W-20241025-v1.24.0.uf2 and above, the bug does not exist (was it fixed or are their other dependencies that were removed?)

Bottom line… the bug seems not to be the result of Pimoroni code, but native to specific MicroPython builds; in particular V1.22 and V1.23.

I could not find any bug reports with the RPI_Pico_W code builds on this issue, so it’s impossible to understand how the bug occurred and how the bug was fixed in V1.24 and above.

The only workarounds I can see other than using Pimoroni Enviro V.0.1.0, is doing a custom code build,(detecting the Micropython version and changing the voltage readings to be detected in the code enviro.boards.weather.py) or for Pimoroni to release a new build with a later release of MicroPython.