Go Down

Topic: Controlling Automower (Read 12463 times) previous topic - next topic

Dawiinci

Problem happens if Automower has low battery. So I have to restart Arduino because it is probably not an issue of the code. How can I do this?

pylon

Change

Code: [Select]
if (strcmp (buffer, "digital") == 0)

to

Code: [Select]
if (strcmp ((char *)buffer, "digital") == 0)

and it compiles for me.

Quote
Problem happens if Automower has low battery. So I have to restart Arduino because it is probably not an issue of the code. How can I do this?


What happens if the mower is low on battery? Does the voltage that powers the Arduino drop? How much voltage do you have with a full battery? How much if it's getting empty? Where do you feed the Arduino with this voltage (Vin, 5V, power connector)?

You can restart the Arduino by pushing the reset button. You probably meant how to do it in software: that doesn't make sense because your software is already not running correctly, so don't expect it to reset itself.

Dawiinci

I can read the Sensors so the issue might be in the Automower side.

But I will try your code thanks.

pylon

Quote
I can read the Sensors so the issue might be in the Automower side.


Why do you want to restart the Arduino then? What do you expect that this should fix?

Dawiinci

#34
Jun 13, 2014, 11:18 pm Last Edit: Jun 14, 2014, 10:52 am by Dawiinci Reason: 1
I can only guess, but it might be possible that the Automower gives feedback that has more than 5 Bytes and therefore I have the issue. In that case the script is not in sync anymore.

However I have a new issue with your code:
Code: [Select]
if (strcmp ((char *)buffer, "digital") == 0)

I can readSensor (humidity) only if I never call doCommand or digital, analog. After I call anything else than readSensor it returns nothing anymore until restart.

Code is attached.

pylon

Quote
I can only guess, but it might be possible that the Automower gives feedback that has more than 5 Bytes and therefore I have the issue. In that case the script is not in sync anymore.


That's no reason to reset the Arduino. If you're unsure clear the serial buffer from time to time.

Quote
However I have a new issue with your code:


Why do you think this has anything to do with "my" code?
Your code formatting is still horrible. Please take the time to use the AutoFormatter in the IDE at least.

Although it should make a significant difference, change the code

Code: [Select]
#define BUFFERSIZE 40
uint8_t buffer[BUFFERSIZE];
uint8_t i = 0;
while (i < BUFFERSIZE) {
  if (client.available()) {
    uint8_t c = client.read();
    if (c == '/') break;
    buffer[i++] = c;
  }
}


to

Code: [Select]
#define BUFFERSIZE 40
uint8_t buffer[BUFFERSIZE];
uint8_t i = 0;
while (i < BUFFERSIZE) {
  if (client.available()) {
    uint8_t c = client.read();
    if (c == '/') break;
    buffer[i++] = c;
  }
}
if (i < BUFFERSIZE) buffer[i] = 0;


In digitalCommand() and analogCommand() you're still using the String class. Why?

Dawiinci

Thanks it works for now. I will report back if it happens again.

Well I have another project, maybe you can give me a hint as well:
http://forum.arduino.cc/index.php?topic=248344

Go Up