AirGradient Forum

MQTT Settings Not Reaching All Devices

I have changed my MQTT (mosquitto) server IP address on my network and have gone to AirGradient to update the address. The address on that page is correct.

I have 3 Air Quality monitors - all of which were reporting to the previous address as expected. 24 hours after making this change, and resetting all three monitors, only one of them is communicating with the MQTT server. The other two are not at all.

How can I debug why they are not communicating? The previous server is still receiving their broadcasts. How do I force them to update to the new address if not through the UI, here? AirGradient

Welcome to the community @cursive!

Are you able to check the server logs to see if the other devices attempt a connection at all?

I would also take debugs logs from the device successfully communicating with the server and one of the others that are not and compare these as well.

Hello! Sorry for the late response - it took me a few days to sit down and do this.

I attached all three sensors to the log viewer. Below is the relevant log lines for the one that is updating. I actually just changed the IP address again today and this one updated to the new one:

et server config: {"country":"US","pmStandard":"us-aqi","co2CalibrationRequested":false,"ledBarTestRequested":false,"ledBarMode":"pm","displayMode":"on","placeOpen":false,"abcDays":8,"tvocLearningOffset":12,"noxLearningOffset":12,"temperatureUnit":"f","targetFirmware":"3.3.9","ledBarBrightness":100,"displayBrightness":81,"corrections":{"pm02":{"correctionAlgorithm":"epa_2021","slr":null},"atmp":{"correctionAlgorithm":"none","slr":null},"rhum":{"correctionAlgorithm":"none","slr":null}},"model":"I-9PSL","mqttBrokerUrl":"mqtt://192.168.1.200:2883"}
Server configuration: 
inF: true
inUSAQI: true
useRGBLedBar: 1
Model: I-9PSL
MQTT Broker: mqtt://192.168.1.200:2883
S8 calibration period: 8
Requested abcDays setting: 8 days (192 hours)
Current S8 abcDays setting: 192 (hours)
'abcDays' unchanged

192.168.1.200 is the updated address and is correct - this one works.

This next one does not work:

Reset reason: ESP_RST_UNKNOWN
[Configure] Info: Reading file...
[Configure] Info: Reading file: success
[Configure] Info: Parse file to JSON
[Configure] Info: corrections not found
[Configure] Info: {"country":"US","pmStandard":"ugm3","ledBarMode":"off","abcDays":8,"tvocLearningOffset":12,"noxLearningOffset":12,"mqttBrokerUrl":"mqtt://192.168.1.150:2883","temperatureUnit":"c","configurationControl":"local","postDataToAirGradient":true,"ledBarBrightness":100,"displayBrightness":81,"offlineMode":false,"model":"I-9PSL","monitorDisplayCompensatedValues":false,"disableCloudConnection":false,"httpDomain":""}
Detected ONE_INDOOR
[OledDisplay] Info: begin
Firmware Version: 3.3.9
LED bar brightness: 100
Init SGP41 success
initializing PM sensor
cleared 0 byte(s)
setting active mode
7 byte(s) written
Set S8 AbcDays successful
[AGSERIAL] Info: IICSerial initialized
[AGSERIAL] Warning: IICSerial failed open serial line, retry..
[AGSERIAL] Warning: IICSerial failed open serial line, retry..
[AGSERIAL] Warning: IICSerial failed open serial line, retry..
[AGSERIAL] Error: IICSerial failed open serial line, give up..
Cellular module not available, using wifi
*wm:AutoConnect 
*wm:Connecting to SAVED AP: XXX
*wm:[ERROR] wifi begin failed 
*wm:AutoConnect: SUCCESS 
*wm:STA IP Address: 192.168.1.18
[WifiConnector] Info: Wait for configure portal
[WifiConnector] Info: WiFi Connected: XXX IP: 192.168.1.18
[LocalServer] Info: Init: airgradient_84fce60765e8.local
[MqttClient] Info: Init uri: mqtt://192.168.1.150:2883
Other event id:7
Successfully connected to MQTT broker
Create new MQTT task
[AgWifiClient] Info: Post measures to https://hw.airgradient.com/sensors/airgradient:84fce60765e8/measures
[AgWifiClient] Info: Success post measures to server with response code 200
LED bar brightness: 100

---- PAYLOAD
 {"boot":0,"bootCount":0,"wifi":-70,"ledMode":"off","serialno":"84fce60765e8","firmware":"3.3.9","model":"I-9PSL"} 
-----
Display brightness: 81
[OTAWifi] Info: http://hw.airgradient.com/sensors/airgradient:84fce60765e8/generic/os/firmware.bin?current_firmware=3.3.9
Success create networking task
[OTAWifi] Info: Firmware is already up to date
E (29836) esp-tls: [sock=49] select() timeout
E (29836) TRANSPORT_BASE: Failed to open a new connection: 32774
E (29837) MQTT_CLIENT: Error transport connect
MQTT_EVENT_ERROR
[MqttClient] Error: Reported from esp-tls: 32774
[MqttClient] Error: Reported from tls stack: 0
[MqttClient] Error: Captured as transport's socket errno: 0
[MqttClient] Info: MQTT_EVENT_DISCONNECTED
[MqttClient] Warning: Connection failed count 1

WiFi RSSI -71
Last process timeout, clear buffer and last handle package
PMS sensor connected 

CO2 = 563.00 ppm
Temperature = 26.45 C

