|
Post by Jason on May 9, 2021 14:47:43 GMT -8
dow4hurst DM your script that wasn’t working and I’ll take a look at it. The value you are seeing is the raw data coming from the AQI reading.
Thanks,
Jason
|
|
dow4hurst
Full Member
SkyWeather2 Newbie
Posts: 117
|
Post by dow4hurst on May 10, 2021 13:15:51 GMT -8
Jason, I got it to work by putting the correct indents in. This section of code in DustSensor.py is I'm pretty sure what you intended to communicate and I just read the spacing wrong:
def read_AQI():
if (config.SWDEBUG): print ("###############") print ("Reading AQI") print ("###############")
if (config.SWDEBUG): print ("Turning Dust Power On") powerOnDustSensor()
# delay for 30 seconds for calibrated reading
time.sleep(30) time.sleep(0.1)
try: myData = hm3301.get_data() except Exception as e: print('=================================') print(datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')) print(e) print('=================================') return 0 if (config.SWDEBUG): print ("data=",myData) if (hm3301.checksum() != True): if (config.SWDEBUG): print("Checksum Error!") myData = hm3301.get_data() if (hm3301.checksum() != True): if (config.SWDEBUG): print("2 Checksum Errors!") return 0
myAQI = hm3301.get_aqi() if (config.SWDEBUG): hm3301.print_data() print ("AQI=", myAQI) #hm3301.close() powerOffDustSensor() state.AQI = myAQI
Before I had the try/except statement fully left justified, which python doesn't want. See below:
def read_AQI():
if (config.SWDEBUG): print ("###############") print ("Reading AQI") print ("###############")
if (config.SWDEBUG): print ("Turning Dust Power On") powerOnDustSensor()
# delay for 30 seconds for calibrated reading
time.sleep(30) time.sleep(0.1)
try: myData = hm3301.get_data() except Exception as e: print('=================================') print(datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')) print(e) print('=================================') return 0 if (config.SWDEBUG): print ("data=",myData) if (hm3301.checksum() != True): if (config.SWDEBUG): print("Checksum Error!") myData = hm3301.get_data() if (hm3301.checksum() != True): if (config.SWDEBUG): print("2 Checksum Errors!") return 0
myAQI = hm3301.get_aqi() if (config.SWDEBUG): hm3301.print_data() print ("AQI=", myAQI) #hm3301.close() powerOffDustSensor() state.AQI = myAQI I'm in the python stumbling around phase... Dow
|
|
|
Post by doxidad on May 10, 2021 14:41:42 GMT -8
Python = brain dead FORTRAN for spacing.
I'm always having indent problems - at least in FORTRAN everything started at column 6 except for comments and line numbers.
If you use the Raspberry Pi desktop, try using the Geany editor. It has nice column markers for ease of indenting properly.
|
|
|
Post by SDL on May 11, 2021 8:03:52 GMT -8
That helps a log. Geany. I use the enhanced VIM editor and it is very useful once it is set up.
BTW, my goal for the summer is to convert over to VSCode on the Pi to do Python editing. Scary!
BP
|
|
|
Post by Jason on May 11, 2021 11:58:58 GMT -8
Once you switch to remote interpreter on PyCharm you'll never go back. All code is maintained on my MacBook and executed remotely on the Pis. SO much easier!
Jason
|
|
|
Post by doxidad on May 11, 2021 17:07:34 GMT -8
I have PyCharm on my desktop. What you suggested will only work with the Professional version. That costs $$. Too bad because it would make life easier for coding. The Community (free) version doesn't contain the features for remote interpreter.
|
|
|
Post by SDL on May 13, 2021 9:34:33 GMT -8
VS Code comes with the remote as part of the free package. Just tried it once so I don't know the quality of the link yet.
BP
|
|
tecronin
Junior Member
Posts: 91
Raspberry Pi: Yes
|
Post by tecronin on May 15, 2021 20:13:12 GMT -8
|
|