27 034 läst ·
94 svar
27k läst
94 svar
Automatisk styrning och övervakning av Automower 220AC
@M455E My GPS module and ESP32 has arrived. I tried compiling the code, and it does connect to the wifi and the mqtt broker, but I do not see any updates in MQTT on GPS. Is this because its not connected to the mower? Looking at the output in console, it doesnt log any errors either. The GPS module works fine with ESPHome on the same board. Got any tips?
You should see debug data about the GPS location atleast, even if the module isnt connected to the mower.D Dezzorex skrev:@M455E My GPS module and ESP32 has arrived. I tried compiling the code, and it does connect to the wifi and the mqtt broker, but I do not see any updates in MQTT on GPS. Is this because its not connected to the mower? Looking at the output in console, it doesnt log any errors either. The GPS module works fine with ESPHome on the same board. Got any tips?
But this only happens after the GPS got a fix. So if it doesn't get a fix, then no data there either (if i'm remember correctly)
D Dezzorex skrev:@M455E My GPS module and ESP32 has arrived. I tried compiling the code, and it does connect to the wifi and the mqtt broker, but I do not see any updates in MQTT on GPS. Is this because its not connected to the mower? Looking at the output in console, it doesnt log any errors either. The GPS module works fine with ESPHome on the same board.
I added a check for the GPS connected, and it seems to report false... But if I poll the serial directly it gets data. So somehow my gps module isnt beeing picked up as it should..P prozzerg skrev:
neither below is working...
if (gps.available(gpsPort)) {
handle_debug(false, (String)"GPS Availab...");
}
if (gpsPort.available()) {
handle_debug(false, (String)"GPS Availab...");
}
Problem solved. Seems the module was sending a bit too much information for the library to process or something, Worked to disable several messages
gpsPort.println(F("$PUBX,40,VTG,0,0,0,0*5E")); //VTG OFF
delay(100);
gpsPort.println(F("$PUBX,40,GGA,0,0,0,0*5A")); //GGA OFF
delay(100);
gpsPort.println(F("$PUBX,40,GSA,0,0,0,0*4E")); //GSA OFF
delay(100);
gpsPort.println(F("$PUBX,40,GSV,0,0,0,0*59")); //GSV OFF
delay(100);
gpsPort.println(F("$PUBX,40,GLL,0,0,0,0*5C")); //GLL OFF
delay(100);
gpsPort.println(F("$PUBX,40,VTG,0,0,0,0*5E")); //VTG OFF
delay(100);
gpsPort.println(F("$PUBX,40,GGA,0,0,0,0*5A")); //GGA OFF
delay(100);
gpsPort.println(F("$PUBX,40,GSA,0,0,0,0*4E")); //GSA OFF
delay(100);
gpsPort.println(F("$PUBX,40,GSV,0,0,0,0*59")); //GSV OFF
delay(100);
gpsPort.println(F("$PUBX,40,GLL,0,0,0,0*5C")); //GLL OFF
delay(100);
How does this Relay work that you mention? Also are you still using the buck converter. Or did you manage to make it work stable with 5V directly from the mower?M455E skrev:
If I remember correct I found in my faulttracing (on the bench) that I was using a slightly different NodeMCU and had not selected the correct HW when compiling the code. I’m soon about to test again in the mower but on the bench I could see a great improvement. Have also added a relay to my design to be able to stop/resume via SW.
Update. Everything is installed in the mower. I decided I'd try with 5V to begin with. It has been live since last night and is working. I do see it dropping to offline every now and then especially when charging, but interestingly when it's back online i check uptime it's still 16h etc, indicating that it didn't seem to crash. More likely maybe it just looses wifi due to interference during charging perhaps?D Dezzorex skrev:
Thank you for the awesome work here!
Now it's time to maybe make some updates to the code and also integrate it into Hass/Node-Red
My intention is to wire it in serial with the stop button. To be able to clear errors like “lifted” it seems like you need to press the stop button first. I’m just using a 3.3V level triggered relay bought from Amazon. Perhaps a 5V works just as good.D Dezzorex skrev:
I see. Won't that also trigger the hatch to open also? Or i guess the hatch opening is just tied to the physical button, and not the actual 3V signal ofcourse.M455E skrev:
Mine seems to have started to "crash" during charging again. It was running fine all of yesterday and today it has now crashed twice in the charger. I guess i have to install the buck converter after all.. are you still running buck converter or 5V?
Redigerat:
D Dezzorex skrev:I see. Won't that also trigger the hatch to open also? Or i guess the hatch opening is just tied to the physical button, and not the actual 3V signal ofcourse.
Mine seems to have started to "crash" during charging again. It was running fine all of yesterday and today it has now crashed twice in the charger. I guess i have to install the buck converter after all.. are you still running buck converter or 5V?
please share…D Dezzorex skrev:Update. Everything is installed in the mower. I decided I'd try with 5V to begin with. It has been live since last night and is working. I do see it dropping to offline every now and then especially when charging, but interestingly when it's back online i check uptime it's still 16h etc, indicating that it didn't seem to crash. More likely maybe it just looses wifi due to interference during charging perhaps?
Thank you for the awesome work here!
Now it's time to maybe make some updates to the code and also integrate it into Hass/Node-Red
D Dezzorex skrev:I see. Won't that also trigger the hatch to open also? Or i guess the hatch opening is just tied to the physical button, and not the actual 3V signal ofcourse.
Mine seems to have started to "crash" during charging again. It was running fine all of yesterday and today it has now crashed twice in the charger. I guess i have to install the buck converter after all.. are you still running buck converter or 5V?[
On my mower the hatch is mechanically operated and a micro switch is indicating Stop electronically. Thus the relay will not open the hatch.D Dezzorex skrev:I see. Won't that also trigger the hatch to open also? Or i guess the hatch opening is just tied to the physical button, and not the actual 3V signal ofcourse.
Mine seems to have started to "crash" during charging again. It was running fine all of yesterday and today it has now crashed twice in the charger. I guess i have to install the buck converter after all.. are you still running buck converter or 5V?
At the moment I do not have it running in the mower…
I will ofcourse share once it's done. Currently I'm still struggling with it dying... I did connect the buck converter to 18V and pulling it down to 5 (4.5 actually). It works great but suddenly it dies.M455E skrev:
I did first believe it was due to range as it kept connecting if i moved it away from the base. But at least now it actually crashed, although I'm not sure it was due to me testing my second esp32 with same clientID for mqtt. I do maybe suspect it could have caused it to crash... But not sure. I know for sure that on the charger it sits on -85dB so it's pretty close on the edge of range (it's actually just a few meters from the AP but there is some concrete and also it was raining)
I guess i will look into soldering on an External wifi antenna in the future.
Need to open the mower again and reset it... That's the real downside to using 18V. On/off switch cannot be used to also restart the esp. Almost considering removing the converter again, but not sure of it's safe? Do we know if it was the cause of the other crashes or not?
Redigerat:
I haven't used a buck converter and i still use the same hardware as when i wrote the first revision of the code. The hardware seems pretty happy to run for long, i've seen atleast 30 days uptime on it.D Dezzorex skrev:I will ofcourse share once it's done. Currently I'm still struggling with it dying... I did connect the buck converter to 18V and pulling it down to 5 (4.5 actually). It works great but suddenly it dies.
I did first believe it was due to range as it kept connecting if i moved it away from the base. But at least now it actually crashed, although I'm not sure it was due to me testing my second esp32 with same clientID for mqtt. I do maybe suspect it could have caused it to crash... But not sure. I know for sure that on the charger it sits on -85dB so it's pretty close on the edge of range (it's actually just a few meters from the AP but there is some concrete and also it was raining)
I guess i will look into soldering on an External wifi antenna in the future.
Need to open the mower again and reset it... That's the real downside to using 18V. On/off switch cannot be used to also restart the esp. Almost considering removing the converter again, but not sure of it's safe? Do we know if it was the cause of the other crashes or not?
As the esp32 is 3,3v, the dev board got a regulator in place between the 5V and the 3,3V. Hopefully that will save the rest of the hardware if the 5V goes too high.
That
I switched back to 5V directly. And it's been stable. I also modified the code a bit, as i suspect my crashed was caused by lost connection to wifi. As your initial code does a while-loop to reconnect to mqtt every 5 seconds if wifi fully disconnects inside that loop the system will never reconnect to wifi, so i added a check inside the loop to check if we are connected to wifi and if not retry every 30s. So far it's been stable for 20 hours so let's hope that fixed it. Got the inspiration from @M455E GitHub that has a reconnect, but I moved it from loop() to inside your while to actually make sure it will reconnect if it happens while stuck in the while loop. Fingers crossed it stays stable nowP prozzerg skrev:I haven't used a buck converter and i still use the same hardware as when i wrote the first revision of the code. The hardware seems pretty happy to run for long, i've seen atleast 30 days uptime on it.
As the esp32 is 3,3v, the dev board got a regulator in place between the 5V and the 3,3V. Hopefully that will save the rest of the hardware if the 5V goes too high.
I have now merged my most recent code into GitHub. It has the following changes based on the original code by @prozzerg.
https://github.com/Dezzorex/AMConnect
- Added wifi reconnect within the mqtt connect loop, to ensure reconnection to wifi if dropped.
- Added restart after X amount of wifi disconnects (default 60)
- Added use of mqtt qos 1 ( and non clean mqtt session reconnect). This will allow mower to receive messages sent when offline, as broker will hold onto message untill it has been received, to ensure any command sent will reach mower in case of network connection loss.
- Added possibility to disable either local and/or mqtt debugging. (Thought maybe for some reason this caused a memory issue originally, but was wrong track, but it's there now)
- Added a few debugging commands and some more mqtt topics. (RSSI, uptime, free heap, restart counts etc)
https://github.com/Dezzorex/AMConnect
- Added wifi reconnect within the mqtt connect loop, to ensure reconnection to wifi if dropped.
- Added restart after X amount of wifi disconnects (default 60)
- Added use of mqtt qos 1 ( and non clean mqtt session reconnect). This will allow mower to receive messages sent when offline, as broker will hold onto message untill it has been received, to ensure any command sent will reach mower in case of network connection loss.
- Added possibility to disable either local and/or mqtt debugging. (Thought maybe for some reason this caused a memory issue originally, but was wrong track, but it's there now)
- Added a few debugging commands and some more mqtt topics. (RSSI, uptime, free heap, restart counts etc)
Redigerat:
Now onto new challenges. Trying to work with the battery capacity, but getBatteryCapacitymAh seems to give a weirdly low number. Currently getting 774 constantly, while getBatteryCapacityUsed is growing/sinking (seen up to 2200 ish at least) depending on if it's used or charging. Any idea why the capacity is reported so low? I could always hard code capacity as 2200 and then devide current (used) with that to get a percentage, but it's so strange that the capacity reports so low. Is this perhaps a number decided upon boot or something? I can swear I've seen it much higher.