Pico W gives faulty sensor data with latest Micropython version #13488
-
(terminology wording corrected by edit) (2nd edit added # 1 and # 2 to identify different Pico W hardware, both purchased recently from supplier) On edit: below I apologized for using the word "faulty" in thread title. Correct title would have been "different" instead of "faulty." It was recommended to me that I leave it, since it already has been done..... I temporarily solved my problem, but any advice is welcome. I have a Pico W at a remote site that has worked perfectly for 8 months, 24/7. Two days ago (Jan 19, 2024) I needed to modify the program. Before downloading the modified code, I decided to upgrade to latest firmware, v1.22.1 (RPI_PICO_W-20240105-v1.22.1.uf2) I immediately had Thonny error problems of missing modules and had to reload modules such as network and urequests. Socket module also flagged. I am a stubborn soul and spent 10 hours trying to find my error. I even re-soldered some connections. I searched the internet until my fingers were sore. Two hours ago I got the brainstorm idea that maybe it was not my problem but was Micropython firmware version related. I loaded the older version, v1.20.0, firmware and put in the same program code. The Pico W worked flawlessly and the wifi was solid. As I said, my problem is solved, but perhaps my issue has broader implications. If I can help anyone with more info, let me know. Working firmware version: Non-working firmware version: my modules: Thonny lower left info: Thonny Used: Opie |
Beta Was this translation helpful? Give feedback.
Replies: 24 comments 56 replies
-
Your observations seems a little bit inconsistent. |
Beta Was this translation helpful? Give feedback.
-
Rob,
Thank you for the comments and question. No, I only use Thonny. Code works
fine with v1.20.0 Micropython firmware on Pico W 1 but not with v1.22.1 firmware on Pico W 1.
I will try to be more informative later this morning.
Opie
…On Sun, Jan 21, 2024 at 3:18 AM Robert Hammelrath ***@***.***> wrote:
Your observations seems a little bit inconsistent. network is a built-in
module of the firmware. You would usually not load it, it's simply there.
The urequests module is as well by default included into the firmware.
Also, there is no need to import both time and utime. utime is an alias
of time and is kept for legacy.
So it may be that the hiccups you see are caused by Thonny. Do you have
the same problems when not using Thonny?
—
Reply to this email directly, view it on GitHub
<#13488 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASEPKVA6IZEOWWBQZJ6CPD3YPTFOTAVCNFSM6AAAAABCDTGKISVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DCOJWGI2TE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Whoops. On edit, I deleted my previous post bc it had passwords. I'll try again.
|
Beta Was this translation helpful? Give feedback.
-
One comment about the way you connect to WiFi: The connect statement is required only once. Like # Configure Pico W as Station
sta_if=network.WLAN(network.STA_IF)
sta_if.active(True)
print('connecting to network...')
sta_if.connect(ssid, password)
for _ in range(10):
if sta_if.isconnected():
print('Connected.')
break
time.sleep(11) |
Beta Was this translation helpful? Give feedback.
-
Robert-hh I put the v1.20.0 firmware back in so you can see the ThingSpeak with correct temperature readings, verified with infrared and ice bath etc. You are welcome to edit link to make it url. My laptop seems to fail to use above shortcuts. And notice that this will continue, connected by wifi all day long, etc etc without disconnecting https://thingspeak.com/channels/2392138 |
Beta Was this translation helpful? Give feedback.
-
Please have WiFi working first, then look at the difference of measurement. The 3.3V of the Pico W will be slightly different whether WiFi is working or not. That will affect your temperature readings. About the ADC a note in the Pico Datasheet: |
Beta Was this translation helpful? Give feedback.
-
The WiFi connect code should have been different with the 4/2023 version as well. Calling |
Beta Was this translation helpful? Give feedback.
-
I have two spare Pico Ws. (On edit, I have labeled these 1 and 2) I will put firmware v1.20.0 in Pico W 1 and firmware version v1.22.1
version in Pico W 2 and then change code in both according to your
instructions, but maybe in a day or two.
Thanks again
…..,.,
…On Sun, Jan 21, 2024 at 11:15 AM Robert Hammelrath ***@***.***> wrote:
The WiFi connect code should have been different with the 4/2023 version
as well. Calling sta_if.connect() is a problem that showed up frequently.
Does WiFi work again with the firmware v1.22.1, when you pull
sta_if.connect() out of the waiting loop? It should. I use the same
structure myself and it follows the example in the documentation, e.g. here
https://docs.micropython.org/en/latest/esp32/quickref.html#wlan. That
example should better be in the generic WLAN section.
—
Reply to this email directly, view it on GitHub
<#13488 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASEPKVHS6LTJTYBUGIOG4C3YPU5KNAVCNFSM6AAAAABCDTGKISVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DCOJZGYYTC>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Aok. I’ll edit later tonight
…..,.,,
…On Sun, Jan 21, 2024 at 3:58 PM Jos Verlinde ***@***.***> wrote:
@opiedopy <https://github.com/opiedopy>
Please use the standard terminology for firmware and version
Working *firmware* version : *v1.20.0*
RPI_PICO_W-20230426-v1.20.0.uf2
Non-working *firmware* version *v1.22.1*:
RPI_PICO_W-20240105-v1.22.1.uf2
A bootloader is a different piece of software altogether bootloaders and
dates are confusing.
—
Reply to this email directly, view it on GitHub
<#13488 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASEPKVDOBSR6PJWY6HWASTDYPV6QHAVCNFSM6AAAAABCDTGKISVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DEMBRG43TI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
OK- I followed good suggestions and did evaluation and have the following conclusions. I have two Pico W's, side by side on my desk. (On edit, now labeled 1 and 2) Pico W 1 has working firmware v1.20,0 and Pico W 2 has Non-Working Firmware v1.22.1 First, the wifi works with both Pico W 1 with v1.20.0 and Pico W 2 with v1.22.1 firmware. That is good because my code is copied directly from the forum member, "hippy" over at the main Raspberry Pi main. Thanks, hippy. Reinstalling everything carefully and several reboots knocked it into working well with both firmwares on both Pico W's. It has been over three hours of continuous wifi connection on both Pico W's.. Second, my original thread title is confirmed. My sensors work under firmware v1.20.0 but do not work accurately with firmware v1.22.1. They read over 20 degrees too high with v1.22.1 And I believe it is fair to say that it is not a voltage reference issue that robert-hh asked about. I conclude that because not only are my thermistors inaccurate with v1.22.1, but also the internal Pico W board sensor readings are different as well. (On edit - ignore next statement. I believe that an infrared measurement of the internal board sensor may be impossible to be accurate, so ignore my conclusion, except to say the Pico W 1 and Pico W 2 internal sensor temps are not the same, but that may be caused by inherent differences in manufacture?) **** ignore ---- My infrared gun sensor measures 74 degrees internal board sensor with laser sighting on v1.20.0 and 74 with v1.22.1 but as the results show below, the v1.22.1 measures 10 degrees higher. ****Ignore The following data support my conclusions?: Data Item # 1
Anyone can view my public data for the non-working firmware v1.22.1 on Pico W 2 at v.20.0 result: Sensor values confirmed by test instruments
on edit: ---- |
Beta Was this translation helpful? Give feedback.
-
So it's good that WiFi works now for both firmware versions. It is however interesting that you get different ADC readings between the two firmware versions. In order to isolate the issue, I made a simple test set-up with applying an external Voltage to ADC0 and reading the result under varying conditions. The external voltage is 1.51V. I soldered a 10nF capacitor close to the ADC input to lower the reading impedance, and since the ADC readings were still noisy, the test code takes an average of 1000 samples taken within 10 seconds. The test runs were repeated several times to see fluctuations. Results:
Voltage at ADC_Vref: 3.29V under all conditions, when ADC is enabled.. The results are somewhat different. Using an NTC, a lower reading from the ADC result in higher temperature readings. I do not know the input voltage at your set-up, and the transfer ratio between input voltage variations to output value differences. Note that the ADC is quite noisy. Proper input filtering should be done. |
Beta Was this translation helpful? Give feedback.
-
Since I have the ability to evaluate data using ThingSpeak, I offer some screenshots that may further illustrate the different adc results for Pico W 1 ( the "1" is my designation to keep boards identified) with v1.20.0 version firmware At 730 est this morning I put plastic over both boards and also the spa sensor. Then I laid a package of frozen vegetables on both boards, 1 and 2, in order to cool them temporarily. ThingSpeak maintains all data for over a year. And charting is available. Here are results, again showing the faulty adc conclusion for Pico W 2 using firmware version v1.22.1 Results: Pico W 1 with working firmware v1.20.0 gave temperatures for spa sensor and internal temperature of 35 deg F and 54 deg F respectively. (Using infrared measurement, the 35 deg F was accurate.) Pico W 2 with non-working firmware v1.22.1 gave temperatures for spa sensor and internal temperature of 58 deg F and 62 deg F respectively. (Using infrared measurement the 58 deg F was 23 degrees too high.) I know of no way to independently measure the internal temperature of the board with an instrument, but v1.22.1 firmware shows internal temperature 8 degrees higher than V1.20.0 under similar circumstances. Does this add to the confusion? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Now for the version swap as you asked for ----- ".....with the existing sensor configuration, run v1.22.1 on Pico "1": " I installed on Pico W "1" what I thought was v1.22.1 but I was confused when I found these two files in my Downloads: RPI_PICO_W-20240105-v1.22.1.uf2 Hmmm. I know that the first one is the one I want, but I decided to try the second one first. Eureka! moment because using the second one caused me to be missing network, urequests and socket module packages. That must have been what happened when I included module issues in my thread way above before my module issues disappeared. Well, now I realize, that the module problems went away during my 10 hours of struggle only because I bumbled into loading the correct Pico W specific v1.22.1. I wonder how many folks may have made that same mistake? So, with the correct v1.22.1 firmware here are the results:
So, these readings are inaccurate...........with the test of v1.22.1 (W version) onto Pico W "1" |
Beta Was this translation helpful? Give feedback.
-
robert-hh, May I suggest that we eliminate the thermistor part of the issue? If you send me a simple voltage divider circuit design using a known, fixed resistor(s) ohm value, and send me the code you want me to use, I will modify Pico W "2" that has v1.22.1 firmare and install the code for a test to see if I can achieve your calculated predicted values? |
Beta Was this translation helpful? Give feedback.
-
Here is the screenshot of Pico W "1" with v1.20.0 to the left, then a drop while I swapped sensors, then normal, then a jump up to inaccurate temperatures when I went to v1.22.1, then drop back down to accurate with v1.20.1 And the inaccuracy is not a simple offset, it goes more inaccurate as temperatures change. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I thought of something else to check. At what point did the "different result sensor" phenomenon occur in the builds? I went back and put in all the firmware and tried them all. Here is what I found: Working builds: Different Result Builds: plus all the preview builds........ on edit - I took out the word "faulty" builds in this comment. I apologize to all the hard working folks who make all this happen. I should have used another word. If moderator wishes, I could re-edit that word out.... In fact, it may be a coincidence? By that, I wonder if after October of 2023, could a supporting module (like math?) have changed when I did my usual apt upgrade, etc? And the supporting module causes my errors and not the firmware upgrade build? Just asking... |
Beta Was this translation helpful? Give feedback.
-
@opiedopy The sample code I provided runs ADC 100 times and returns the average. You can as well change it to larger numbers. The diagram you sketched above looks wrong. I added the 10nF capacitor between ADC0 and GND. It reduces the impedance for the sample phase of the ADC and suppresses RF noise. I have a lot of that here from a nearby radio station. Nevertheless, the results to v1.20.0 and 1.22.1 seem comparable, less than 1 digit of the internal ADC. With the other board & set-up you see a difference. And your results with the voltage divider are different to mine, at least the raw readings. But maybe that's related to the batch of the PICO_W devices. The one I use is pretty old, maybe the first batch. Maybe I should get new ones. Anyhow there are differences in your initial set-up when using different firmware versions, reason unknown. The libraries used for the firmware are not related to code on your PC. So any upgrade of it will not affect the calculations in the board. @mendenm Noticing the difference between the actual input impedance and the data sheet, I glance though the code and did not seen anything obvious. But I did not compare it bit-by-bit with the RP2040 data sheet. And the behavior is the same for v1.20.0 and v1.22.1. So for a firmware version difference it did not matter. |
Beta Was this translation helpful? Give feedback.
-
previous picture had line error in drawing, here is my copy of robert-hh design as installed ps: On edit, I confess that I previously did not use AGND as shown but used another GND. Subsequently, as part of my investigation I re-did the soldering and used AGND as shown above. |
Beta Was this translation helpful? Give feedback.
-
This morning I ran the two different firmwares and results are below. The two results are very similar. This leads me to think that the "difference" in my original topic thermistor outcomes (with different firm wares) is module-related somewhere in the version codes. I mean that v1.20.0 treats some module (math?) differently than v1.22.1. ??
|
Beta Was this translation helpful? Give feedback.
-
Again, explaining the "difference" with thermistors with v1.22.1 too high in temperature and not a linear offset. import sys import sys |
Beta Was this translation helpful? Give feedback.
-
Marcus,
Thank you for your comment. I have multiple checks on accuracy of readings
for the v1.20.0 Pico board.
The frozen vegetables were on top of a plastic bag to protect the two Picos.
Additionally, my infrared reading was spot on and matched v1.20.0 Pico.
I’ve used another Pico W in our Alaska property monitoring a 27 kw boiler
for a year+. When I set boiler output for 160/140/120 adjustable I get Pico
W info of exactly those readings that also confirm the dial gage on boiler.
I reside in NC and depend on the Pico W reading from there via internet.
I am in no distress, as I initially stated. I can use older builds forever
I suppose. It is just a curious circumstance that Robert and you are
helping figure out. I remain grateful.
Perhaps the research will help others in future.
………..
…On Tue, Jan 23, 2024 at 1:39 PM Marcus Mendenhall ***@***.***> wrote:
@opiedopy <https://github.com/opiedopy> Neither of these numbers seems
even vaguely correct for having the sensor under frozen vegetables. Somehow
I think something is really wrong in both cases for your setup.
—
Reply to this email directly, view it on GitHub
<#13488 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASEPKVBB3RHQZRNNWCUPLBTYP77WRAVCNFSM6AAAAABCDTGKISVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DEMRUGM4TK>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
I made an interesting observation. When the ADC pin is
the input impedance is high (not like 25k), and the temperature dependency is gone. So you could try in your code to insert at the top before the line
Edit: It may not apply to your batch of the RP2040, since you had all the time reading with the resistor divider in the range of 32000. |
Beta Was this translation helpful? Give feedback.
I made an interesting observation. When the ADC pin is
the input impedance is high (not like 25k), and the temperature dependency is gone. So you could try in your code to insert at the top before the line
thermistor28 = machine.ADC(28) #hwr, hot water return, 10K NTC thermistor typical
:Edit: It may not apply to your batch of the RP2040, since you had all the time reading with the resistor divider in the range of 32000.