problem with HC-05: no data is shown

Hi, I made a project with a robot. That robot, with 4 DC motors, is controlled by smartphone through an app. In the middle of dealing with some problems, the HC-05 suddenly stopped working. It wasn't hot, there's no sign of burns, it just doesn't give life signs. I put another HC-05 sensor: this one doesn't send any data to the Arduino. Nothing. Zero. The light on it flashes at something like four times a second. I tried using AT mode: it just does not answer. It's like it's not there. I am using a Mega 2560 and the bluetooth is wired to Serial1. Here the code for the AT mode:

void setup() {
  pinMode(7,OUTPUT);
  digitalWrite(7, HIGH);
  Serial.begin(9600);
  Serial1.begin(38400);

}

void loop() {
  if(Serial1.available()) {
    Serial.write(Serial1.read());
  }
}

When I put the sensor in AT mode, the light flashes once every two seconds. The dead sensor, in AT mode, sends rubbish till 74880 baud, then nothing. What can I do? I wired the VCC to 3.3 volts: nothing happened. I had to wire the sensor to 5 volts to get the led flashing. The TX of the sensor is wired to RX1, and the RX is wired to TX1. What can I do? :'( :'( :'( :'(

speedylearner: The light on it flashes at something like four times a second.

This is probably telling you - power on, ready to connect.

Here the code for the AT mode: ............ } }

This code is sort of listening for data from Bluetooth, not for sending commands to Bluetooth.

When I put the sensor in AT mode, the light flashes once every two seconds.

Correct. Do you really need to do this?

The dead sensor, in AT mode, sends rubbish till 74880 baud, then nothing. What can I do?

If it is sending anything at all, it is not dead, it is just suffering from mis-use. You could try desisting from the mis-use, starting with the baud rate. HC-05 will only run reliably at the rate which you have configured it to run at. If you have not configured it, which is likely, it will only run at the default rate, 9600.

I wired the VCC to 3.3 volts: nothing happened. I had to wire the sensor to 5 volts to get the led flashing.

No surprise. Look on the back of the board. It probably says power 3.6v - 6v, which implies that feeding it 3.3v is probably a bad idea.

You might find the following background notes useful.

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

I want the Arduino to read data from the sensor. It does not work with 9600 baud and neither with 38400. It sends something - the TX light on the Arduino turns on. What can I do?

The Tx light on Arduino simply means Arduino transmitting something to the serial pin. Nothing more. It can do that with Bluetooth disconnected.

What can I do?

You might start by reading reply #1 again, particularly the bit about baud rates. I take it you have not bothered to read the background notes, or tried to use them.

I tried everything. Every baud rate. The TX light lights up when I send data. I send a thing, and the sensor just disconnects suddenly. I read all. I think the sensor isn't working correctly. I'll replace it. I'll let you know tomorrow.