I use Arduino UNO, Arduino Nano, and Bluetooth module HC-06.
I use blynk (v2.27.15) on my android phone
I use 2 types of connection 1st between Arduino UNO to Arduino nano, and 2nd Arduino UNO to HC-06, the default connection between Arduino UNO to HC-06 using softwareserial pin 2,3. but when I connect my wire in pin 2 and 3, the serial monitor content won’t appear, and I connect back to pin 0 and 1, the serial monitor content appears. Why I can’t change the connection pin?
here it is my code:
#define RX1 2 //Connect to the TX pin of the HC-12
#define TX1 3 //Connect to the RX pin of the HC-12
SoftwareSerial DebugSerial = SoftwareSerial(RX1, TX1); // RX, TX
#define RX2 4 //Connect to the TX pin of the Arduino Nano
#define TX2 5 //Connect to the RX pin of the Arduino Nano
SoftwareSerial mySerial(RX2, TX2);
#define BLYNK_PRINT DebugSerial
//char auth = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxee";
char auth = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxAS";
ff = 0;
A = param.asInt();
if ( A == 1)
Serial.println(" Manual ");
if ( A == 2)
Serial.println(" Setting ");
if ( A == 3)
Serial.println(" Auto ");
J = param.asInt();
if ( J == 1)
Serial.println(" Auto start ");
if ( J == 0)
Serial.println(" Auto stop ");
For you to be able to view the serial data from a pair of pns on an MCU, a TTL to USB adapter is required.
The UNO (and the majority of other dev boards) has an onboard TTL to to USB adapter. This is connected between pins 0/1 and the large USB port on the end of the board.
If you want to use other pins for debugging then you’ll need to add an additional TTL to USB adapter, usually known as an FTDI adapter, between your software serial pins and your PC.
The simpler solution is probably to continue using pins 0/1 for debugging via the built-in TTL–>USB adapter, and use a software serial port to communicate with your other device(s).
Hai Pete, i have no problem when i set pin 4 and 5 to serial communication between Arduino UNO and Arduino Nano, and before i set this code, i have done set it to pin 2 and 3 to communicate between Arduino UNO and Arduino Nano, so pin 0 and 1 to communicate between Arduino UNO and HC-06.
Just because when i need to cut connection from HC-06 with Arduino when i want to upload new program, so i need to move the HC-06 communication pin.
Also i’m not set pin 0 and 1 to serial but why the serial monitor keep showing the exact thing i want to send form my HC-06 to Arduino UNO?
You don’t need to, the Uno’s one hardware serial port - referenced as
Serial is hard-wired to pins 0/1 and the large USB connector on the end of the board (via the built-in TTL to USB adapter).
You are using this to communicate between the UNO and HC-06 for your Blynk Bluetooth connection:
and you are eavesdropping on that connection when you connect the large USB connector to your PC and open the serial monitor.
As I’ve already explained, if you wish to use a SoftwareSerial port for debugging then you’ll need an external TTL to Serial (FTDI) adapter.
Or, you’ll need to connect your HC-06 to a SoftwareSerial port and use
Serial rather than
DebugSerial for your debug messages so that then can be viewed via the onboard USB connector.
hooo, i see, then why the example code form blynk library for bluetooth HC-05 and HC-06 connected to 2 and 3 as the following
// You could use a spare Hardware Serial on boards that have it (like Mega)
SoftwareSerial DebugSerial(2, 3); // RX, TX
#define BLYNK_PRINT DebugSerial
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth = "YourAuthToken";
// Debug console
DebugSerial.println("Waiting for connections...");
// Blynk will work through Serial
// 9600 is for HC-06. For HC-05 default speed is 38400
// Do not read or write this serial manually in your sketch
@Richard_Hadiputra please edit your post, using the pencil icon at the bottom, and replace whatever characters you’ve used at the beginning and end of your code with the correct triple backtick characters so that it displays correctly.
Triple backticks look like this:
Yes, i did it, thanks, i’m not realize it before
Because that’s exactly what you need to do if you want to use the Uno’s Single hardware serial port with built-in TTL to USB adapter for debugging.
I really don’t think you’ve grasped the principal here, but I can’t be bothered to keep explaining and re-explaining something that isn’t Blynk related.
I’d suggest that you re-read the comments I’ve made in this topic and try to understand them. If that doesn’t help then do some googling or watch some YouTube videos that explain the issue in a way that you are able to understand.