How to control Arduino with Bluetooth? Learn Bluetooth usage on XIAO BLE (Sense) & Tutorial with Modules and Shields

Wonder how you can pair and control your Arduino Board with Bluetooth? If so, you’re in the right place! In today’s Arduino Bluetooth tutorial, I’ll be guiding you on how you can easily get started!

Alongside the Arduino Bluetooth tutorial, I’ll be providing:

  • Arduino-supported MCU with Bluetooth 5.0 & Bluetooth usage tutorial on XIAO BLE (Sense)
  • A list of Arduino Bluetooth modules for your consideration
  • Arduino Bluetooth projects to get started

Step by Step Arduino Bluetooth Tutorial

Let’s get started right away with the Arduino Bluetooth Tutorial, where I’ll provide all you need to know about pairing Arduino with Bluetooth. Ranging from hardware configurations to programming and using it with your iPhone or Android devices!

1. What do you need for this Arduino Bluetooth Tutorial:

  • You can use the Arduino nano or Arduino Uno for this Bluetooth tutorial

More on the Bluetooth Module used:

Grove – Blueseeed – Dual model (HM13)

Flexible and packed with high Bluetooth transmission speed, the Grove – Blueseeed LE – Dual Model (HM13) uses a CSR dual-mode Bluetooth chip, with the ARM architecture single chip that supports AT instructions.

  • This allows users like yourself to have control over the serial baud rate, equipment name, and pairing password!

You may be wondering; why not the HC-06 or HC-05 Arduino Bluetooth module instead? Well, with the Grove – Blueseeed – Dual Model (HM13), you’re getting the following key advantages:

  • Bluetooth 4.0 BLE rather than Bluetooth V2.0
  • Low power consumption

To not dwell on the tutorial any longer, You can find out more about this Bluetooth Module here!

2. Hardware configurations:

  • Step 1: Connect the Grove – Blueseeed – Dual model (HM13) to a Grove port on the Grove – Base Shield via the Grove cable
  • Step 2: Plug Grove – Base Shield into your Arduino board
  • Step 3: Connect your Arduino to PC via USB cable

3. Understanding the software:

Conventions

  • In EDR mode, only the slave can be configured while either master or slave can be in BLE mode.
  • Factory default setting:
    • EDR Name HMSoft, Slave role, PinCode 1234
    • BLE Name HMSoft, Slave role, PinCode 000000
    • Baud: 115200, N, 8, 1;
  • AT Command format:
    • Uppercase AT command format. string format, without any other symbol. (e.g. \r or \n).
    • Any incorrect command would get no response.

For the full list of AT commands, you can head over to our wiki page!

4. How to program on the Arduino Bluetooth Module

After understanding the software configurations, here’s how to configure Bluetooth with a PC. For hardware connection, do refer to the “Hardware configurations” section. You’ll find that the flashing blue LED on the module illustrates no connection is set up

  • Step 1: Open a serial terminal and set Baud Rate: 115200, Databits: 8, Stopbits: 1, and no flow control like above
  • Step 2: Send “AT” to Bluetooth with the serial terminal to check if you receive an “OK”
    • The Bluetooth only respond AT commands either when:
      • No connection is set up
      • All commands were seen as string and sent out

*You can distinguish the above status in step 2 through LED indications.

It should look something like this after the above steps:

Here are some useful configurations that can be sent:

  1. Test serial connection, send “AT”, will return “OK”.
  2. Restore factory settings, send “AT+RENEW”, return “OK+RENEW”.
  3. Reset baud rate of serial port, send “AT+BAUD2”, return “OK+Set:2”.
  4. Enable authentication, send “AT+AUTH1”, return “OK+Set:1”.
  5. Reset the Bluetooth, send “AT+RESET”, return ”OK+RESET”.
  6. Query firmware version, send “AT+VERS?”, return “OK+Get:HMSoftV217”.
  7. Query MAC of EDR, send “AT+ADDE?”, return “OK+Get:000E0E002074”.
  8. Query MAC of BLE, send “AT+ADDB?”, return “OK+Get:000E0B002074”.
  9. Set the name of EDR, send “AT+NAMEHM-13-EDR”, return “OK+Set:HM-13-EDR”.
  10. Set the name of BLE, send “AT+NAMEHM-13-BLE”, return “OK+Set:HM-13-BLE”.
  11. Set the password of EDR, send “AT+PINE123451”, return “OK+Set:123451”.
  12. Set the password of BLE, send “AT+PINB123451”, return “OK+Set:123451”.
  13. Enable discovery and connectable, send “AT+SCAN0”, return “OK+Set:0”.
  14. Enable notify information of connection, send “AT+NOTI1”, return “OK+Set:1”.
  15. Notify information include address, send “AT+NOTP1”, return “OK+Set:1”.
  16. Enable user key, send “AT+PIO01”, return “OK+Set:1”.
  17. Set to Central mode, send “AT+ROLB1”, return “AT+ROLB1”.
  18. Set to Peripheral mode, send “AT+ROLB0”, return “AT+ROLB0”.

We used two Bluetooth that were connected with the PC, with one set as central while the other as Peripheral. Several seconds later, they find each other, and the LED stops flashing connected!

5. How to pair Arduino Bluetooth Module with iPhone and Andriod

Since the Grove – Blueseeed – Dual model (HM13) have two protocol: Bluetooth EDR (Enhanced Data Rate) and Bluetooth Low Energy (BLE), it can communicate with either Andriod or iPhones!

For this part of the tutorial, we’ll use an iPhone to demonstrate how you can interact with Bluetooth!

*Note: The tutorial below is run on an older version of ios but it should still work the same

  • Step 1: Power the Bluetooth and configure it as a Peripheral role
  • Step 2: Search LightBlue in the App Store and install it
  • Step 3: Launch the app, and connect to “HM-13-BLE”
  • Step 4: Touch on properties and hit “listen for notifications” to enable data receiving
    • There’s a “Hex” key on the top right under properties to change data format as well
  • Step 5: Hit “Write new value” and write some words to start sending data to the PC

With the serial terminal, you can transfer data from the PC to iPhone as well:

6. Bluetooth Data transmission guide between two Arduino boards

Now after all the above steps, are you ready to code? In this final section, we’ll use two Arduino Uno and a pair of Bluetooth modules to get started!

  • Step 1: Set up the connection mentioned in the hardware configurations section
  • Step 2: Assign the Bluetooth to the Central role by modifying the text to “#define MASTER 1”
    • The program of Central and Peripheral use the same code but there’s a difference in the micro define at the beginning of the program
  • Step 3: Follow the flow chart below for initialization of the program

After the initialization, the Central and Peripheral will do different things; Central will send a message to the Peripheral interval and print what’s received from the Peripheral while the Peripheral only responds to the central

  • Step 4: Download the test code and open HM-13_SW.ino with Arduino IDE, compile and download to Arduino Uno
    • Remember to configure the Bluetooth to the different role by modifying the macro at the beginning
  • Step 5: After the program is downloaded, open two serial terminal windows and wait for the Bluetooth connection
    • A connection is indicated by: LEDs on the Bluetooth modules will flash for a few seconds, stop flashing, and kept on

According to the program written, the Central will now send a message to the Peripheral continually and get feedback every time


Arduino-supported MCU with Bluetooth 5.0

As the first wireless product in the Seeed XIAO family, Seeed XIAO BLE & BLE Sense has equipped a powerful Nordic nRF52840 MCU which is designed in a Bluetooth 5.0 module, built around a 32-bit ARM® Cortex™-M4 CPU with Floating-Point Unit(FPU) operating at 64Mhz.

Seeed XIAO BLE nRF52840

-Supports Arduino / MicroPython -Bluetooth5.0 with Onboard Antenna

Seeed XIAO BLE nRF52840 Sense

