1

Recently had issues with HC-06 AND Arduino UNO. Turned out that the last module was not working, this module keeps flashing and it appeared in the Bluetooth list. I'm trying to work with some AT commands but for some reason this doesn't work. This module is brand new (ZS-040). enter image description here

#include <SoftwareSerial.h>

SoftwareSerial btSerial(2, 3); // RX, TX
/*
 * Connect pin 2 Arduino to pin TX HC-06 
 * Connect pin 3 Arduino to pin RX HC-06
 */
void setup() {

Serial.begin(9600);

Serial.println("Enter AT commands:");

btSerial.begin(9600);

}

void loop()

{

if (btSerial.available())

Serial.write(btSerial.read());

if (Serial.available())

btSerial.write(Serial.read());

}

I uploaded the code, went into Serial Monitor. When I type a command, I get no reply. I opened "Arduino Bluetooth" app,connected to my phone and when I type something in the terminal on my phone I see the text on my PC's Serial Monitor screen. Any ideas what I should do next? Could it be something to do with the RX pin? Should I use voltage divider? I have 1k and 2k Ohm resistors, how should I connect them if that's the solution?

6
  • you did not say what happens if you type in the serial monitor after sending data from the phone to the serial monitor
    – jsotola
    Commented Jan 9, 2020 at 22:42
  • i.imgur.com/cGkbeFz.gifv I can send data from the phone but not in the PC. I also got this reply from another platform but still not sure what I should do next. I need instructions, I'm new to all of this. Thanks.
    – Janar
    Commented Jan 10, 2020 at 14:49
  • the other reply: i.imgur.com/KLACLDD.png
    – Janar
    Commented Jan 10, 2020 at 14:49
  • Tried changing bt modules baud rate, that didn't work
    – Janar
    Commented Jan 10, 2020 at 14:51
  • SOLVED: Read this guide (chenthedesignmaker.com/…), tried changing "No line ending" to "Both NL & CR". Now when I type AT command I get the reply OK and when I type on my phone I see the text in serial monitor (PC).
    – Janar
    Commented Jan 10, 2020 at 15:04

1 Answer 1

1
  1. Use a macro like this to send AT commands:

     #include <SoftwareSerial.h>
    
     SoftwareSerial btSerial(2, 3); // RX, TX
     /*
      * Connect pin 2 Arduino to pin TX HC-06 
      * Connect pin 3 Arduino to pin RX HC-06
      */
     void setup() {
    
     Serial.begin(9600);
    
     Serial.println("Enter AT commands:");
    
     btSerial.begin(9600);
    
     }
    
     void loop()
    
     {
    
     if (btSerial.available())
    
     Serial.write(btSerial.read());
    
     if (Serial.available())
    
     btSerial.write(Serial.read());
     delay(1000);
     //btSerial.print("AT+PIN4321");
     //btSerial.print("AT+NAMEAlibaba");
     //btSerial.print("AT+BAUD4");
    
    
     }
    
  2. You may have another port set on the HC 06 instead of 9600, like I had. If so, try this code with all the possible port numbers and changing something like the password, and everytime you run the code - go check if it worked, this way you will find in wich port number you have your module.

good luck

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.