I’m a French beginner in Arduino.
I started with Uno but after a while, I needed to use to much sensor and I changed for a Mega.
Recently, I started trying to use a HC-05 module.
Everthing was working fine until these last day.
I didn’t get my arduino mega working with SoftwareSerial library.
I followed some tutorial using HardwareSerial pin as Serial1 19/18 - Serial2 17/16 - Serial3 15/14 to declare SoftwareSerial object instance like :
// Rx, Tx
SoftwareSerial mySerial(19, 18);
But it was not working… After some search, I found that it was ussless to do that and better to use directly use Serial1 / Serial2 / Serial3.
And this solution was working…
Then, I tried to use the HC-05 module STATE pin to get the connexion status.
First I connected the STATE pin to one empty digital pin as pinMode(state_pin, INPUT). And by this way, I got the status.
Then, and maybe I did something wrong at this step (because I didn’t find concret example on Internet), and for that I used this example :
In that post, it’s wrote :
“As a quick visual indicator you can put a LED + suitable resistor on the STATE pin. When the module is connected the LED will light.”
I wanted to use a blue LED, but not idea about witch resistor to use… and how really connect the LED to the STATE pin.
I’ve tried several things :
STATE pin to the LED- and LED+ to the arduino pin / STATE pin to the LED+ and LED-. I didn’t remember, but in one case I still got the state value by digitalWrite (pin) and in the other case I got no more result… and in both case, the LED was no ligtning.
STATE pin to the LED+ and LED- to the arduino GND… still LED no lightning
STATE pin to the LED+ <==> LED+ to the arduino pin and LED- ton the arduino GND… still LED no lightning…
But now, I facing a problem. Before start to use the STATE pin, it was working perfectly, I could pair and connect the HC-05 to my android phone and send data from my android phone to the HC-05 module and activate a servo on receiving data…
But since I did my tests with the STATE pin with LED, it doesn’t work anymore.
I’m still using HardwareSerial port.
During setup() method, I start serial com with Serial1.begin(9600);
I can get the state status and wait until the module is connected with my phone… but when setup ends and loop starts, the connexion fails and the module is disconnected from my phone and no way to connect them again…
I’ve tryied with Serial2 and Serial3… It was working one time on Serial3 and after no more. I don’t understand… I don’t know if I damage something and if the problem comes from the arduino HardwareSerial port or from my HC-05 module
Today I’ve read on (Arduino - SoftwareSerial) :
“Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).”
I’ve tryied with couple of pins 10/11 (in this list) and even with some other pin like 3/4, but I can’t get the SoftwareSerial instance working.
In loop, the instance is always not available…
I thougt to try the module on my UNO R3… If I could get it work, I could deduce that the problem comes from my MEGA.
If anybody has an idea to help me, he is welcome…