Hi,
I am trying to pair two arduinos nano with 2 hc05 devices. I want both arduinos to communicate without any external manipulation.
I have set both arduinos in AT mode and I put Slave / Master configurations.
I did the following configurations:
AT+ROLE and AT+CMODE with their respective values on slave/master then I binded the master one to the slave address. Same bluetooth device, same baud rate.
PS: I don't know why, I get an address like this for my devices XXXX:XX:XXX basically, the LAP part of the address has only 3 digit instead of 6, I added 3 zeros to make it work on AT+BIND.
When I power up both arduinos, they start blinking at fast rate then they blink twice every ~2 seconds at the same time, I suppose it means they are both connected.
I connected both RX and TX to their SerialSoftware pins
if (BTSerial.available()
{
BTSerial.write("slave\n");
Serial.write(BTSerial.read());
}
I put this code on both arduinos but BTSerial.available() doesn't seem get a value other than 0.
Any idea of how I can fix this ? Maybe I forgot something or I did something wrong, thanks.
is there a computer involved anywhere ?
please show the connections you made with all devices involved.
please post the full code of what you are testing with.
I only use computer to read communication between both devices on my Serial monitor.
SLAVE code
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(A3, A4); // CONNECT BT RX PIN TO ARDUINO 11 PIN | CONNECT BT TX PIN TO ARDUINO 10 PIN
void setup()
{
pinMode(A2, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
digitalWrite(A2, HIGH);
Serial.begin(9600);
BTSerial.begin(38400); // HC-05 default speed in AT command more
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
BTSerial.write("slave\n");
if (BTSerial.available()){
Serial.write(BTSerial.read());
}
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
BTSerial.write(Serial.read());
}
MASTER code
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(A6, A5); // CONNECT BT RX PIN TO ARDUINO 11 PIN | CONNECT BT TX PIN TO ARDUINO 10 PIN
void setup()
{
pinMode(A4, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
digitalWrite(A4, HIGH);
Serial.begin(9600);
BTSerial.begin(38400); // HC-05 default speed in AT command more
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
BTSerial.write("MASTER\n");
if (BTSerial.available()){
BTSerial.write("MASTER\n");
Serial.write(BTSerial.read());
Serial.write(BTSerial.available());
}
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
BTSerial.write(Serial.read());
}
Devices :
Devices Arduino Nano - Bluetooth NANO, Wiring for both slave & master shown in code ( SoftwareSerial BTSerial() )
do you have a smartphone with Bluetooth capability ?
(and an app for Serial communication ? Search "Bluetooth Terminal")
can you confirm that ONE pair of Arduino-HC05 are working/communicating ?
Wiring for both slave & master shown in code
really ?
it looks confusing to me; 
SoftwareSerial BTSerial(A6, A5); // CONNECT BT RX PIN TO ARDUINO 11 PIN | CONNECT BT TX PIN TO ARDUINO 10 PIN
oh, another thing - A6 can NOT be used as a digital pin.
I'm trying to find out if they truly communicate or not, I can only say that I binded the master one to the slave address, that both blink at the same time twice every 2 seconds when I power up both. I also checked the devices version, same one.
Is it only A6 or all the analog inputs that can't be used for this task ?
For the wiring, I chose analog pins for a matter of place for other devices that I will add later, I will try with digital pins.
RX & TX pins are connected following the code description, GND and Vcc connected to arduino relative pins and I added the hc05 EN pin to communicate through AT mode.
Kinda unnusual, but I don't have a working smartphone, I'm using the IDE monitor to test whether it works or not.
I tested the bluetooth communication between my PC and an arduino before, it worked just fine.
I will update if changing wires makes a difference.
ZaoualiWork:
Is it only A6 or all the analog inputs that can't be used for this task ?
only A6 & A7 on the Nano - they can only be used for analogRead()
ZaoualiWork:
I tested the bluetooth communication between my PC and an arduino before, it worked just fine.
okay - if your computer has BT then at least confirm Serial communication between Arduino+HC05 and the computer (through a Terminal program).