0

members

Easy Basics: Project 028c Bluetooth 4.0 AT-09 BLE module

of Acoptex.com in UNO

Basics: Project 028c

Project name: Bluetooth 4.0 AT-09 BLE module

Tags: Arduino, Arduino Uno, Bluetooth module, Bluetooth 4.0, Bluetooth Low Energy, Bluetooth Classic, Bluetooth 4.0 Low Energy, Wibree, BLE.  BR/EDR, basic rate/enhanced data rate, HM-10 BLE module, AT-09 BLE module, AT commands, TI  CC2540, CC2541, iBeacon, CC41-A, BLE-CC41-A

Attachments: AT09BLEATcommssketch, BLEmoduleIdentificationsketch

In this project, you needed these parts :

1.Aruduino Uno R3 (you can also use the other version of Arduino)

2.Arduino IDE ( you can download it from here  )

3.Jumper cables

4. Breadboard

5. Bluetooth 4.0 AT-09 BLE module  1 pc

6. Resistor 2 pcs (1pc 1 KOhm and 1 pc 2 KOhm)

7. USB to TTL serial converter 1 pc

8. USB mini cable 1 pc (optional)

General

We will learn about Bluetooth 4.0 AT-09 BLE module, how to connect it to Arduino board, how to communicate with it using AT commands.

Understanding the USB to TTL converter

You can read more about them here.

Understanding the bluetooth module BLE

Bluetooth [WikiPedia] is a wireless technology standard for exchanging data over short distances (using short-wavelength UHF radio waves in the ISM band from 2.4 to 2.485 GHz) from fixed and mobile devices, and building personal area networks (PANs). Range is approximately 10 Meters (30 feet).

Bluetooth Low Energy (Bluetooth LE, BLE, formerly marketed as Bluetooth Smart) is a wireless personal area network technology designed and marketed by the Bluetooth Special Interest Group (Bluetooth SIG) aimed at novel applications in the healthcare, fitness, beacons, security, and home entertainment industries. Compared to Classic Bluetooth, Bluetooth Low Energy is intended to provide considerably reduced power consumption and cost while maintaining a similar communication range.

Mobile operating systems including iOS, Android, Windows Phone and BlackBerry, as well as macOS, Linux, Windows 8 and Windows 10, natively support Bluetooth Low Energy. The Bluetooth SIG predicts that by 2018 more than 90 percent of Bluetooth-enabled smartphones will support Bluetooth Low Energy.

Bluetooth Low Energy is not backward-compatible with the previous (often called "Classic") Bluetooth protocol. The Bluetooth 4.0 specification permits devices to implement either or both of the LE and Classic systems.

Bluetooth Low Energy uses the same 2.4 GHz radio frequencies as Classic Bluetooth, which allows dual-mode devices to share a single radio antenna. LE does, however, use a simpler modulation system.

Current mobile devices are commonly released with hardware and software support for both Classic Bluetooth and the Bluetooth Low Energy.

Operating systems:

  • iOS 5 and later - Apple iOS has supported BLE since the iPhone 4S exists.
  • Windows Phone 8.1
  • Windows 8 and later - supports Bluetooth 4.0 as a dual mode device (classic Bluetooth and Bluetooth Low Energy)
  • Android 4.3 and higher could support BLE. Not all Android devices on 4.3 are able to support BLE, just support classic Bluetooth only.
  • BlackBerry 10
  • Linux 3.4 and later through BlueZ 5.0. On Linux, the protocol stack BlueZ got an update to support BLE as well. The update does not mean that all Linux devices will support BLE now.
  • Unison OS 5.2

Bluetooth Low Energy technology operates in the same spectrum range (the 2.400–2.4835 GHz ISM band) as Classic Bluetooth technology, but uses a different set of channels. Instead of the Classic Bluetooth 79 1-MHz channels, Bluetooth Low Energy has 40 2-MHz channels. Within a channel, data is transmitted using Gaussian frequency shift modulation, similar to Classic Bluetooth's Basic Rate scheme. The bit rate is 1 Mbit/s, and the maximum transmit power is 10 mW.

