Connecting Nodemcu with Bluettoth device

I have connected device in this format. I am testing basic interactive code with bluetooth. If i send string

from '1' serially it wont respond led will not turn on . How can i use this device

if i disconnect TX and RX it will start working . means it print data. if i connected with hardware it didnt worked

int LED = D1;

void setup() {
 pinMode(LED, OUTPUT);
 Serial.begin(115200); /* Define baud rate for serial communication */

void loop() {

 if (Serial.available())  /* If data is available on serial port */
      char data_received; 
      data_received =;  /* Data received from bluetooth */
      if (data_received == '1')
       digitalWrite(LED, HIGH);
       Serial.write("LED turned ON\n");        
      else if (data_received == '2')
       digitalWrite(LED, LOW);
       Serial.write("LED turned OFF\n");
       Serial.write("Select either 1 or 2");

Select either 1 or 2LED turned ON
Select either 1 or 2Select either 1 or 2Select either 1 or 2Select either 1 or 2Select either 1 or 2Select either 1 or 2

Have you tested this with the Serial MOnitor.. and NO BT module attached yet.. to see if you are getting the results you expect?

Is the baudrate set correctly? (you have changed what was used in your 'example')

Have you paired a device to the BT module?

Yes it Started working. Why cant i upload the code TX & RX line connected to bluettoth. everytime if i need to upload fresh code i need to remove tx & rx wire and upload.

While using Software serial or Hardware serial function. Is there any way to avoid it

Because you need the RX/TX lines to upload your code.. you cant be using/connecting them to something else.

You use softwareserial fo ryour BT device.. and leave the RX/TX lines for your serial monitor/debugging and code upload abilities.