Serial comunication between Teensy 4.1 and Arduino Nano 33 IOT

Luca

Active member
Hi, i am trying to get a teensy 4.1 to comunicate with an arduino nano 33 IOT over a serial bus but.
Here is the arduino code that is supposed to constantly send a message:
Code:
void setup() {
  Serial.begin(9600);

  pinMode(13,OUTPUT);
  digitalWrite(13,HIGH);
}

void loop() {
  Serial.println("Hello World");
  digitalWrite(13,!digitalRead(13));
  delay(1000);
}

And here is the teensy code that is supposed to read the message sent by the arduino on the serial monitor:
Code:
#define radio Serial2

void setup() {
  pinMode(13,OUTPUT);
  digitalWrite(13,HIGH);

  radio.begin(9600);
  Serial.begin(9600);
}

void loop() {
  if(radio.available()){
    Serial.print(radio.read());
  }
}

I am also attaching a photo of the breadboard wiring
IMG_4764 (1).jpg


The problem is that i dont see anything on the serial monitor when i plug in the teensy.
Any help will be apreciated.
 
I think you need to use different pins on Arduino Nano 33 IOT.
- UART (Universal Asynchronous Receiver-Transmitter)
UART IOT.jpg
 
Last edited:
Thanks a lot, i didn't know that on the arduino the serial monitor was separeted from the Uart. Now i see something on the serial monitor of the teensy but is random numbers that dont make sense.
I checked that it was set to the same baud rate of the boards (9600) but it didn't change.
#define radio Serial2 needs to be changed as well.

I also don't understand why i should do this.
 
Because the single, hardware UART on an Arduino Nano 33 IOT needs to be addressed as Serial1.begin().
From the document I referred above:
This is not the case for the Nano or MKR families, since these ones have two separate channels, using Serial for the communication with the computer and Serial1 for the communication with any other device through UART.
Thus #define radio Serial1.

Paul
 
Yes but that line is on the teensy code, the receiver, because i want to use one of the 8 hardware serial ports of that board and not the first one.
As you can see in the picture the jumpers are connected to the serial 2 of the teensy
 
Ah, OK. Sorry for the confusion caused.
If you want the Arduino Nano 33 IOT to send out data over the hardware serial port, you need to use Serial1:

C++:
void setup() {
  Serial1.begin(9600);

  pinMode(13,OUTPUT);
  digitalWrite(13,HIGH);
}

void loop() {
  Serial1.println("Hello World");
  digitalWrite(13,!digitalRead(13));
  delay(1000);
}
And don't forget to wire it like @Chris O. stated.

Paul
 
Here the updated tansmitter code:
Code:
/*
 * Transmitter Arduino Nano 33 IOT
 */

void setup() {
  Serial1.begin(9600);

  pinMode(13,OUTPUT);
  digitalWrite(13,HIGH);
}

void loop() {
  Serial1.println("Hello World");
  digitalWrite(13,!digitalRead(13));
  delay(1000);
}

Here the updated receiver code:
Code:
/*
 * Receiver Teensy 4.1
 */

#define radio Serial2

void setup() {
  pinMode(13,OUTPUT);
  digitalWrite(13,HIGH);

  radio.begin(9600);
  Serial.begin(9600);
}

void loop() {
  if(radio.available()){
    Serial.print(radio.read());
  }
}
And the updated wiring
IMG_4765 (1).jpg


This is what i see on the serial monitor:
1704449734490.png

How can i fix that?
 
Back
Top