– TinyML/TensorFlow Lite- IMU / Microphone – Bluetooth5.0

Here are features and specifications:

  • Powerful CPU: Nordic nRF52840, ARM® Cortex™-M4 32-bit processor with FPU operating at 64 MHz
  • Wireless capabilities: Bluetooth 5.0, NFC, and ZigBee module with onboard antenna
  • Ultra-small size: 21 x 17.5mm, Seeed Xiao series classic form-factor for wearable devices
  • Ultra-low sleep power: 5 μA, deep sleep model
  • Battery charging chip: BQ25101 chip supported lithium battery charge management
  • Rich interface: 1x Reset button, Ix UART, 1x IIC, 1x SPI, 1x NFC, 1x SWD, 11x GPIO, 6x ADC, 1x Three-in-one LED,1x User LED
  • Onboard 2 MB flash
  • Onboard PDM microphone and 6-axis IMU (only for XIAO BLE nRF52840 Sense)
  • Single-sided components, surface mounting design
  • Support Arduino/ MicroPython/ CircuitPython

Bluetooth usage tutorial on XIAO BLE (Sense)

If you “originate” from the Arduino ecosystem, you can still use your Arduino IDE and many libraries to program the XIAO BLE (Sense).

XIAO BLE and XIAO BLE Sense both support Bluetooth connectivity. You can check the Bluetooth usage on XIAO BLE (Sense) on the Wiki page.

In this wiki, we will connect the XIAO BLE (Sense) and the smartphone using Bluetooth, and send a message from the phone to turn on/off the built-in red LED on the XIAO BLE (Sense).

If you want to try out more examples you can navigate to File > Examples > INCOMPATIBLE > ArduinoBLE and check all the examples under ArduinoBLE.


List of other recommended Arduino Bluetooth modules

Now that I’ve gone through the above Arduino Bluetooth tutorial, here’s a list of other recommended Arduino Bluetooth modules to try! They are all Grove compatible!

Grove compatible?

Grove system is Seeed’s very own initiative, mainly aimed at helping users like yourself to easily use different modules, sensors, and more through our plug and play system!

  • We currently already hold more than 200 Grove modules, including other modules/sensor types for you to choose from!

Don’t believe how easy pairing is made possible with Grove? Below shows a general Arduino Bluetooth module vs one of our Grove – Bluetooth Modules:

Like how simple and less messy it is?

All you need is a Grove Base Shield alongside your Arduino and you’re good to go!

Ok, now let us start with our list of Arduino Bluetooth Modules and Shields!

1. Bluetooth V4.0 option: Grove – Blueseeed (HM11)

The most complete, most convenient, the most stable of Bluetooth Data transmission, remote control, PIO acquisition module

Master and Slave in one
Remote control without other MCU
The PIO data acquisition without other MCU

The Grove – Blueseeed LE (HM11) is a Low Energy Bluetooth module that utilizes an HM11 with capabilities described as the one above in its datasheet. It can be used with your Arduino board alongside the base shield similar to the earlier tutorial!

With support for a BLE ComAssistant APK, this Bluetooth module can easily communicate with your phone without pairing!

  • It can be set via AT commands directly as well!

Applicable in many conditions such as robot controls or remote control equipment, this Arduino Bluetooth Module is suitable for both beginners and avid tinkerers!

Interested to find out more?

  • We’ve provided an easy and convenient command set alongside an Arduino pairing tutorial on our product page!

2) Grove – Serial Blueseeed (CSR BC417)

Looking for an option that rivals the HC-06 Bluetooth Module? The Grove – Serial Blueseeed (CSR BC417) not only matches the Bluetooth V2.0 and hopping spread spectrum technique, but it supports a higher transmission speed and ease of pairing!

When planning to use the HC-06 Bluetooth Module, you have to go through the tedious way of converting voltages, dealing with voltage dividers and electrical circuits which is not apparent on the Grove – Serial Blueseeed!

  • Thanks to our Grove system, all you need to pair the Grove – Serial Blueseeed with Arduino are plug-and-play Grove cables!

Apart from its ease of pairing, it features a selectable baud rate and a within 30min auto-reconnect when disconnected feature as well!

Interested to find out more?

  • We’ve provided an easy and convenient command set alongside an Arduino pairing tutorial on our product page!

3) Arduino Bluetooth Shield option: Blueseeed Shield V2 (HM01)

Looking for an Arduino Bluetooth shield option instead? Here’s the first recommended option!

Based on the HM01 Bluetooth module, it’s a low cost and easy to use option with Bluetooth 2.0 technology and integrated Grove ports for you to install our plethora of Grove Modules!

Here are its features and specifications:

  • Seeeduino/Arduino compatible
  • Up to 10m communication distance in house without obstacle
  • A full set of configuration commands
  • UART interface (TTL) with programmable baud rate
  • On board PCB Antenna
  • Input Voltage: 3.3V
  • Baudrate: 9600, 19200, 38400, 57600, 115200, 230400, 460800
  • Default Baud rate: 9600, Data bits: 8, Stop bit: 1, Parity: No parity
  • Default PINCODE:”1234”

Interested to find out more?

  • We’ve provided an Arduino and Andriod pairing tutorial on our product page!

4) HM11 Shield Option: Seeed Blueseeed Shield (HM11)

Like what you saw about the HM11 Arduino Bluetooth module earlier with the first recommendation? This is a shield version; more functions, and even easier connectivity!

Since it’s packed with exactly what you’ll get from the HM11 module; Bluetooth V4.0, 2.4Ghz band, etc., I’ll just cover its specialties!

For that, we’ll take a look into its hardware:

  • HM-11 module
  • Signal lamp: Lamp will blink if BLE is not connected, but the lamp will keep lighting after BLE has been connected
  • Grove connectors: Two Grove connectors for convenient plugging of Grove products onto the board
  • Hard or Softserial port: You can choose two of seven digital pins as the communication channel, just plug the jumpers into the headers
  • Reserved pinouts from HM-11: There are reserved pinouts from the HM-11 module, such as CTS1, RTS1, and PIO2, etc.
  • Reset Button: For reset of the shield, doesn’t affect the mainboard even if its plugged in

Note: This shield is only best compatible with the following boards:

  • Arduino Uno/Seeeduino v4.2
  • Arduino Leonardo/Seeeduino Lite

Interested to find out more?


Arduino Bluetooth Projects

To end today’s guide to Arduino Bluetooth modules, here are two simple Arduino Bluetooth projects you can get started!

Control your robotic car through Bluetooth

Robotics and Arduino is a fun and interesting hobby which is very commonly seen nowadays. With this project, you can experience that through the help of Bluetooth!

Here’s what you need:

Hardware components:

Software apps and other services:

  • Arduino IDE

Interested to find out more? Check out the full tutorial by Kevin-Lee on Seeed Community Hub!

Fun, Little, Scary Horror Doll

Want to pull a little prank on someone and get their hilarious reaction? This project is the one for you!

It uses a controller to small doll eyes emitting light of terror. It can swing and turn hands, head, and emits a scream of terror. Mount a PIR sensor above and when someone is close to it, it’ll jump out to scare them!

Here’s what you need:

Hardware components:

This project uses Wio Link, however, you can still use an Arduino board with a Grove – Base Shield

Interested to find out more? Check out the full tutorial by shijian.fang on Seeed Community Hub!

Summary

That’s all for today on Arduino Bluetooth. I hope with today’s blog, you get a deeper understanding of how to pair Arduino with Bluetooth!

To help you easily get started with your next Arduino Bluetooth project, do consider the list of Arduino Bluetooth modules and shields covered today. And consider the newly launched powerful and small size XIAO BLE (Sense) MCU with Bluetooth 5.0 to realize more project ideas!

About Author

Calendar

January 2020
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031