I have about 10.000 integer values (range : -200 / +200) on c#. I would like to send them to Arduino Uno.
I wrote a simple c# code (this code also display Arduino Serial Monitor, so i can check the results)
// piece of code that sends data to Arduino
int a = 0;
foreach (var results in s)
{
string ID = results.Sample.ToString() + '\0';
// if (a == 20) { MessageBox.Show(ID); a = 0; }
char[] buff = ID.ToCharArray();
serialPort1.Write(buff, 0, ID.Length);
}
And i wrote a simpe Arduino code
// piece of code that sends data to Arduino
void loop()
{
while (Serial.available() > 0) // do while serial data is available
{
char buffer[10];
Serial.readBytesUntil('\0', buffer, 5);
int i = atoi( buffer );
Serial.println( i );
}
}
When i send the datas pieces by pieces (20's in parts), the codes send and read datas correctly.
However, it does not see my job. When i send all the data at a time, the Arduino code does not read the datas correctly (synchronization problem).
I should send 2 column data(each of which contains 10.000 integer values).
The Arduino has a "small" (measured in bytes and not kilo or mega bytes) serial buffer. The buffer is probably filling up and dropping the remaining bytes.
Yes, it does. But, when the string is sent, only the characters up to the NULL are sent.
I'd recommend using \n instead of \0.
I could not understand exactly what is the difference between \n & \0?
By the way, i add a delay command in the c# program and now i could read one column's data correctly.
However, it is not enough fast and also i will read two column data.
When i add the second column's data, this solution will not be sufficient.
For what purpose? The Arduino can't store that many values.
Firstly, i should transfer the two columns data from c# program to Arduino's ports.
I would like to display & check the transfer process.
Therefore, I also display the Arduino Serial Monitor with c# application.