Using photon as a computer to serial interface

I needed to connect to a serial device but I didn’t have a serial adapter for my computer. I took the photon and basically bridged Serial and Serial1 to basically form my own serial adapter.

int incoming1 = 0;
int incoming = 0;
void setup()
{
    Serial.begin();
    Serial1.begin(115200);
    pinMode(D7, OUTPUT);
    digitalWrite(D7, LOW);
    
}

// Rx Serial -> Tx Serial1
// Rx Serial1 -> Tx Serial

void loop()
{
    digitalWrite(D7, LOW);
    
    if (Serial1.available() > 0)
    {
        incoming1=Serial1.read();
        Serial.write(incoming1);
    }
    
    
    
    if (Serial.available() > 0)
    {
        incoming=Serial.read();
        Serial1.write(incoming);
        digitalWrite(D7,HIGH);
    }
    

}
2 Likes

Is this over Wi-Fi or hardwired?

Wire. It just connects the usb serial to the rx and tx serial so that when you connect the rx and tx pins to a serial device, you can use it via photon connected to usb.

2 Likes