dclaar / purple_air

Code for displaying Air Quality from a Purple Air device
MIT License
6 stars 4 forks source link

App periodically just stops #5

Closed danswett closed 4 years ago

danswett commented 4 years ago

Typically happens after a few hours of uptime, but sometimes faster. The heart will stop drawing and the AQI will stop updating.

Connecting to Putty and doing CTRL+C doesn't show any traceback - it just gives a clean console prompt.

Device is plugged into the USB port on a computer for power, but isn't attached. One device is connected to a mac and one to a PC and both exhibit the same symptom.

dclaar commented 4 years ago

Yeah, mine stopped once right after the update, unfortunately not connected to any computer. I plugged it into a computer, and it has been working flawlessly since.

Do you have any idea of a common condition that might trigger it? My wild guess--since mine has not stopped working, and the AQI is horrible (well, OK, not Napa horrible, 181 horrible)--is maybe something about low AQIs.

On Fri, Oct 2, 2020 at 10:52 AM Dan Swett notifications@github.com wrote:

Typically happens after a few hours of uptime, but sometimes faster. The heart will stop drawing and the AQI will stop updating.

Connecting to Putty and doing CTRL+C doesn't show any traceback - it just gives a clean console prompt.

Device is plugged into the USB port on a computer for power, but isn't attached. One device is connected to a mac and one to a PC and both exhibit the same symptom.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dclaar/purple_air/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALAVYVXUL2OCXB54XPYT43SIYHPDANCNFSM4SB7IRKA .

danswett commented 4 years ago

It was happening when the AQI was around 70, and still happening with the 160-170ish we've been getting the past few days. Doesn't seem dependent on the correction - happened with L and N.

I've thought about trying to reflash them to see if that changes anything

danswett commented 4 years ago

Seems to be happening much more frequently today (again for whatever reason).

dclaar commented 4 years ago

It would be great if you could putty to the device, interrupt with control-c, and then restart the app on the device. I have 2 running, and I can't get either to fail. It's really frustrating, because I know there's a bug somewhere! Hopefully I will have time this weekend to try to find it by code inspection.

On Fri, Oct 2, 2020 at 12:01 PM Dan Swett notifications@github.com wrote:

Seems to be happening much more frequently today (again for whatever reason).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dclaar/purple_air/issues/5#issuecomment-702905615, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALAVYWLP3323LLRA6VTFGLSIYPRNANCNFSM4SB7IRKA .

danswett commented 4 years ago

Sure. So connect Putty, CTRL+C, and then which command to restart it?

On Fri, Oct 2, 2020 at 12:22 PM Doug Claar notifications@github.com wrote:

It would be great if you could putty to the device, interrupt with

control-c, and then restart the app on the device. I have 2 running, and I

can't get either to fail. It's really frustrating, because I know there's

a bug somewhere! Hopefully I will have time this weekend to try to find it

by code inspection.

On Fri, Oct 2, 2020 at 12:01 PM Dan Swett notifications@github.com wrote:

Seems to be happening much more frequently today (again for whatever

reason).

You are receiving this because you commented.

Reply to this email directly, view it on GitHub

https://github.com/dclaar/purple_air/issues/5#issuecomment-702905615,

or unsubscribe

< https://github.com/notifications/unsubscribe-auth/AALAVYWLP3323LLRA6VTFGLSIYPRNANCNFSM4SB7IRKA

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dclaar/purple_air/issues/5#issuecomment-702914923, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4JWNIT23G2LFMXWYVHCN3SIYR7LANCNFSM4SB7IRKA .

dclaar commented 4 years ago

Hold down A, press power, go to apps, start app. Just like starting from scratch.

On Fri, Oct 2, 2020 at 12:51 PM Dan Swett notifications@github.com wrote:

Sure. So connect Putty, CTRL+C, and then which command to restart it?

On Fri, Oct 2, 2020 at 12:22 PM Doug Claar notifications@github.com wrote:

It would be great if you could putty to the device, interrupt with

control-c, and then restart the app on the device. I have 2 running, and I

can't get either to fail. It's really frustrating, because I know there's

a bug somewhere! Hopefully I will have time this weekend to try to find it

by code inspection.

On Fri, Oct 2, 2020 at 12:01 PM Dan Swett notifications@github.com wrote:

Seems to be happening much more frequently today (again for whatever

reason).

