Blluetooth module hc-05 not working

I am using the software serial library to use the bluetooth module hc-05 with arduino UNO.
I am using a old code that worked in the past
'''#include <SoftwareSerial.h>

#define deviceDXSX "DX"
#define fsample 20

#define cailbration_m 2.7
#define calibration_q 600

String sensorData = "";

int state = 0;
void setup() {
Serial.begin(9600); // Default communication rate of the Bluetooth module
}
void loop() {

if(Serial.available() > 0){ // Checks whether data is comming from the serial port
state = Serial.readString()[0]; // Reads the data from the serial port
String st = "------------- Received: "+Serial.readString();
Serial.println(st);
} else {

sensorData = "";
sensorData = sensorData + conditionSensorInput(analogRead(A0))+";";
//sensorData = sensorData + conditionSensorInput(analogRead(A1))+";";
sensorData = sensorData + deviceDXSX+";";
sensorData = sensorData + fsample;
Serial.println(sensorData);

}
delay(int(1000/fsample));
}

'''
I upload the code without connecting tx rx wires and after uploading I reconnect the wires (tx->rx and rx->tx) and connect the bluetooth to the computer, opening the buetooth serial nothing appear but just when I reattach the arduino to the computer and look to the USB serial I read all the data. I don't understand why. Someone can help me???

Hello
Run some HC-05 tutorials to get started.

1. Connect BT with UNO as per Fig-1.
hc05-UNO
Figure-1:2.

2. Check that your smart phone is paired with BT.
3. Upload the following sketch into UNO.

#include<SoftwareSerial.h>
SoftwareSerial SUART(10, 11);//SRX = DPin-10, STX = DPin-11

void setup() 
{
  Serial.begin(9600);
  SUART.begin(9600);
}

void loop() 
{
  if(Serial.available()>0)
  {
    SUART.print(Serial.read());
  }
  if(SUART.available()>0)
  {
    Serial.print(SUART.read());
  }
}

4. Enter A in the InputBox of SM and check that it has appeared on BT terminal of your phone.
5. Enter A in the BT terminal of your phone and check that it has appeared on OutputBox of SM.

You include the SoftwareSerial library, but do not create nor initialize (begin) a SoftwareSerial object.

To what pins is the HC05 connected? Post a schematic of your wiring, please. Hand drawn, photographed and posted is fine.

What Bluetooth device and app is sending to the Arduino + HC05?

Do the LED flashes indicate that the HC05 is paired and connected ( 2 quick flashes followed by a 2 seconds off, repeat)?

1 Like

The bluetooth is connected to arduino as following:
Vcc->3.3V
GND->GND
TX->D0(RX)
RX->D1(TX)
I didn't create any object because I should use directly the serial, I also tried to create the software serial object by using the pin D11 and D12 but they didn't work anyway.
The LED when connected to computer is flashed correctly as you say
I am looking directly to the HC-05 serial port
image

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.