Ok, I’ve setup my first MQTT sensor but I’m having a final difficulty that has me stumped as to where to look to fix it.
I have a NodeMCU development board with a DHT11 temp and humidity sensor attached. Sketch written and uploaded to the DB after a few hitches and now I can see the device in my wifi network so all good there.
I know MQTT is working as I can run the “Hello World” test without any issues either on my RPI which is running Home Assistant.
Built the sensors into HA and can see them on my UI but here’s where the hitch is, they are constantly showing as unknown and I cannot seem to get a reading for either temp or humidity from the sensor.
Should I be thinking it’s a faulty sensor or is there a way I can test that out to see if I’ve made a mistake somewhere else?
Ok, that appears to work better (sorry it’s been a long day) although I’m getting no response from the pi. The sketch was designed to wait 10 minutes between the sensor reporting in to conserve energy so one would assume I need to wait up to 10 minutes perhaps.
If you aren’t seeing any output in the mosquitto_sub window (when a message hits the broker, you’ll see the topic and payload of the mqtt message) even after whatever interval the NodeMCU should be reporting on, it means that the NodeMCU isn’t sending any messages. Debug your code first.
I should add it could be because the NodeMCU is not connecting to your broker, or your code not publishing a message every 10 mins like you think it should.
thanks, that’s what it looks like but I used the example code form the HA MQTT page and even chatted with the guy who wrote it. It all compiled and loaded correctly.
Guess I’ll have to go through the entire code to see what the issue is (not that I’m sure I’ll even know what to look for)
I don’t think I understand why your DHT wired correctly to the NodeMCU would have anything to do with the Raspberry Pi (which I assume is running HA) subscribing to the topic. They are independent things. Is it working now? That’s all that matters.
No it is still not working but I would think that the better response the Pi received was a good sign. Sorry, this is the first time I’ve tried working with MQTT so not very sure of myself.
Is the output I’ve received back on the pi ok? My concerns with not receiving the temp and humidity is because I think the sensor is not kaput after I hooked it up to the power source not the data source.
Your ESP8266 should publish messages. We haven’t received/seen any message yet. May be you should add some debug output (serial) to your sketch. So you can be sure what the MCU is doing. If you can see proper measurements you can try to publish the measurements via MQTT. If you post your sketch the support would be easier.