Arduino Bluetooth Control: Arduino to Arduino Control Via Bluetooth

Published By

When the average person hears the term “Bluetooth,” they may think of an audio headset or speaker. Both devices use Bluetooth technology, but electronics enthusiasts know you can use this short distance communication method for much more than listening to your favorite podcast.

Bluetooth can transmit information in dozens of interesting, innovative ways. One of our favorite uses is pairing an Arduino-based robot or another device to a smartphone for control.

Here’s how to get started with Bluetooth technology for your next Arduino robotics project.

How Does Arduino to Arduino Bluetooth Communication Work?

Using Bluetooth serial signals, your phone controls the Arduino as perfectly as if the two had a hardware connection. Apps like Bluetooth Terminal and ArduinoRC do a good job of making your phone into an interface device in this scenario.

It gets even better. With the proper setup, you can enable two Arduino boards to talk to each other without a computer or phone involved, whatsoever. Arduino to Arduino communication is a little more complex to operate correctly, but it opens up control possibilities considerably.

Step 1: Construct the Circuits

Arduino Nano Bluetooth Fritzing

For this build, you’ll need to construct a pair of identical breadboards, as shown in the Fritzing diagram above. Each of these will use an Arduino Nano to transmit data via an HC-05 Bluetooth Module, allowing its mate to receive this data and respond by flashing the onboard LED. You can send a signal from one Arduino to another via a computer’s serial interface, but the button input provides a shortcut key to wirelessly transmit a character.

Here’s what you need to build your circuits:

  • (2) Arduino Nanos
  • (2) Breadboards
  • (2) HC-05 Bluetooth modules
  • (2) Pushbuttons
  • (2) 1k resistors
  • (2) 2k resistors
  • (2) 20k resistors
  • Jumper Wires
  • (2) mini-USB cables

 

Note: You can substitute many of the parts based on your preferences. For example, an Arduino Uno works just as well as a Nano. Also, you can see in the circuit diagram that we’ve used a voltage divider on the HC-05’s RX pin. HC-05 modules work at 3.3V, so we made this choice to prevent providing too much voltage to that pin.

 

 

Pair Your Arduino Bluetooth Module

Arduino IDE - Bluetooth Communication

Fig 2: By opening a second instance of the Arduino IDE, you can work with two separate boards at the same time.

Once you have your circuit setup completed, you’ll need to set up your two Bluetooth modules to talk to each other. Here’s are the next steps:

  1. Transfer the HC-05_AT_MODE_01 code found here to one of your Arduino boards. Then, put the HC-05 Bluetooth module in AT mode by powering the module on while holding the board’s button down.

  2. The onboard LEDs will blink on and off slowly when it boots. Open a serial monitor in your Arduino IDE; then, type “AT.” If everything is working correctly, you’ll get an “OK” response back from the terminal.

  3. Enter “AT+ROLE=1” to set your HC-05 up as a master; then, AT+CMODE=1 to allow it to pair with any address (module).

  4. Reset the device, and your HC-05—now acting as a master—will pair with the other HC-05, which normally comes setup as a slave module.

If you need to change a master to a slave, interface with it serially as described above and enter AT+ROLE=0. It’s also possible to use an HC-06 module, which only works in slave mode. Use the code linked in step 1 for more details. You can also bind the two modules together using these more advanced instructions.

When you’re working with two Arduino boards like this, it can be extremely helpful to load two Arduino IDE instances (from a shortcut, not using file/new or file/open in the IDE). This allows you to load programs and monitor serial ports simultaneously, making programming and troubleshooting much easier.

Test Your Arduino Bluetooth Control

Arduino to Arduino Bluetooth Communication

Fig 3: A button press turns on the light on another Arduino Nano. Sticky notes signify the serial port used, in order to tell each one apart during programming.

Once you’ve connected your HC-05/Arduino, load the software found here onto each Arduino and follow these steps:

  1. Open a serial monitor for each IDE instance, then experiment with entering “O” and “F” (case sensitive).
  2. You should see the opposite board respond by turning its onboard LED on and off. Press the button. This will send the “B” character to the opposite board, blinking the LED for a short time.
  3. You can also type “B” in the serial monitor to test this functionality.
  4. Once satisfied that things are working correctly, you can disconnect either assembly and plug them in at opposite sides of the room, blinking lights back and forth.

Now that you’ve connected your two Arduino boards, it’s time to get creative. Perhaps you’ve been controlling your robot with a phone over Bluetooth, but you’d rather have a physical keypad. Maybe you’d like to design a custom computer interface that operates remotely. Bluetooth technology can add a new, portable dimension to your robotics projects.

perks 1

Latest News

Sorry, your filter selection returned no results.

We've updated our privacy policy. Please take a moment to review these changes. By clicking I Agree to Arrow Electronics Terms Of Use  and have read and understand the Privacy Policy and Cookie Policy.

Our website places cookies on your device to improve your experience and to improve our site. Read more about the cookies we use and how to disable them here. Cookies and tracking technologies may be used for marketing purposes.
By clicking “Accept”, you are consenting to placement of cookies on your device and to our use of tracking technologies. Click “Read More” below for more information and instructions on how to disable cookies and tracking technologies. While acceptance of cookies and tracking technologies is voluntary, disabling them may result in the website not working properly, and certain advertisements may be less relevant to you.
We respect your privacy. Read our privacy policy here