Communication between two boards

Hi everyone
I am new at programming and encountered a problem that I need experienced people like you to help to solve.

I have two arduino boards(M0 PRO and UNO). What I would like to do is transmit variables from M0 PRO to UNO which is connected to a screen(1.8" TFT shield, Adafruit), therefore those variables will be shown on the screen.

For testing, I simply tried to make "blank" shown on the screen while it did not work,below are what I wrote

M0 PRO

void setup() {
  Serial.begin(9600);
 
}

void loop() {
  Serial.write("100");
  delay(50);        // delay in between reads for stability
}

UNO

float p = 3.1415926;
int pr = 0;
int oldpr = 0;
String prs = "empty";

}

void loop() {

  prs = Serial.readStringUntil('\n');

  String output = "Pressure kPa: " + prs ;
  
  tft.fillRect(85, 5, 30, 10, ST7735_BLACK);

  tft.setCursor(5, 5);
  tft.setTextColor(ST7735_WHITE);
  tft.setTextSize(1);
  tft.println(output);
  
  delay(2000);

}

It will be a great help
Thank you very much :slight_smile:

Can you explain the connection between two arduino? How the serial pins connected on both Arduino?

One end reads data until it encounters a \n. The other end does not send a \n. Why not?

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example.

The 3rd example will be the most reliable and you should easily be able to make the sending Arduino comply with that system.

...R

If you have two boards, would you consider using 2-wire protocol? For programming, 2-wire is nice because it sends packets rather than individual characters that you have to parse as they come in.

PaulS:
One end reads data until it encounters a \n. The other end does not send a \n. Why not?

Did you check this suggestion from PaulS?
Have you went through Robin's tutorial, Post #3
How did you connect both Arduino's
Do they have common GND?
Arduino1->Arduino2

TX->RX
RX->TX
Note: Please don't PM me.