Bluetooth connectivity not working hm-10

i am trying to make an app that controls Arduino for a project I working on but I am having problems with the Bluetooth module. I have never used Bluetooth with Arduino before so I decided to try turning an LED on and off. but even after I connect my phone to the hm-10 module every command I send does not seem to be received by the module.

I used the same wiring as every youtube tutorial and article I saw, they are essentially all the same.

this is the code I used

#include <SoftwareSerial.h>
SoftwareSerial Bluetooth(9, 10);
int LED = 13;
int Data;


void setup() {
  Bluetooth.begin(9600);
  Serial.begin(9600);

  Serial.println("Waiting for command...");

  Bluetooth.println("Send 1 to turn on the LED. Send 0 to turn Off");
    pinMode(LED, OUTPUT);
}

void loop() {
  if(Bluetooth.available()){
    Data=Bluetooth.read();
    if(Data == '1'){
      digitalWrite(13, HIGH);
      Serial.println("LED On");
      Bluetooth.println("LED On");
    }
    else if(Data=='0'){
      digitalWrite(LED, 0);
      Serial.println("LED Off");
      Bluetooth.println("LED On D13 Off");
    }
    else{;}
  }
 
}

Hello dorcuthe

Did the mobile phone get paired to the BT-module ?

Did you check the wiring twice wrt rx/tx lines?

Post the wiring diagram.

Please edit your post, select all code and click the <CODE/> button; next save your post.

This will apply code tags so your code is easier to read and easier to copy and the forum software will display it correctly.

Your topic was moved by @pert because this is not a problem with avrdude; after all, you can upload :wink:


This is a screenshot from my phone. It is connect the light on the module stopped flashing, and it sent instructions to my phone, but when i send the number 1 to turn on the led, it does nothing.

Hello dorcuthe

Check out this small example:

//https://forum.arduino.cc/t/bluetooth-connectivity-not-working-hm-10/1263617
#include <SoftwareSerial.h>
SoftwareSerial Bluetooth(9, 10);
int LED = 13;
void setup()
{
  Bluetooth.begin(9600);
  Serial.begin(9600);
  Serial.println("Waiting for command...");
  Bluetooth.println("Send 1 to turn LED ON - Send 0 to turn LED OFF");
  pinMode(LED, OUTPUT);
}
void loop()
{
  if (Bluetooth.available())
  {
    switch (Bluetooth.read())
    {
      case '1':
        digitalWrite(13, HIGH);
        Serial.println("LED ON");
        Bluetooth.println("LED ON");
        break;
      case '0':
        digitalWrite(LED, LOW);
        Serial.println("LED OFF");
        Bluetooth.println("LED OFF");
        break;
      case '\r':
        Bluetooth.println("Send 1 to turn LED ON - Send 0 to turn LED OFF");
        break;
    }
  }
}


Same issue. I have been messing around with the wiring, and no matter what i try i cant seem to get it to recieve signals from my phone.

Did you check the data? Is it incorrect or you don't get any data at all?

Im not completly sure, but my phone is recieving the instructions from the board so i see no reason why it shouldnt be receiving data.

check the wiring.

Control your settings on phone app. CR carriage return, ascii/hex etc.

The wiring is fine, i have rx connected to 9 and tx connected to 10. The phone app is set to CR. it is connecting, when i use the serial monitor for the data inputs it sends the LED ON or LED OFF messages.

Carry out a test with a second BT module.
Replace the RX/TX cables.

Yep, but you have not confirmation for rx from phone to board. Make your loop to echo back whatever it receives.

Also here the wiring was fine: