Two Port Serial connection (Serial & GPS)

    #define BLYNK_PRINT DebugSerial

    // You could use a spare Hardware Serial on boards that have it (like Mega)
    #include <SoftwareSerial.h>
    SoftwareSerial DebugSerial(2, 3); // RX, TX
    SoftwareSerial Printer(4, 5); //RX, TX

    #include <BlynkSimpleStream.h>

    // You should get Auth Token in the Blynk App.
    // Go to the Project Settings (nut icon).
    char auth[] = "b8bbb48d00684e4b9f3e2b79526c701c";

    float Lat = 0;
    float Lon = 0;
    float Alt = 0;

    BLYNK_WRITE(V1) {
      GpsParam gps(param);

      Lat = gps.getLat();
      Lon = gps.getLon();
      Alt = gps.getAltitude();
      
    }


    void setup()
    {
      // Blynk will work through Serial
      // Do not read or write this serial manually in your sketch
      Serial.begin(9600);  
      while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
      }
        
      DebugSerial.begin(9600); //Serial USB
      Printer.begin(9600);
      
      Blynk.begin(Serial, auth);
    }

    void loop()
    { 
      //DebugSerial.listen();
      //while(DebugSerial.available()>0){
        Blynk.run();
        //}
      //Printer.listen();
      //while(Printer.available()>0){
        Serial.println("Test");
       // }
    }


I hope to use blynk,

  1. Connect with Ethernet (Now I use it through Serial connection)
  2. Send GPS of Mobile
  3. Check the GPS information through Serial Monitor,

In this case, I am in trouble of using serial port parallelly
When I check the GPS information in Serial Monitor,
my COM port is busy, so I cannot check the information.
Furthermore, when I use cloud.blynk with COM port,
I cannot use Serial monitor,
However, If i do not use cloud.blynk with COM port,
I can check my ‘Auth Code’ in Serial Montor

You have correctly stated that a serial port can only be used by one connection at a time.

You haven’t said what type of board you are using.

If you want to connect to Blynk with the USB link, then you need to send other serial data back to your PC via SoftSerial using a TTL-USB adapter to another terminal program on your PC like Termite or something.

Or just connect to Blynk via a Ethernet shield, or WiFi shield, and use Serial and the IDE Serial Monitor as normal.

1 Like

Thanks Gunner.
It was really helpful.
My board is Arduino-Uno,
and I will change serial connection to Wi-Fi connection.
I hope it goes well. Thank you for replying!
Have a nice day.