Pages: 1 2 [3]   Go Down
Author Topic: Controlling Automower  (Read 11497 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Change

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

to

Code:
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.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

But I will try your code thanks.
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.

* Automower.ino (9.24 KB - downloaded 8 times.)
« Last Edit: June 14, 2014, 03:52:16 am by Dawiinci » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
#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?
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: 1 2 [3]   Go Up
Jump to: