modifications to the boards are done, they now have to be setup properly.
My code is divided in 3 parts under main(), selectable by a definition. Define
either SETUP , SLAVE or MASTER in order to compile the board. The Bluetooth
modules are setup using the keypad box , using the SETUP
You need to modify
the code to fit your boards. The steps needed are :
the "password command" to the Bluetooth password you want to use.
the "bind command" to bind to the address of your current modules. This is
different for each module.
the project with SETUP defined.
- Make a
resistor bridge with 3 x 1k resistors.
- Flash the
keypad box with the compiled SETUP hex file.
the KEY pin to your resistor bridge to provide 3.3v
- POWER ON
the keypad box.
- Press the
key matching the command you want to use.
I used my
logic analyzer to view the module's response to my commands , but it is not absolutely
necessary. Since the keypad box doesn't have a display, there is no output to
tell you if the command was received properly. The HC-05 firmware has 2
LEDs to show its status, and they are on a different pin than the HC-06
firmware, so the breakout board is not wired properly. I did not modify
the board to have the LED working because I do not need it in my project. I did
use my logic probe to check the status of pin 31 to confirm the module was in
AT mode. AT mode is required to setup the modules. While in this mode , the
module will not output the data it receives , but instead it uses it to setup
some parameters for its normal working mode.
2 modules needed , the master module and the slave module. You cannot connect 2
slave modules together, hence the reason why the HC-06 firmware was not good
for my project. In this project , the modules are bound to each other. No other
devices can connect to them and send data. To bind the modules, you need
the other module's address. There are a few ways you can acquire the addresses.
The easiest is simply by powering your module and trying to connect to it to
see its address. I used my android phone with blueterm+ and was able to quickly
see the addresses. Using your PC to connect to it will also work. The
default password is 1234 of course. If you have a logic analyzer you can use it
to read the response of the module when you press key 7 on the keypad flashed
with the SETUP program. The baud rate for the AT mode is always 38400 8N1. You
can also get the addresses when you are flashing the HC-05 firmware,
One of my
module address is : 2014 04 159158 but when you send the command AT+ADDR? The
modules responds 2014 4 159158 , dropping the lead 0 of the 2nd part of the
to change the code for keys 2 and 3 to reflect the module's addresses with the
address corresponding to your module. According to the datasheet the format is
Here is the code for key 2, which is used to bind the slave module to the master module's address :
if (buffer == 2) // Bind to master
tot_overflow = 0;
Read more »
- Key 2 is used to program the slave
module to be bound to the master module, so it contains the master module's
- Key 3 is used to program the
master module to be bound to the slave module, so...