HC-05 bluetooth module not receiving data

Hi guys,
I'm using a HC-05 bluetooth module on default settings (I've not used any AT commands) as i want to receive data. I have made an app in MIT App inventor that sends Bluetooth data to a connected module. The LED on the module blinks twice every few seconds so it is definitely connected, however it is not receiving the data it is sent. I have made a voltage divider with resistors on the RXD pin. Please can you help?

This is the programming section.

Have you forgotten something?

yeah its about the code for the bluetooth module

this is my code:

if (bluetoothSerial.available() > 0) {
    incoming_value = bluetoothSerial.readString();
    if (incoming_value == "b") {
      tone(12, 2000);
      delay(50);
      noTone(12);  
    }
}

Hi!

It would be quite easier if you start trying to receive a character instead of a String. Even because you´re actually using a character to control this snippet ("" apart). After doing it succesfully you can go through longer messages.

ok i've changed it to char still not working

char incoming_value;
  Serial.println(bluetoothSerial.available());
  
  if (bluetoothSerial.available() > 0) {
    incoming_value = (char)bluetoothSerial.read();
    if (incoming_value == 'b') {
      tone(12, 2000);
      delay(50);
      noTone(12);  
    }
    if (hc05.available()){
      char temp = hc05.read();
      if (temp == 't')                               
    {
      balanca.tare();                                
      Serial.println("Tare done!");  
    }

This is a snippet of a code that I use in a bluetooth scale. It works well.

Maybe you can share the whole code in order for me or others users try to help a little more...

my problem is that hc05.available() always returns 0. so it never works.

Maybe the problem lies in the code you didn't post

#include <SoftwareSerial.h>

SoftwareSerial bluetoothSerial(2, 3);

void setup() {
  // put your setup code here, to run once:
  pinMode(2, INPUT);
  pinMode(3, OUTPUT);
  
  bluetoothSerial.begin(9600);
    Serial.begin(9600);
  Keyboard.begin();
}

void loop() {                           
  // put your main code here, to run repeatedly:
  char incoming_value;
  Serial.println(bluetoothSerial.available());
  
  if (bluetoothSerial.available() > 0) {
    incoming_value = (char)bluetoothSerial.read();
    if (incoming_value == 'b') {
      tone(12, 2000);
      delay(50);
      noTone(12);  
    }
  }
}

So, there´s a good chance that your problem resides on the app. Are you sure it´s sending info to the HC-05?

i think so it uses send text block!

my app code

SoftwareSerial bluetoothSerial(2, 3);

What module pins are connected to 2 and 3?

To see if the issues are with the app inventor code or the Arduino/HC05 try using Kai Morich's Serial Bluetooth Terminal.

RXD to 3, TXD to 2

Yes, this looks correct with module RX to ss TX and module TX to ss RX

i tried the terminal and i sent the letter b. nothing happened on arduino

Your app code looks fine for me, just as your Arduino code. There´s something more missing... :face_with_raised_eyebrow:

Before "connecting" your app to the HC-05, your phone might be paired with it. Is it paired?

I saw somewhere that some HC-05 modules can come with a 38400 baud rate as standard. That would be my next guess.

When I use the terminal app and send a 'b' to your program I can flash an led connected to pin 12.

What is connected to pin 12?