OK guys, thanks for your support.
Yes, the connexions are like mentioned in J-M-L's post.
My first and foremost error was to focus on the TX/RX leds. I followed StefanL38's advice and made 2 simple sketches (send/receive "Hello") and realized that in my case, and I would like confirmation that it's also the case for you, the TX/RX leds do not blink when data is transmitted from an arduino to another.
Once I took that obsession out of my mind, I started to dig further in my "Recepteur" code and found errors.
First here is the modified code
const byte numChars = 32;
char receivedChars[numChars];
boolean newData = false;
char tempChars[numChars];
int FLAG = 0;
int LED = 3;
char * strktokIndx;
//____________________________________
void setup()
{
Serial1.begin(9600);
Serial.begin(9600);
pinMode(LED, OUTPUT);
}
//____________________________________
void loop()
{
newData = Scan_Instructions();
Serial.print("newData = ");
Serial.println(newData);
Serial.print("receivedChars = ");
Serial.println(receivedChars);
if (newData == true)
{
strcpy(tempChars, receivedChars);
Serial.print("tempChars = ");
Serial.println(tempChars);
Parse_Instructions();
}
Serial.print("FLAG =");
Serial.println(FLAG);
if (FLAG == 0)
{
Stop_LED();
}
else
{
Start_LED();
}
newData = false;
Serial.println("___");
delay(1000);
}
//____________________________________
boolean Scan_Instructions()
{
boolean Incoming_Msg = false;
boolean newData = false;
byte ndx = 0;
char startMarker;
char endMarker;
char rc;
startMarker = '<';
endMarker = '>';
while (Serial1.available() > 0 && newData == false)
{
rc = Serial1.read();
//Serial.print(rc);Serial.print("===");
if (Incoming_Msg == true)
{
if (rc != endMarker)
{
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars)
{
ndx = numChars - 1;
}
}
else
{
receivedChars[ndx] = '\0';
Incoming_Msg = false;
ndx = 0;
newData = true;
}
}
else if (rc == startMarker)
{
Incoming_Msg = true;
}
}
Serial.print("newData (in function) =");
Serial.println(newData);
return newData;
}
//____________________________________
void Receive_Instructions()
{
strcpy(tempChars, tempChars);
}
//____________________________________
void Parse_Instructions()
{
char * strktokIndx;
strktokIndx = strtok(receivedChars, ",");
FLAG = atoi(strktokIndx);
//return FLAG;
}
//____________________________________
void Start_LED()
{
digitalWrite(LED, HIGH);
}
void Stop_LED()
{
digitalWrite(LED, LOW);
}
I added serveral intermediary "Serial.print" to track the results from my different orders and spot where my code was bugging.
Now that it's working, serial monitor returns :
newData (in function) =1
newData = 1
receivedChars = 1
tempChars = 1
FLAG =1
... When my hand was on the sensor and ...
newData (in function) =1
newData = 1
receivedChars = 0
tempChars = 0
FLAG =0
... When my hand was not on it.
The part that had to change from my initial code was the function boolean Scan_Instructions(). It did not return adequate newData and was not providing adequate receivedChars for the loop(). While the boolean was true in the function, it stayed false outside. Char receivedChars was "infinitely expanding".
Since newData was always false, receivedChars was never copied in tempChars and, therefore, Parse_Instructions() was useless.
Then nothing was working...
My (main) modifications were:
- making boolean Incoming_MSG and newData non static (they all were static)
- I corrected an error I made while typing the second condition
if (rc != numChars)
instead of
if (rc != endMarker)
My next step will be to add a second parameter to the packet data (a float that will be processed by the slave to compute pump speed) and make sure parsing is effective.
My conclusion, linked to the title of this thread : no, the board's TX/RX led DO NOT BLINK when arduinos are communicating between them. That's only the case when communication is occuring between arduino and serial monitor (computer).
Thanks again, cheers