Hi everyone !
I finally post my problem here because I desperate to find a solution.
I work on a project which consist in the transmission of the data on the Arduino Uno R3's analog input to a device working on OpenWRT, a Linux distribution for embedded systems.
The transmission is made by serial communication at 115200 Baud.
The embedded system is a router (Ref : TP-Link WR-703n).
My problem is :
When my embedded system begins to read on the serial port, the Arduino suddenly stops its transmission after a random duration (between 1 second and 2 minutes, without any logic). It is quite surprising because the communication is unilateral (the Arduino send data but is supposed to receive nothing from the embedded system).
Is anyone has an idea about the source of the problem ?
I would like to precise that I find the same problem if I try with an Arduino Mega 2560.
You will find my code this below :
int current, voltage;
long last_instant;
byte startflag = 5;
byte data[4];
void setup()
{
Serial.begin(115200);
}
void loop() {
if(last_instant < micros() - 1000)
{
last_instant = micros();
current = analogRead(A0);
voltage = analogRead(A1);
data[0] = current % 256;
data[1] = current / 256;
data[2] = voltage % 256;
data[3] = voltage / 256;
// Adaptation of the data in order to not use the flag value
if(data[1] == 5)
{
data[1] = 6;
}
if(data[3] == 5)
{
data[3] = 6;
}
// Data sending
Serial.write(startflag);
Serial.write(data[0]);
Serial.write(data[1]);
Serial.write(data[2]);
Serial.write(data[3]);
}
}
Thank you for your help !