Error when connecting to MQTT
Posted: Mon Feb 19, 2018 9:56 am
I am quite new to this and tried to program my ESP32 to read sensor data from DHT22 (actualy AM2302, but I was told they are the same), and post it to MQTT server running on Raspberry Pi 3. To do that I run microphyton script on ESP32, using REPL.
Here is error message that I get:
---------------------------------------------
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "dht_publish.py", line 11, in <module>
File "umqtt/simple.py", line 99, in connect
MQTTException: 5
---------------------------------------------
I am not sure what is file "<stdin>", but other two files ("dht_publish.py", "umqtt/simple.py") are based on tutorial that I found on this subject:
https://www.youtube.com/watch?v=_vcQTyLU1WY
Line 11 in file "dht_publish.py" is : "client.connect() # Connect to MQTT broker"
So I understand it is not able to connect to MQTT broker. I know that wifi is enabled and working on ESP32 as I got IP address and I see it registered on my wifi router. I also know that MQTT broker on my Raspberry Pi is working, I tested it with command line using Putty as well as using Node-Red. So if both network and MQTT broker are fine, I think something else must be causing error message... I double checked IP address that I have in "dht_publish.py" file, not sure what else can I check.
Here are lines 97-100 from file "umqtt/simple.py" . File Simple.py is taken from: https://github.com/micropython/micropyt ... qtt.simple (umqtt folder) and I haven't done any changes to the file as per turorial.
--------------------------------------
assert resp[0] == 0x20 and resp[1] == 0x02
if resp[3] != 0:
raise MQTTException(resp[3])
return resp[2] & 1
--------------------------------------
Any thoughts on how can I proceed further?
Here is error message that I get:
---------------------------------------------
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "dht_publish.py", line 11, in <module>
File "umqtt/simple.py", line 99, in connect
MQTTException: 5
---------------------------------------------
I am not sure what is file "<stdin>", but other two files ("dht_publish.py", "umqtt/simple.py") are based on tutorial that I found on this subject:
https://www.youtube.com/watch?v=_vcQTyLU1WY
Line 11 in file "dht_publish.py" is : "client.connect() # Connect to MQTT broker"
So I understand it is not able to connect to MQTT broker. I know that wifi is enabled and working on ESP32 as I got IP address and I see it registered on my wifi router. I also know that MQTT broker on my Raspberry Pi is working, I tested it with command line using Putty as well as using Node-Red. So if both network and MQTT broker are fine, I think something else must be causing error message... I double checked IP address that I have in "dht_publish.py" file, not sure what else can I check.
Here are lines 97-100 from file "umqtt/simple.py" . File Simple.py is taken from: https://github.com/micropython/micropyt ... qtt.simple (umqtt folder) and I haven't done any changes to the file as per turorial.
--------------------------------------
assert resp[0] == 0x20 and resp[1] == 0x02
if resp[3] != 0:
raise MQTTException(resp[3])
return resp[2] & 1
--------------------------------------
Any thoughts on how can I proceed further?