BLE has a very fast time for pairing and reconnecting. It needs 6 ms and classic Bluetooth up to 6 seconds! Older BT chips will be too slow, thus unable to support the 6 ms BLE.

Bluetooth Low Energy was previously called Bluetooth Ultra Low Power, and in early 2001, was WiBree. “Wi” for wireless, and “Bree” for Bree in the Lord of the Rings. Bree was the town where the two major roads, the Great East Road and Greenway, crossed. Bluetooth Low Energy is an "always off" technology. It transmits short packages of data and is not able to support audio streaming. It is perfect for devices like a heart rate belt, mouse or keypad.

Bluetooth Low Energy is a part of Bluetooth 4.0. A dual mode device like a smartphone is able to support classic Bluetooth (BT) and Bluetooth Low Energy at the same time. Your smartphone could be connected to a Bluetooth 2.1 headset and stream audio, and at the same time be connected to a heart rate belt or other sensors on your bicycle.

Single mode devices like the heart rate belt will run in the Bluetooth Low Energy (BLE) peripheral mode and the smartphone will run in the central mode. In the classic Bluetooth this is still called master and slave.

In the new specification, BT 4.1 we have the hub. You will find such a hub in a smart watch for sports. The watch will work in the central mode in direction to the heart rate belt and other senors on the bike and in peripheral mode in direction to the smartphone. Professionals will not carry the heavy smartphone while riding the bike and will collect the data in smart watch. The watch will work in the peripheral mode during the transfer of the collected data to the smartphone. Often the data will be forwarded to a tablet or laptop. 

BLE 4.1 vs. BLE 4.2 - New Features and Advantages

Bluetooth 4.2 is an important update to the Bluetooth Core Specification with many new features and benefits designed specifically for Bluetooth Smart technology, and advantages when comparing Bluetooth 4.2 vs. Bluetooth 4.1 (also known as Bluetooth Low Energy or Bluetooth Smart).

Bluetooth 4.2 introduces several new features that improve speed and privacy over Bluetooth 4.1 but the main advantage is allowing chips to use Bluetooth over Internet Protocol version 6 (IPv6) for direct Internet access. With this, the possibilities expand beyond thoseof current designs and markets to include any type of Bluetooth device requiring speed and security in the IoT.

Why use BLE 4.2 instead of BLE 4.1? The Bluetooth SIG recommends implementing Bluetooth 4.2 in all new designs and requires the same qualification process as all other Bluetooth designs. Devices using Bluetooth Smart will be backward compatible with Bluetooth 4.0 or 4.1 devices that also implement the low energy features. Devices implementing the (BR/EDR) Core Configuration will be backward compatible to all adopted Bluetooth Core versions beginning with 1.1 that also implement Bluetooth BR/EDR.

Key Bluetooth 4.2 Features Not Available with Bluetooth 4.1:

IoT Capabilities:

  • Low-power IP (IPv6/6LoWPAN)
  • Bluetooth Smart Internet Gateways (GATT)

With BLE 4.2 Bluetooth Smart sensors can transmit data over the internet.

 Security:

  • LE Privacy 1.2
  • LE Secure Connections

With new, more power efficient and highly secure features, BLE 4.2 provides additional benefits allowing only trusted owners to track device location and confidently pair devices.  

Speed:

  • 250% Faster
  • 10x More Capacity

Compared to previous versions, BLE 4.2 enables 250% faster and more reliable over-the-air data transmission and 10x more packet capacity.

Designing with BLE 4.2 requires no mandatory features but, similar to previous versions, manufacturers are required to implement all errata applied in order to comply with the BLE 4.2 specifications.

BLE modules

There are 2 ways BLE devices can talk to each other:

  • Broadcaster + Observer
  • Central + Peripheral

 With Broadcaster + Observer there isn’t a standard connection, the Broadcaster, usually some kind of sensor, sends out periodic signals (advertising packets) which the Observer listens for. The Broadcaster does not normally know if anything is listening or not.

The Central + Peripheral scenario is more like (but not exactly the same) as the classic connection. When the Central (master) device finds a Peripheral (slave) device it wants to connect to it initiates a connection and takes on the master role managing the connection and timings.

