Electron Serial2 trouble

Hey everyone,

So I’ve got a new design and I have two serial devices that need to connect to an Electron. First one will connect to the good ol GND, TX, and RX pins. The second device however will need to connect to Serial2 which as I understand are available on C2(RX) and C3(TX). I went ahead and wired Serial2 to Serial 1 as shown here:

Then I flashed this code to the Electron:

#include "Serial2/Serial2.h"

SYSTEM_MODE(MANUAL);

unsigned long start = 0;
unsigned long tOut = 500;

void setup() {
    Serial2.begin(115200);
    Serial1.begin(115200);
}

void loop() {
    for(int i = 0; i < 10; i++){
        Serial2.printf("Test: %i\n", i);
        unsigned long start = millis();
        while(Serial1.available() == 0 && millis() < start+tOut);
        if(Serial1.available() == 0){
            Serial.println("No Data");
        }else{
            delay(10);
            while(Serial1.available() != 0){
                Serial.print(Serial1.read());
            }
            Serial.println();
        }
    }
}

All I see is No Data on my Particle CLI Serial log. Any ideas on this?

C2/C3 is Serial4.
Serial2 is the one that is shared with the RGB LED.

2 Likes

Lol. Thanks @rickkas7 I actually just tried Serial4 out of sheer curiosity and it worked. I think this diagram is a bit confusing:

It shows UART4 which is C2 and C3 as Serial 2 in the legend down below. Why in the world would it say Serial 2 next to UART 4 if the software reference to it is Serial 4? Very confusing.

You’re right, that is confusing. I’ll have to look into that because it doesn’t seem right.

2 Likes

Thanks man.