Open jontebotas opened 8 years ago
I have also tested to assign a static IP to my ESP-01 in my router, but I still get the same problem as above.
When bypassing the Uno to communicate with the ESP-01 directly via AT commands in the serial monitor, I manage to connect to my AP - and this time i get the correct IP (my static IP). This tells me the problem lies in my sketch or in WifEsp (or my use of it)?
Hey, don't know if it may help, but I made a MQTT example and post it in this issue #37 . Hit me back if you need help.
Hi! I am using a ESP8266-01 to enable wifi for my Arduino Uno. The ESP-01 is connected via the RX/TX on the Uno, and i am using SoftSerial for debugging (via an Arduino USB2Serial). The ESP-01 is powered from a separate power source.
I manage to connect to my AP (wifi), but not to my MQTT broker (mosquitto on a raspberry pi). I get the following error in mosquitto:
In the serial monitor, i get that the MQTT-connection fails (RC: -2)
The essential parts of my code: Declarations etc:
My setup-loop (i'm using a macro to enable/disable serial.println for debugging)
The reconnect() function:
I have found one strange thing: In the mosquitto-logs my Uno/ESP-01 have the IP: 10.0.1.16 (which is also the IP that is shown when checking the connected clients in my AP). However, when i call the function WiFi.localIP() in my Arduino sketch, it says that my local IP is "10.0.1.116". Can this be the reason to why my MQTT-connection fails? I haven't found a way to get around it though...
Any ideas on how to solve this?
Thankful for any help!