There are several types of BLE modules: HM-10, AT-09, BT05-A mini, HT-11 and so on.

Quite a lot BLE modules use the Texas Instruments (TI) CC2541 chip. This is the large black square in the middle of the module as can be seen in the photo above. Online resources suggest that the CC2540 chip, that is similar, can also be used. This chip is programmed with matching firmware and it then implements the logical layers needed for the BLE protocol. The chip operates at voltages between 2V and 3.6V.

The CC2541 chip needs some passive components to work, such as oscillators, capacitors, resistors and an antenna. Those are provided by daughter board. The daughter board is soldered to the main board around the perimeter, via arc-like soldering pins.

The daughter board  - HM-10 module, made by Chinese “JNHuaMao Technology Company”, hence the HM initials. JNHuaMao makes different kinds of Bluetooth modules. In this case they designed the board and wrote a firmware for the TI chip to implement the needed functionality. The firmware determines the interface that will be used to control the module over serial connection.

Another Chinese company, “Bolutek Technology Co., Ltd“, decided to make a similar board. Their model is called CC41-A (CC41 from now on). It uses the same TI chip and similar board design (both are based on TI’s reference design for the chip). One difference that is easy to spot is that CC41 only has one oscillator where HM-10 has two. This is ok as one of the oscillators is optional per CC2541 specifications. 

As can be seen, the daughter boards are very similar. The pins are also compatible. Regardless of whether Bolutek copied the board design or made one of their own, many sellers were selling the CC41 module by using the HM-10 module name. This led to confusion and caused JNHuaMao to launch a campaign against clones posting various accusations. The bottom line is that these two daughter boards have the same TI chip, very similar board layout but different firmware.

Voltage-wise, the daughter boards have no voltage regulators and expect to be powered by 3.3V per chip specifications. Similarly, the serial logic expects 3.3V TTL levels.

You can find specification of AT-09 BLE (CC41-A) module here.

You can also identify your BLE module by uploading to Arduino Uno this sketch. The wiring is the same as for using Arduino Uno board (see below). See more information here.

Signals and connections of the bluetooth 4.0 AT-09 BLE module 

The AT-09 is a module that contains a BLE chip (a CC2540/CC2541). This module allows to perform serial communication with the BLE chip thanks to an Rx and a Tx pin. This module is also very similar to the HM-10 module and is also compatible with it. 

Features:

  • Bluetooth protocol: Bluetooth Specification V4.0 BLE, no byte limit for sending and receiving, 110m ultra-long-distance communication in an open environment and iphone4s 
  • Operating frequency: 2.4GHz ISM band Modulation method: GFSK (Gaussian Frequency Shift Keying) 
  • Sensitivity: ≤-84dBm at 0.1% BER 
  • Transmission rate: Asynchronous: 6 kbps Synchronous: 6 kbps 
  • Security features: Authentication and encryption 
  • Support Services: Central & Peripheral UUID FFE0, FFE1 
  • Power consumption: Under the automatic sleep mode, the standby current is 400uA~1.5mA, and 8.5mA during transmission. 
  • Power Supply: +3.3VDC 50mA 
  • Appearance size: 26.9mm x 13mm x 2.2mm 
  • Bluetooth Certification: ROHS REACH BQB

Pins:

  • VCC: +3.3V Power
  • GND: Ground pin
  • TXD: Transmit Serial Data 
  • RXD: Receive Serial Data
  • STATE: Allows you to know current module connection state. The STATE pin is normally LOW and goes HIGH when the device is connected.
  • EN (able): Allows you to enable or disable the module

Breakout board: ZS-040

BLE chip: CC2540 or CC2541 (we had CC2541)

Bluetooth name: We had HC-05 initially but after AT command "AT+DEFAULT" it was automatically changed to CC41-A. Of course you can set any name for your module.

AT command mode

AT command mode allows you to interrogate the Bluetooth module and to change some of the settings; things like the name, the baud rate, whether or not it operates in slave mode or master mode.

 

  • CC-41A commands are case insensitive, so ‘AT’ and ‘at’ both work
  • CC-41A commands needs to be terminated with \r \n
  • CC-41A commands does not entertain ‘?’
  • CC-41A default boots to slave mode (Role0)

 

Firmware Bolutek

V3.0.6,Bluetooth V4.0 LE

You can find the list of AT commands for SLAVE here and list for AT commands for MASTER here. You can also get it with AT command - "AT+HELP". Description of commands you can find here.

Default settings: 9600 baud rate, PIN - 000000.

Firmware differences

Unfortunately the HM-10 AT commands are different from AT-09 (CC41-A) AT commands. Specifically the CC41-A is less documented and the command set and available functionality are poorer.

Main differences include:

  • Case-sensitivity.
  • End-of-line termination, with HM-10 expecting no new-line or carriage-return while the CC41 expects both.
  • Different command names, such as VERS vs VERSION.
  • Different command syntax, such as using a ‘?’ for queries or not using any special character.
  • etc.

Connecting to your Bluetooth 4.0 AT-09 BLE module (CC41-A) via a phone

If you whipped out your phone to test which BLE module you have earlier, maybe you tried to pair it to see what would happen, and were suprised when it rejected your connection. Maybe you thought it didn't work and were very sad. Guess what, though? Your Bluetooth 4.0 AT-09 BLE module (CC41-A) is working!

You just need an application to connect to it.

You can download Android based applications from Google play:

  • B-BLE (BLE4.0 Scan)
  • BLE Scanner
  • HM BLE Terminal
  • Bluetooth spp tools pro

You can download IOS based applications from Apple store:

  • BlueCap
  • BLE scanner
  • BLE Nearby
  • BLE Finder

Build the circuit

There are a couple of common ways to connect the Bluetooth 4.0 AT-09 BLE module to a PC/laptop:

1. Using USB to TTL converter with or without DTR Pin


2. Using Arduino Uno board


Step by Step instruction

1. Using USB to TTL converter with or without DTR Pin

For using this USB to UART Converter you need a software tool. Most of the development tools like MikroC Pro, Arduino has a UART Tool along with it. You can use different software tools: TerminalUSR-TCP232-Test V1.4AiThinker_Serial_Tool_V1.2.3cooltermsscom3.2 , KiTTYputty,tera termHMComAssistant and so on. We recommend you to use AiThinker_Serial_Tool_V1.2.3 or sscom3.2, as you can save your AT commands and it's very easy to use.

  1. Do wiring.
  2. Connect USB to TTL converter (UART converter) to your PC/Laptop USB port.
  3. Download and install the driver for USB to TTL converter (UART converter). See more information about it here.
  4. Download and open software tool. 
  5. Change the COM port (Serial port). Check in your Device manager -> Ports (COM & LPT) which USB port your UART converter/Arduino Uno board connected to. 
  6. Set the baud rate 9600, data bits 8, parity bits none,stop bits one.
  7. Press Open serial button (We use AiThinker_Serial_Tool_V1.2.3 here)
  8. First you need to check if AT commands are working - enter “AT” and press  Send button.This would print "OK" which signifies of working connection and operation of the module.
  9. Check the firmware version - enter “AT+VERSION” and press button Send. Returns the current version of the firmvare: “+VERSION=Firmware V3.0.6, Bluetooth V4.0 LE”
  10. Enter “AT+STATE” and press button Send. Returns the current state of the module: “+STATE=2 OK”. According to AT commands list - INQUIRING.
  11. Enter “AT+ROLE” and press button Send. The possible values are ; 0 – Peripheral, 1 – Central. Returns “+ROLE:0”. To change to Central Mode, enter “AT+ROLE1” and press button Send. Will return “+ROLE=1 OK”. 
  12. Enter “AT+NAME” and press button Send. Returns "+NAME=CC41-A". To change the name enter “AT+NAMEnewname” and press Send button. Returns “+NAME:newname OK” (or something similar depending what your module is called)
  13. Enter “AT+HELP” and press button Send. Returns the list all the AT commands. 
  14. Enter “AT+RESET” and press button Send. Software reboot will be done.
  15. Enter “AT+ADDR” and press button Send. You will get local bluetooth address. For example: "+ADDR=00:15:85:10:82:A2".
  16. You can get or set baud rate.Enter “AT+BAUD” and press button Send.  Returns: "+BAUD=4". To change baud rate use "AT+BAUDn" n=1 for 1200, n=2 for 2400, n=3 for 4800, n=4 for 9600 (default), n=5 for 19200, n=6 for 38400, n=7 for 57600, n=8 for 115200, to enable, reset the module with "AT+RESET".
  17. You can get or set pin code for pairing. Enter “AT+PIN” and press button Send. Returns your PIN: "+PIN=000000". To change PIN enter "AT+PIN123456" and press button Send. PIN changed to 123456 now, reset the module with "AT+RESET".

