Using a Raspberry Pi 3 Model B (Raspbian 9)
I am using MQTT to send Temperature, Humidity, and Pressure (BME280) to Cayenne. This all worked great until recently and now neither my BME280 sensor or my SI7021 will display the temperature. I have tried this on 2 different Raspberry Pi’s using the above mentioned sensors. I have not changed anything in my code I am using the typical paho.mqtt.client, but now all of the sudden the Temperature does not display. I did not think the updates would affect MQTT and Raspberry Pi.
I am still having this issue…thank you for responding…My code has not changed and it is mostly code that I found and modified. Again I have this same issue on 2 different Raspberry Pi 3’s and the temperature does not display when using the si7021 or BME280 sensors. Humidity and Pressure display just fine. Thanks.si7021_mqtt.txt (1.5 KB)
Try changing your if statements to have a print so you know for sure you are actually getting a value, then run the script in a terminal with python (filename).py to get the output. You can comment out the sleep at the top so you don’t have to wait 30 seconds.
if fahrTemp is not None:
print("temp: " + str(fahrTemp))
fahrTemp = "temp,f=" + str(fahrTemp)
mqttc.publish(topic_si7021_temp, payload=fahrTemp, retain=True)
if humidity is not None:
print("hum: " + str(humidity))
humidity = "rel_hum,p=" + str(humidity)
mqttc.publish(topic_si7021_humidity, payload=humidity, retain=True)
I have another program…again…one I slightly modified from someone else’s work. But it prints the temperature just fine. Also, I should add that through the dashboard using MQTT…it will display the temperature for like a second and then it goes away and just leaves a " - " where the temperature was. I think this is a Cayenne / MQTT issue. I can display DS18B20 1-wire temperature on the dashboard just fine, no issues at all. This issue started several weeks ago and I had run this same MQTT for months prior with no issue. I do appreciate your assist on this and thanks/sorry if it is your code that I have been borrowing (I’m still learning) I have 2 RPi 3’s that I am having this issue on and 2 different sensors (si7021 and BME280) and I am using 2 different Cayenne accounts (1 personal and 1 work) and in all cases the temperature does not display on the dashboard but prints the data fine outside of Cayenne and MQTT. I hope this makes sense. Attached is the loop code that I use that prints the temp just fine. si7021_loop.txt (2.0 KB)
this is the si7021 sensor and does print the temp and humidity values just fine. It just doesn’t seem to want to post the temp on the Cayenne dashboard for some reason. Again, same issue with the BME280 sensor…everything displays fine on the Cayenne dashboard but the temp. Thanks. I hope this give you some insight as to what is going on…
So it appears something has changed. I have done nothing to my Raspberry Pi 3’s nor have I changed any of the code, but now out of the blue the temperature is displaying again on all of my sensors and my Pi’s. I use a BME280 sensor and a si7021 sensor on 2 different Pi’s and now everything is working again. I assume something was changed on the Cayenne side that has fixed this?