Hi, I would like to do hardware serial communication between the Nano 33 BLE and OpenRB-150 which is very similar to an MKR board. I'll show what I have - but it's not working:
Here's the connected pins from the nano to the OpenRB-150:
- TX1 -> 13 Rx
- RX0 -> 14 Tx
- VIN -> 5v
- GND -> GND
I am trying to power the nano from the openRB-150, which works and I can run codes on the boards separately while the openRB-150 powers the nano. I want to use Serial2 for something else on the OpenRB-150 and want to use pins 13/14 to talk with the nano.
Here's the code on the nano:
//Transmitter
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // set LED pin as output
digitalWrite(LED_BUILTIN, LOW); // switch off LED pin
Serial.begin(9600); // initialize serial communication at 9600 bits per second:
Serial1.begin(9600); // initialize UART with the first board with baud rate of 9600
Serial.println("Enter a number between 0-9 to turn on or off the LED on different boards");
}
void loop() {
// check if there is any incoming byte to read from the Serial Monitor
if (Serial.available() > 0){
int inByte = Serial.read();
switch (inByte){
// Send to receiver 1
case '1':
Serial1.println('1');
delay(100);
Serial.print("Board 1: LED ON");
break;
case '2':
Serial1.println('2');
delay(100);
Serial.print("Board 1: LED OFF");
break;
default:
Serial.println(" ");
break;
}
}
}
Here's the code on the OpenRB-150:
//Receiver
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // set LED pin as output
digitalWrite(LED_BUILTIN, LOW); // switch off LED pin
Serial1.begin(9600); // initialize UART with baud rate of 9600
}
void loop() {
while (Serial1.available() >= 0) {
char receivedData = Serial1.read(); // read one byte from serial buffer and save to receivedData
if (receivedData == '1') {
digitalWrite(LED_BUILTIN, HIGH); // switch LED On
}
else if (receivedData == '2') {
digitalWrite(LED_BUILTIN, LOW); // switch LED Off
}
}
}