You are receiving this because you commented.

Reply to this email directly, view it on GitHub

<https://github.com/dclaar/purple_air/issues/5#issuecomment-702905615 ,

or unsubscribe

<

https://github.com/notifications/unsubscribe-auth/AALAVYWLP3323LLRA6VTFGLSIYPRNANCNFSM4SB7IRKA

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dclaar/purple_air/issues/5#issuecomment-702914923, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA4JWNIT23G2LFMXWYVHCN3SIYR7LANCNFSM4SB7IRKA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dclaar/purple_air/issues/5#issuecomment-702927338, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALAVYXFPYRZLSXOEOY4FTDSIYVKLANCNFSM4SB7IRKA .

danswett commented 4 years ago

Ah ok. Then presumably CTRL+C when I notice that it's frozen?

dclaar commented 4 years ago

Yes, if you don't already see an error.

On Fri, Oct 2, 2020 at 1:17 PM Dan Swett notifications@github.com wrote:

Ah ok. Then presumably CTRL+C when I notice that it's frozen?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dclaar/purple_air/issues/5#issuecomment-702938697, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALAVYVANOCANH7CRXQSNHTSIYYO3ANCNFSM4SB7IRKA .

danswett commented 4 years ago

Got it:

Traceback (most recent call last): File "main.py", line 48, in File "main.py", line 36, in main File "aqi.py", line 351, in Run File "aqi.py", line 309, in GetData File "m5stickc.py", line 237, in GetURI File "libs/urequests.py", line 102, in request NotImplementedError: Redirects not yet supported MicroPython 0f84002d0 on 2020-09-11; M5Stick with ESP32 Type "help()" for more information.

dclaar commented 4 years ago

Ooh. That's, umm, interesting. That means that purpleair returned a 302 status or similar.

On Fri, Oct 2, 2020 at 2:03 PM Dan Swett notifications@github.com wrote:

Got it:

Traceback (most recent call last): File "main.py", line 48, in File "main.py", line 36, in main File "aqi.py", line 351, in Run File "aqi.py", line 309, in GetData File "m5stickc.py", line 237, in GetURI File "libs/urequests.py", line 102, in request NotImplementedError: Redirects not yet supported MicroPython 0f84002d0 on 2020-09-11; M5Stick with ESP32 Type "help()" for more information.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dclaar/purple_air/issues/5#issuecomment-702956648, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALAVYTZQQANAXWCRTCIUNTSIY52FANCNFSM4SB7IRKA .

dclaar commented 4 years ago

Oh wait, it crashed for me, too! I got a 500 error, which means there's a problem on their site.

On Fri, Oct 2, 2020 at 2:05 PM Doug Claar dclaar@google.com wrote:

Ooh. That's, umm, interesting. That means that purpleair returned a 302 status or similar.

On Fri, Oct 2, 2020 at 2:03 PM Dan Swett notifications@github.com wrote:

Got it:

Traceback (most recent call last): File "main.py", line 48, in File "main.py", line 36, in main File "aqi.py", line 351, in Run File "aqi.py", line 309, in GetData File "m5stickc.py", line 237, in GetURI File "libs/urequests.py", line 102, in request NotImplementedError: Redirects not yet supported MicroPython 0f84002d0 on 2020-09-11; M5Stick with ESP32 Type "help()" for more information.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dclaar/purple_air/issues/5#issuecomment-702956648, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALAVYTZQQANAXWCRTCIUNTSIY52FANCNFSM4SB7IRKA .

dclaar commented 4 years ago

OK, I pushed a hack that will retry after displaying an error message for a while. Long term fix is to drag in https://github.com/pfalcon/pycopy-lib/tree/master/urequests, which handles redirects.

dclaar commented 4 years ago

Added a print statement for the 500 error. Can't do much about the 429. Purple air says they redirect if you hit the site too often, so I've asked what "too often" is.

dclaar commented 4 years ago

OK, after chatting with Purple Air, I've upped the interval so that it's not "too often".

dclaar commented 4 years ago

Sausage made while you wait. :)

danswett commented 4 years ago

👍

dclaar commented 4 years ago

I have put more protective code in. I also created my own copy of urequests.py that handles redirection, but it is not yet in the copy scripts. I'm waiting to hear back from Purple Air about how to handle the redirects first. But I'm closing because even without that, the device should recover after showing a red error screen for 5 seconds.