AirGradient Forum

Repeatedly failing OTA update

I received and put together my I-9PSL today. It came with firmware 3.1.3 and after getting it connected to my wifi it indicated that it was doing an OTA update. However, it failed at some point. No big deal, I just used the browser-based update to install 3.1.13, and at boot it indicates it is on that version.

However, on every boot it goes into the OTA update process again trying to update to 3.1.13 and fails in the 50s of percent, here’s an example failure log:

firmwareCheckForUpdate:
firmwareCheckForUpdate: Perform
checking for new OTA update @ http://hw.airgradient.com/sensors/airgradient:24587c8007c8/generic/os/firmware.bin?current_firmware=3.1.13
Starting OTA update ...
Writing to partition subtype 17 at offset 0x1f0000
File size: 1413472 bytes
OTA message: 
OTA message: 0
OTA message: 1
OTA message: 1
OTA message: 2
OTA message: 2
OTA message: 3
OTA message: 4

OTA message: 54
OTA message: 54
OTA message: 55
OTA message: 56
OTA message: 56
E (75087) TRANSPORT_BASE: poll_read select error 113, errno = Software caused connection abort, fd = 49
OTA message: 56
E (75123) TRANSPORT_BASE: poll_read select error 0, errno = Success, fd = 49
Data read error
OTA message: 
# of bytes written: 803598
E (77820) esp_image: invalid segment length 0xffffffff
Error: esp_ota_end failed! err=0x5379. Image is invalid2
OTA message: 

The percent it fails at does vary a bit, it’s not consistent.

How do I get it out of this state?

Mine does that all of the time. I would expect you to be getting 3.2.0 at this point so it may be trying to install that one. That is what mine is running.

Not sure why it is having trouble though.

You could try manually updating to the absolute latest firmware here

https://www.airgradient.com/documentation/firmwares/

I later noticed the configuration it’s pulling was telling it to update to 3.2.0

[Configure] Info: Parsing configuration: {"country":"US","pmStandard":"ugm3","co2CalibrationRequested":true,"ledBarTestRequested":false,"ledBarMode":"co2","displayMode":"on","placeOpen":true,"abcDays":-1,"tvocLearningOffset":12,"noxLearningOffset":12,"temperatureUnit":"f","targetFirmware":"3.2.0","ledBarBrightness":50,"displayBrightness":80,"corrections":{"pm02":{"correctionAlgorithm":"none","slr":null},"atmp":{"correctionAlgorithm":"ag_pms5003t_2024","slr":null},"rhum":{"correctionAlgorithm":"ag_pms5003t_2024","slr":null}},"model":"I-9PSL"}
[Configure] Info: Parse configuration success
[Configure] Info: co2CalibrationRequested: True
[Configure] Info: Detected new firmware version: 3.2.0

I know I can manually upgrade, but the problem is that it actually has succeeded at downgrading itself once to 3.2.0, at which point I stopped getting data on the dashboard. So that’s not a great state to be in.

Additionally, the dashboard configuration page for selecting a version only goes up to 3.1.13, which is odd given how old that is and how it’s still actually telling my device to go to 3.2.0.

Also, why is OTA upgrade so broken? I have no confidence that it would actually upgrade to a newer version successfully, except after very many attempts.

Oh, and the reason I mentioned installing 3.1.13 is because the setup page (documentation/one-v9/) shows it, even though it is way out-of-date and you have to use the link for “Older firmware versions and change logs are available here.” to get the actually up-to-date version.

I’m now running 3.3.6 (except when OTA update succeeds and downgrades me to 3.2.0 and breaks data reporting …)

Scherm­afbeelding 2025-04-26 om 14.58.06

I got the purple (sometimes white) dot on the Airgradient, and thought i had Wifi trouble, after getting some mails with Offline notifications only but no mentioning of the older firmware like the screenshot after logging in the app portal and clicking on the three dots for showing the device information.

After i found this out i upgraded it through the browser successfully, connected to wifi and the AIrgradient showed the purple dot again. I did not notice it before so did the upgrade again and saw the downgrading in the display from the airgradient one and shows me also the white dot sometimes and changes back to purple.

I have a ticket open about 3.2.0 not being in the drop-down and the fact that different pages show different versions as the current release

I’ve been seeing lots of red (can’t talk to the server) and purple (got a response it didn’t like from the server) over the past couple of days. Fortunately the issues haven’t lasted long enough to cause any data loss, but I do think there’s a server-side issue (perhaps being overloaded) going on at the moment. It might be related to the failed OTA updates.

At some point my device did downgrade itself to 3.1.13.

Seriously, how is anyone supposed to stay on newer versions (including the latest) right now? There’s no way to turn off auto-downgrade, and no way to select newer versions.

So … turns out you can make the same call that the dashboard does when setting firmware version, but hack the version to be 3.3.6, and that works. Additionally, it did the 3.3.6 upgrade successfully on the first try, which I was not expecting.

If anyone cares to do it themselves I can explain further.

Yes, please explain. I rebooted my indoor and outdoor monitor today, and now data reporting is broken. I do get a failed firmware update notification at boot on the indoor monitor.

Easiest way assumes you have a linux machine, or linux under windows subsystem for linux, or maybe curl installed on windows (but I haven’t tried that). You use your browser’s developer tools (networking tab) when submitting the firmware version form on the dashboard, then copy that request as a curl command. You can edit that command to have whatever firmware version you want, then run it in a linux terminal. That’s really it.

The other path would be to use the browser tools to edit the page such that you can get it to submit a different version. I tried the simplest version of editing the DOM that is displaying the selected version, but that was no successful, so you’d have to dig around more into either the DOM or javascript variables to figure out what you have to edit before submitting.

Thanks for your quick answer! I will try this when I have some time. Hopefully they’ll fix it quickly. But if not, I’ll give this a try later this week.

Data reporting works again for me. Mistake on my side. I made some changes in my router configuration today and had a mistake in my firewall rules. Both of my monitors report data to the airgradient dashboard again. Both monitors automatically downgraded their firmware from 3.3.6 to 3.2.0.

Very confusing that the firmware notice in the APP is linked to the ‘how to upgrade the firmware’, instead it should be linked to the firmware setting in the Dashboard and perhaps there it should have a link to the Airgradient website to check if OTA fails.

Firmware now is ok, but in the console log i get a lot of these:
[2074089][E][WiFiClientSecure.cpp:144] connect(): start_ssl_client: -1
[AgWifiClient] Error: Failed fetch configuration from server with return code -1

and some of these lines:
[5562968][E][ssl_client.cpp:37] _handle_error(): [start_ssl_client():273]: (-80) UNKNOWN ERROR CODE (0050)
[5563081][E][WiFiClientSecure.cpp:144] connect(): start_ssl_client: -80
[AgWifiClient] Error: Failed post measures to server with response code -1

Online mode and isPostToAirGradient = true

Checked network on Macbook that got a correct response with:
openssl s_client -connect api.airgradient.com:443 -servername api.airgradient.com