I need to get another serial port working in addition to Serial. I have been working with a Teensy, which has three serial ports. I just address them as Serial1, Serial2 and Serial3.
I soldered wired onto the castellated contacts for TX2 and RX2 and added the Teensy code to my Blues project. The code won’t build. I get an error “Undefined reference to `Serial2’.”
Are the pins labelled Serial 2 (or Serial0 or Serial3) usable in the PlatformIO/Arduino environment? If so, how do I use them?
I’m assuming you’re using a Swan, since you mentioned the castellated contacts (we do have a Swan Carrier in the store, that can make it easier to make connections to the castellated pins without soldering.
To use an alternative serial port you can add this to your app:
HardwareSerial Serial2(A5, A4);
This is particularly useful if you want to use our Notecard Outboard Firmware Updates feature with a Feather. The ODFU runs over TX/RX while Serial2 is used for serial communication in the sketch.
If you want to use RX2/TX2, then this is the declaration
HardwareSerial Serial2(PB6, PA2_ALT);
Don’t forget to call Serial2.begin() before using it