Serial Interface Example

The next test covers the serial interface: There are three serial interfaces:

  1. Serial.begin(9600) -  the normal serial interface via the USB connection. After a reset, it takes about a second to be ready
  2. Serial0.begin(9600) - UART1 on the board
  3. Serial1.begin(9600) - UART2 on the board

The code is pretty simple:

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

void loop() {
    Serial.println("Hello World 1");
    Serial0.println("Hello World 2 UART1");
    Serial1.println("Hello World 3 UART2");
    delay(1000);
} 

With this code, the connected PC will see three serial ports being available and in the connected terminal windows you will see the different output. The baud rate used here of 9600 can be replaced independently by higher baud rates. To connect to the pins on the board I used FOCA breakouts. Please note that you have to connect RX of the FOCA with TX of the UART and TX of the FOCA with RX of the UART.


The nice thing with this setup is that it is easily possible to connect to a serial device like a bluetooth adapter without interfering with the USB connection as it is the case with the Arduino