wsular / urbanova-aqnet-rpi-node-school

This repository contains code and notes related to the sensor packages developed for WSU Urbanova Air Quality Network (aqnet). This particular repository is for sensors that are used as part of the Ramboll project at schools in the Spokane School District.
0 stars 1 forks source link

Code stops on bad PMS5003 data #9

Closed matthewRoetcisoender closed 5 years ago

matthewRoetcisoender commented 5 years ago

It looks like if the data for the PMS5003 data isn't complete, the "break" stops the rest of the code and so the result is the same as before (code needs to be manually restarted)

vonw commented 5 years ago

Ahh... My fault... We need to use "continue" in the except portion of the try/except code. "break" literally breaks completely out of the loop, while "continue" starts at the top of the loop again. Please try that and let me know how it goes.

matthewRoetcisoender commented 5 years ago

It seems as though using "continue" instead of a break is supposed to restart the while loop...but if that is the case I'm not sure why all of the "continue's" already in place still occasionally results in an error as that should have the same impact as as adding a continue under the "except" block

matthewRoetcisoender commented 5 years ago

whoops just saw you put that in

matthewRoetcisoender commented 5 years ago

I added in the continue, I'm just not entirely sure how to test it as I haven't thought of how to simulate bad data while running the code...

vonw commented 5 years ago

Good point. But you should be able to scroll back up through the output on the screen to see if it printed any error messages, but then kept on going.

Also, as I suggested, you might want to pause the script execution for a couple of seconds before attempting to read the PMS5003 data again. So insert "time.pause(2)" just before the new "continue" commands (in both the PMS5003 and BME280 try/except commands.)

matthewRoetcisoender commented 5 years ago

ok I'll do that. In terms of the error messages, I have a picture of the output of when the code stopped, but for some reason it is taking a while to upload to the computer so I can paste it here. But essentially all of the print statements from the AWS protocols are printed, and then the "erroneous data record from PMS5003" and "skipping measurement and trying again" print statements from the except block are printed and then the terminal returns to where it needs an input. (so it didn't look like there were any error messages which might indicate that a continue might work if the code hadn't been halted by the break)

vonw commented 5 years ago

Right. But once you replace "break" with "continue" in the try/except loops, the software shouldn't stop. So the only way to know if a data buffer error occurred would be to look for the "erroneous data record from PMS5003" and "skipping measurement and trying again" statements (in past output).

matthewRoetcisoender commented 5 years ago

I had one instance today where the "error bad data" message came through (printed to RPi and email notification) and then after the delay acquired good data, so I think this issue might be solved

vonw commented 5 years ago

OK. Thanks for the update. Please close this issue when you're ready. We can always open it again if we encounter another failure. It's really great that we have time for the "shake down" on the roof!!