how i can recive data?
example my data is :
a,b,c
a and b and c is number from 0 to 9999
a and b and c after recived put into variable:
sensor1=a
sensor2=b
sensor3=c
how i can send data?
example my data is :
a,b,c
a and b and c is number from 0 to 9999
a and b and c must sended by serial
sensor1=a
sensor2=b
sensor3=c
welcome to the arduino-forum.
For a small demo-code that shows the principle additional information is needed
at what baudrate is the data sended?
is there some kind of endmarker that is added after the number?
What device is sending the data?
another arduino?
a computer?
best thing would be if you could post a real example of the data
Hello, do yourself a favour and please read How to get the best out of this forum and modify your post accordingly ➜ please edit your post, select the code part and press the </> icon in the tool bar to mark it as code. (also make sure you indented the code in the IDE before copying, that’s done by pressing ctrlT on a PC or cmdT on a Mac)
Would you mind to learn first how to receive (transmit) only one character from the InputBox (to the OutputBox) of the Serial Monitor (Fig-1) and then learn multi-characters (the string)?
I can send and receive between Arduino and LabVIEW successful.
But I want send this form:
a,b,c
A and b and c is variable.
And my received data from LabVIEW is a,b,c format .
After received in Arduino I can put into sensor variable,but I can't separate sensor=a,b,c and put into sensor1-3.
The comma-delimited format is often known as System Data Format, SDF. This is the format used in GPS NMEA, so GPS libraries offer a good view into how to parse SDF streams.
if (strstr(nmea, "$GPRMC")) {
// found RMC
char *p = nmea;
// get time
p = strchr(p, ',')+1;
float timef = atof(p);
uint32_t time = timef;
hour = time / 10000;
minute = (time % 10000) / 100;
seconds = (time % 100);
milliseconds = fmod(timef, 1.0) * 1000;
p = strchr(p, ',')+1; // A/V?
p = strchr(p, ',')+1; // lat
p = strchr(p, ',')+1; // N/S?
p = strchr(p, ',')+1; // lon
p = strchr(p, ',')+1; // E/W?
p = strchr(p, ',')+1; // speed
p = strchr(p, ',')+1; // angle
p = strchr(p, ',')+1;
uint32_t fulldate = atof(p);
day = fulldate / 10000;
month = (fulldate % 10000) / 100;
year = (fulldate % 100);
// we dont parse the remaining, yet!
return true;
}
return false;
}
Robin's Serial Input Basics - updated might be a good read. It does not use String objects but it can give you the idea.
Please edit your post, select all code and click the </> button to apply so-called code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code. This is described in How to get the best out of this forum.