Serial Comm Between Different Types of Arduino

I'm trying to get one arduino to send serial messages to the other using their Tx/Rx pins, and I succeeded with 2 arduino unos, but when I tried to send send from an arduino pro micro to an uno, it didn't work. I tried my nano 33 ble to the uno with no success either. So is this just not possible for some reason?

Here's the code:

Sender:

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

void loop() 
{
  int x = random(10, 20);
  Serial.println(String(x));
  delay(100);
}

Receiver:

const unsigned int MAX_MESSAGE_LENGTH = 12;

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

void loop() 
{
 while (Serial.available() > 0)
 {
   static char message[MAX_MESSAGE_LENGTH];
   static unsigned int message_pos = 0;
   char inByte = Serial.read();

   if ( inByte != '\n' && (message_pos < MAX_MESSAGE_LENGTH - 1) )
   {
     message[message_pos] = inByte;
     message_pos++;
   }
   else
   {
     message[message_pos] = '\0';
     Serial.println(message);
     message_pos = 0;
   }
 }
}

The Pro Micro has two serial ports. Which one did you use?

From memory, the Tx and Rx pins on a Pro Micro are Serial1 rather than Serial

2 Likes

Yes, I discovered that Serial1 instead of Serial works for the micro.

As for the nano 33 BLE, I still cannot get these two to talk to each other, or anything else. I suppose I could use Wire, but I'd rather use those ports for other things in my project.

Is there a working example of serial communication working with nano 33 BLEs? The code posted up top doesn't work, blank output.

The Nano BLE is a 3,3v board. The UNO is a 5v board. Use a voltage divider.

Good point, but a voltage divider won't fix the 3.3->5V translation. If you make that connection, it will have an extremely low noise immunity margin. A MOSFET based level translator is a better way. It level shifts in both directions.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.