-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Home Assistant - MQTT #264
Comments
Finally I managed to make it work simply by putting the... correct ssid... Now, after around 20hours functioning correctly this message appears on Arduino Monitor: |
I had an issue where my router was not giving out a new DHCP lease due to an arp issue - I found a lot more stability with static IP configured - may help |
I still have the same problem after some time. I followed @brucehatherell advice but no result. |
I want to set up a static ip for arduino uno, not dhcp, can some one help me with the synthax for the ino file? |
I'm having a similar issue around this. I added something force the wifi to reconnect and then try the MQTT connection again. This works reliably, but I am noticing MQTT is still losing connection every few minutes. Is there anything special that should be set regarding MQTT? In Home Assistant, this is how frequently the sensor is losing MQTT connection. |
I think it's rather a network communication issue between the arduino/esp and the router/mqtt server, from a pc/laptop open a command prompt and execute a ping command with the -t parameter into arduino/esp and see if there is packet loss. |
I've managed to modify the sketch for arduino uno to setup static ip instead of dhcp: -added these lines:
Ethernet.begin(mac, ip, subnet, gateway); |
So I'm seeing times when I ping and it's OK Other times I'm seeing issues, like this: I also looked at the router + Mosquitto logs. Again I see peroids of nothing happening.. then I see this repeat over and over. |
It's clear a comunication issue between the device and router. You have packet loss and the device is reauthenticating (DHCPOFFER, DHCPREQUEST, DHCPACK) If the device is an esp try put it more closer to the router and if it's an arduino uno with ethernet shield replace the network cable between the router and the arduino (my arduino is not working if the cable length to the router is more than 10 meters) |
Hi @lubster85,
Are you running OpenWRT on the router? Looks like there's an OpenWRT setting that disconnects devices that don't send ACK packets frequently (which would apply to this use case): https://openwrt.org/faq/deauthenticated_due_to_inactivity
You could also add something in the sketch that pings the router at a certain interval to keep the connection alive, but this looks like a general networking issue. |
Hi, in my case the router is next to esp8266 but still communication issues after some time. |
Thank you for the suggestion. Yes, I am using OpenWRT. The ESP device is a NodeMCU device and it is a fair bit away from the router (but it should not be out of range). I have that setting in the config already on the 2.4GHZ network, but II'll try pinging the router ever-so-often and see if that helps. |
I know this has been mentioned before but power issues will also cause problems with wifi. Are you powering via usb? Try a different adapter just as an experiment as well. Normally you would see this as reboots but you didnt mention those so it could be something else. I have also seen a bad esp that would disconnect and never reconnect until a reboot. A new esp solved the issue. |
Yes, I am at the moment. I'm using a 5V 1amp (iPhone charger) power supply. I'll try a 2amp supply and see how that goes. I haven't noticed it reboot, but I haven't paid close attention to this. |
Yesterday I tried adding the following to my sketch. The idea was to ping the router every 5 seconds. I'm going to reflash it tonight and make sure no other changes are in the sketch (I'm using the HomeAssistant-MQTT example as my base) and will retest. To ping, I've added the "Pinger" library and I've placed it directly in the loop section just above mqttHandle();
On another note - would it likely have any impact to edit the Pubsubclient library to increase
? |
I keep my opinion, it seems to be a wifi signal issue. Rather than reflash the nod mcu with the same sketch, place it near by the router and see if the problem persists. It's a simple thing. |
@daexpert I'll give that a shot to test it, although unfortunately it has to be positioned where it is if i am to use it. I've had it in place for ages without issue and the router is the same device too so I'm really lost for a good explanation. For completeness sake, here are some logs from the ESP device and router after flashing the updated sketch.
|
I have checked the arduino monitor when the service became unavailable. Here is what I get: MQTT Disconnected, failed to reconnect When I have the reset button of esp8266 pressed the service becomes available again. Any idea? |
I have the same issue that it becomes unavailable and have to reset the ESP8266. I also tried to ping the ESP8266 and found that requests keep timing out, even when the WiFi signal is strong (-50dBm) |
It seems I managed to fix this issue just by re-flashing the firmware and selecting the correct board in the Arduino IDE. I was using NodeMCU 1.0 (ESP-12E) instead NodeMCU 0.9 (ESP-12) |
I admit that I am not familiar with MQTT and Home Assistant and I need some help:
In the following code:
...
const char* mqttServer = "192.168.1.200"; The domain or IP where the MQTT is installed (namely the IP of Home Assistant)?
const int mqttPort = 1883; // MQTT server port
const char* mqttUsername = "user"; // Optional, leave blank if not required Username of HomeAssistant or MQTT?
const char* mqttPassword = "pass"; // Optional, leave blank if not required Password of Home Assistant or MQTT?
...
Is there something I have to change on yaml code (except of course the configuration of zones, partitions etc.)?
The text was updated successfully, but these errors were encountered: