Okay, everything works now. Thanks for the advice!
Now I have another problem. I would like to seperate the parts, I did it by the strtok() like you guys told me, but how is it possible to get everything like:
var1 = $IIMWV
var2 = 225.0
var3 = R
etc
(this is the string: $IIMWV,225.0,R,000.0,N,A*38)
I can have it printed this way, but doesn't the data get's overwrited every cycle?
This is the program I made to test it, so I don't mess up my main one.
#include <string.h>
char *data;
char delimiters[] = ",";
void setup()
{
Serial.begin(9600);
}
void loop()
{
char anemometer[] = "$IIMWV,225.0,R,000.0,N,A*38";
data = strtok(anemometer, delimiters);
while (data != NULL)
{
delay(500);
Serial.println(data);
data = strtok(NULL, delimiters);
}
delay(1000);
}
my goal is to work like this:
if the start of the string = var1 ($IIMWV)
write var2(225.0) to somewhere, var3(R) somewhere, etc
This way I can compare the vars, and make decisions whether it is correct, or use them to calculate other things.
I also tried out the atoi function to get the int's out of it, but here I have the same problem. How can I write them away so that I can process it?
I will post the main program, the one that is working, later when I get back home.
Already thanks for all the useful advice!
Ben