2. Using Arduino Uno board

  1. Do wiring.
  2. Open Arduino IDE.
  3. Plug your Adruino Uno board into your PC and select the correct board and com port. 
  4. Open up serial monitor and set your baud to 9600 baud. The AT-09 BLE module expects commands to include a carriage return and newline characters (\r\n). You can add these automatically in the serial monitor by selecting “Both NL & CR” at the bottom of the window. You can also enter them manually in the form AT\r\n. If you forget to add carriage return and newline characters the module will not respond.
  5. Power off the bluetooth module before verifying and uploading the sketch (attached on the begining of the project description).
  6. Verify and upload the sketch to your Adruino Uno board.
  7. We used the software serial on Arduino board pins 2 and 3 to talk to the AT-09 BLE module. This means that we can still use the hardware serial to talk to the serial monitor on a host computer.
  8. First you need to check if AT commands are working - enter “AT” and press  Send button.This would print "OK" which signifies of working connection and operation of the module.
  9. Check the firmware version - enter “AT+VERSION” and press button Send. Returns the current version of the firmvare: “+VERSION=Firmware V3.0.6, Bluetooth V4.0 LE”
  10. Enter “AT+STATE” and press button Send. Returns the current state of the module: “+STATE=2 OK”. According to AT commands list - INQUIRING.
  11. Enter “AT+ROLE” and press button Send. The possible values are ; 0 – Peripheral, 1 – Central. Returns “+ROLE:0”. To change to Central Mode, enter “AT+ROLE1” and press button Send. Will return “+ROLE=1 OK”. 
  12. Enter “AT+NAME” and press button Send. Returns "+NAME=CC41-A". To change the name enter “AT+NAMEnewname” and press Send button. Returns “+NAME:newname OK” (or something similar depending what your module is called)
  13. Enter “AT+HELP” and press button Send. Returns the list all the AT commands. 
  14. Enter “AT+RESET” and press button Send. Software reboot will be done.
  15. Enter “AT+ADDR” and press button Send. You will get local bluetooth address. For example: "+ADDR=00:15:85:10:82:A2".
  16. You can get or set baud rate.Enter “AT+BAUD” and press button Send.  Returns: "+BAUD=4". To change baud rate use "AT+BAUDnn=1 for 1200, n=2 for 2400, n=3 for 4800, n=4 for 9600 (default), n=5 for 19200, n=6 for 38400, n=7 for 57600, n=8 for 115200, to enable, reset the module with "AT+RESET".
  17. You can get or set pin code for pairing. Enter “AT+PIN” and press button Send. Returns your PIN: "+PIN=000000". To change PIN enter "AT+PIN123456" and press button Send. PIN changed to 123456 now, reset the module with "AT+RESET".

Summary

We have learnt about Bluetooth 4.0 AT-09 BLE module, how to connect it to Arduino board, how to communicate with it using AT commands.

Library:

  • SoftwareSerial library included in Arduino IDE. The version of SoftwareSerial included in Arduino IDE 1.0 and later is based on the NewSoftSerial library by Mikal Hart. You can also read about it here.  

Sketch:

  • See attachments on the begining of this project description. 


Other projects of Acoptex.com
Easy Basics: Project 105a SIM900A GSM GPRS mini module of Acoptex.com in NANO 28-11-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 03-04-2018
Viewed: 8080 times