DPHacks / picow-air

Pico W Air Quality Monitoring w/ PM 2.5 Sensor
MIT License
36 stars 6 forks source link

How can I get AQI values published through MQTT? #4

Closed Bursucel closed 2 months ago

Bursucel commented 4 months ago

I was able to add the particles values but I cannot get the json data to show AQI value . Any idea what it should be ? Thanks.

camerahacks commented 2 months ago

I just added to the latest version of code.py you can download it and copy to your board. Thanks for the suggestion.

Let me know if you run into any issues.

webdeck commented 2 months ago

It looks like a merge conflict got committed:

def pmdata_aqi():
    """
    Get AQI information based on average values
    """
<<<<<<< HEAD
    value = USAQI.pm25_aqi(average_values(avgDict)['pm25 env'])
    value = USAQI.aqi_info(value)
    return value
=======
    aqi = USAQI.pm25_aqi(average_values(avgDict)['pm25 env'])
    aqi = USAQI.aqi_info(aqi)
    return aqi
>>>>>>> 9636e2a3af18ddd94d9607d47c4bb861f79a2eba

and in the main loop:

while True:

    # Take the measurements after every interval
    if (clock + INTERVAL) < time.monotonic():

        mqtt_msg = {}

        mqtt_msg = read_all()

        # averrage to smooth out values
        avgDict = average_dict(mqtt_msg)

        mqtt_msg = average_values(avgDict)

<<<<<<< HEAD
        aqi = pmdata_aqi()
=======
        aqi_data = {'aqi': pmdata_aqi()}
>>>>>>> 9636e2a3af18ddd94d9607d47c4bb861f79a2eba
camerahacks commented 2 months ago

Aaaargh, fixed it!

camerahacks commented 2 months ago

Closing as addressed