One – Hardware Serials

Hardware Serials

The SODAQ ONE has 3 hardware serials:
SerialUSB – This is for when you are debugging over the USB Cable.
Serial – Serial is attached to pin D12/A12/TX and D13/A12/RX.
Serial1 – Is connected to the RN2483 LoRaWAN Module.

void setup() {
  // put your setup code here, to run once:
  SerialUSB.begin(57600);
  Serial.begin(57600);
  Serial1.begin(57600);
}

void loop() {
  // put your main code here, to run repeatedly:

}

 

SerialUSB

The sketch starts direct after uploading new code or when connected to a power source.
After opening a Serial Monitor the code will not reset, add the following code to your sketch if you want your sketch to wait for a Serial Monitor.

  while ((!SerialUSB) && (millis() < 30000)) {
    // Wait for SerialUSB or start after 30 seconds
  }

Override Serial

In most example sketches the default usb communication is Serial.
On the “old” AVR Arduino boards Serial is connected to the USB port.

There are two option to use SerialUSB instead of Serial.
1. Replace everywhere Serial with SerialUSB, recommended for when you would like to use Serial AND SerialUSB.
2. Overrride Serial, you cannot use Serial anymore, used for testing.

#define Serial SerialUSB