Hi,
I've seen many topics about this module, but no one that fits my problem, so here is a new one :
I'd like to connect a bluetooth HC-05 module to an Arduino Mega to enable communication between my phone and my Arduino device.
I have connected the module like on This stackexchange's pinout, except I put RX and TX on ATMega pins 18 (TX) and 19 (RX) to keep an access to Serial monitor
Right now, my problem is that a message sent from the Serial monitor is received by the Android app (I'm using the "Arduino Bluetooth Controller" android application), but a message sent by the app is not received by the module. I have tried example codes with chat, LED on and off, etc, nothing is working.
Here is my current code, and screenshots of the messages exchanges (I hope images won't be too big):
#include <SoftwareSerial.h>
SoftwareSerial BTserial(19, 18);
// DPin-19 of UNO is RX-pin; to receive data from TX-pin of HC-05
// DPin-18 of UNO is TX-pin; to transmit data to RX-pin of HC-05
char c;
void setup()
{
Serial.begin(9600);
BTserial.begin(9600);
}
void loop()
{
if (BTserial.available())
{
Serial.print("Bluetooth > ");
while (BTserial.available())
{
c = BTserial.read();
Serial.write(c);
}
}
if (Serial.available())
{
Serial.print("> ");
while (Serial.available())
{
c = Serial.read();
Serial.print(c);
BTserial.print(c);
}
}
}
Can anyone help me solve this communication problem ? Thanks !