bluetoothesp8266nodemcuhc-05

Transmit/Receive data Nodemcu(V3) + Bluetooth Module HC-05


I am trying to communicate with the HC-05 Bluetooth module for quite long time now, but with no success.

I am using the Nodemcu(V3) ESP8266 module.

I connect the HC-05 to Nodemcu in following sequence:

HC-05             Nodemcu
-----             -----------
RX       -->      Pin 1 (Tx)
TX       -->      Pin 3 (RX)
Vcc      -->      +3.3V
GND      -->      GND 

For starters, i want to check if my Nodemcu is communicating properly with my HC-05 module.

I have written the following code to read the response of AT commands:

#include <SoftwareSerial.h>
SoftwareSerial BTserial(3, 1); // RX | TX
char Bluetooth_Name = ' ';

void setup() 
{
    // Arduino IDE serial monitor
    Serial.begin(115200);

    // HC-05 default serial speed for AT mode is 38400
    BTserial.begin(38400);  

    // Wait for hardware to initialize
    delay(1000);

    // Print debug string
}

void loop()
{

   // Keep reading from HC-05 and send to Arduino Serial Monitor
   if (BTserial.available())
   {
      reading = BTserial.read();
      Serial.println(reading);
   }

   // Keep reading from Arduino Serial Monitor and send to HC-05
   if (Serial.available())
   {
      reading = Serial.read();
      BTserial.write(reading);
   }
}

However, i do not get response for any AT command at all. The serial monitor just shows blank.

Thanks in advance

EDIT:- I connected the "EN" pin on the HC-05 to Vcc. Noe, the led on the HC-05 blinks slowly, which means that the HC-05 is configured in command mode. However, i am still not able to receive the response for any AT commands. I have also selected "Both NL & CR" in the serial monitor, configured the baud rate correctly and double-checked the hardware connections.

Everything seems to be correct except that i don't get response for the AT commands.

Please help!!!


Solution

  • I changed the line

    SoftwareSerial BTserial(3, 1); // RX, TX
    

    to

    SoftwareSerial BTserial(D4, D3); // RX, TX
    

    And got it to work!