The other one that doesn’t work looks similar - they are both receiving a very old (over a week now) IP address for the MQTT server from your guys’ cloud servers:

Reset reason: ESP_RST_UNKNOWN
[Configure] Info: Reading file...
[Configure] Info: Reading file: success
[Configure] Info: Parse file to JSON
[Configure] Info: corrections not found
[Configure] Info: {"country":"US","pmStandard":"ugm3","ledBarMode":"off","abcDays":8,"tvocLearningOffset":12,"noxLearningOffset":12,"mqttBrokerUrl":"mqtt://192.168.1.150:2883","temperatureUnit":"c","configurationControl":"local","postDataToAirGradient":true,"ledBarBrightness":100,"displayBrightness":81,"offlineMode":false,"model":"O-1PP","monitorDisplayCompensatedValues":false,"disableCloudConnection":false,"httpDomain":""}
Detected OPEN_AIR_OUTDOOR
Firmware Version: 3.3.9
Can not detect S8 on Serial1, try on Serial0
CO2 S8 sensor not found
Can not detect S8 run mode 'PPT'
Init SGP41 failuire
SGP sensor not found
Can not detect SGP run mode 'O-1PP'
initializing PM sensor
cleared 25 byte(s)
setting active mode
7 byte(s) written
Detected PM 1 on Serial0
initializing PM sensor
cleared 0 byte(s)
setting active mode
7 byte(s) written
Detected PM 2 on Serial1
Firmware Mode: O-1PP
[AGSERIAL] Info: IICSerial initialized
[AGSERIAL] Warning: IICSerial failed open serial line, retry..
[AGSERIAL] Warning: IICSerial failed open serial line, retry..
[AGSERIAL] Warning: IICSerial failed open serial line, retry..
[AGSERIAL] Error: IICSerial failed open serial line, give up..
Cellular module not available, using wifi
[WifiConnector] Info: Connecting to WiFi...
*wm:AutoConnect 
*wm:Connecting to SAVED AP: XXX
E (6570) wifi:sta is connecting, return error
[  6452][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007
*wm:AutoConnect: SUCCESS 
*wm:STA IP Address: 192.168.1.235
[WifiConnector] Info: Wait for configure portal
[WifiConnector] Info: WiFi Connected: XXX IP: 192.168.1.235
[LocalServer] Info: Init: airgradient_64e8330a15f0.local
[MqttClient] Info: Init uri: mqtt://192.168.1.150:2883
Other event id:7
Successfully connected to MQTT broker
Create new MQTT task
[AgWifiClient] Info: Post measures to https://hw.airgradient.com/sensors/airgradient:64e8330a15f0/measures
[AgWifiClient] Info: Success post measures to server with response code 200
E (17702) esp-tls: [sock=49] select() timeout
E (17702) TRANSPORT_BASE: Failed to open a new connection: 32774
E (17703) MQTT_CLIENT: Error transport connect
MQTT_EVENT_ERROR
[MqttClient] Error: Reported from esp-tls: 32774
[MqttClient] Error: Reported from tls stack: 0
[MqttClient] Error: Captured as transport's socket errno: 0
[MqttClient] Info: MQTT_EVENT_DISCONNECTED
[MqttClient] Warning: Connection failed count 1
[OTAWifi] Info: http://hw.airgradient.com/sensors/airgradient:64e8330a15f0/generic/os/firmware.bin?current_firmware=3.3.9
Success create networking task
[OTAWifi] Info: Firmware is already up to date
Firmware update: up to date

Is there a way to force these other ones to update (or better yet, be able to set this locally?)

On the 2 that aren’t receiving the update the ConfigurationControl is set to Local, which means it won’t get configuration settings from the AirGradient Dashboard site.

This happens when you use the HomeAssistant integration by default. If you are using HA, go into Settings>Devices and select your AirGradient device and change the Source to Cloud
image

Or you can use an API request to set the MQTT on your locally controlled device using curl or Postman if that is up your alley.

3 Likes

Oh, thank you very much! I had no idea adding those to HA did that! I changed it to Cloud again and they are now working as expected !

It might be worth mentioning that on the MQTT settings page or the documentation for it.

1 Like

@airgradient @Achim_AirGradient
This is exactly what I was reporting in request 25815 about the confusion it causes that by adopting AirGradients to the HomeAssistant integration and changing the Configuration Source to Local.

@Nastya_AirGradient can you please add this note in our dashboard on the MQTT screen. Thanks.

I don’t necessarily think it belong on the MQTT section, as none of the Dashboard settings will flow down to a device if Configuration Control is set to Local.

If anything, the Dashboard should show some kind of indication on the main page that a device is controlled locally. But ideally, the HA integration would stop changing the configuration of an AirGradient device and keep it however it was when it was first adopted.

Yes I agree. I think we actually discussed exactly that. To display a warning on the dashboard if that setting is there. I will check what happened of that discussion.

To be clear - we’re talking about user experience here, and as an end-user who wanted to update my MQTT endpoint there was no indication to me on the only documented place I can set the MQTT endpoint that I need to watch for this, so I do think some indication, directly on that page, would be helpful in my specific situation…

Updating this documentation would be good too: /support/kb-mqtt-conf/ (wont let me paste the actual link)

I honestly didn’t even know until this situation that local management was a thing I should look out for so some documentation updates (wherever you decide they go) would definitely help.

Thanks for the info and discussion on this! I very much appreciate the assistance!