Introduction: How to Create an Arduino Compatible Bluetooth 4.0 Module

Picture of How to Create an Arduino Compatible Bluetooth 4.0 Module

UPDATE: Lets Make Robots, my home digital hackerspace, was purchased by RobotShop. I don't want to go into, but the new owners banned myself and most of the veteran members. That stated, most of the links there will be broken. Luckily, I was able to make a copy of my content (the reason they banned me?) and moved it to a Github site.

UPDATE:

For Windows users I wrote a GUI terminal app for changing the HM-1X's settings, you can find it here,

HM-1X Aid


UPDATE: I published a free iOS serial terminal app for a client, but it works well for other applications.

I've also created a walkthrough on how to write an iOS app for the HM-10.

UPDATE: I had some people mention I screwed-up and posted the wrong breakout board. For that I'm sorry, please email me and we'll talk.

I have corrected the link with a new version of the breakout that should correct "all" issues (working RX/TX LEDs).

But I'll add, please use this Instructable at your own risk. I'm a Psychology major :P

I had been looking for a cheap alternative to some of the Arduino Bluetooth devices I'd seen, which in my opinion are overpriced.

Redbear's Mini: $39.95 (Note: This is a uC and BLE combo).
Redbear's Uno Shield: $29.95
BLEDuino: $19.95 (if part of Kickstarter)
Bluegiga Shield: $69.95

After seeing these, I thought I'd try to make one; this is my bumbling process for making an Arduino Bluetooth 4.0 device at home:

I highly recommend reading details about the HM-10 and interfacing with it:

Variants of the PCB can be found here; though, many are untested.


This is a fellow to keep an eye on. He is working on creating open-source firmware to replace the HM-10 firmware.

Step 1: How to Create an Arduino Compatible Bluetooth 4.0 Module

This guide is intended to show how to interface one of these HM-10 Bluetooth Low Energy modules to an Arduino.

I started working with these little Bluetooth modules in attempt to add Bluetooth 4.0 to my robot projects.

 

Step 2: Arduino BT 4.0 Module -- Overview

Picture of Arduino BT 4.0 Module -- Overview

There are a few bits of information I'd like to offer upfront. First, I'm a homeless outreach worker; I'm not an engineer of any sort. So, there will be mistakes in my design.

Second, although I was able to interface these BT 4.0 modules with an Arduino, I've not fully interfaced them with a PC or mobile device. This is due to the BT 4.0 software stacks being very different than earlier versions of Bluetooth (<3.0).

Still, I've shown that is possible to make this bridge using the Lightblue app for iOS.



It's also one reason I write. I'm too cheap to pay to develop an iOS app to interface with these modules and I don't own an Android device with BT 4.0. So, I'm hoping someone in the crowd will let me know when they've finished the software needed. :)

I will state that Jellybean 4.3 offers a Bluetooth 4.0 API.

Now, price is a big concern with me, so I'll givet the breakdown up front:

The bill-of-materials (BOM):
1.HM-10 x 1
2.BS1138 x 1
3.0603 LEDs x 3 (best if assorted colors)
4.0805 Resistors 10k x 3
5.0805 Resistor 20k x 1
6.0805 Resistors 470 x 3

7.0805 1uF capacitor x 2

8.(OPTIONAL) SOT-23-5 LDO Voltage Regulator (it doesn't make sense to use this, but I put the option on the board just in case. I'll explain).

This should bring your total just under $10 USD. And the boards I purchased from OSHPark, which come out to be less than $2 a piece. Therefore, I figure around $12 for a BT 4.0 module.

I felt this price was better than some of the options available:

Redbear's Mini: $39.95 (Note: This is a uC and BLE combo).
Redbear's Uno Shield: $29.95
BLEDuino: $19.95 (if part of Kickstarter)
Bluegiga Shield: $69.95

Step 3: Arduino BT 4.0 Module -- Order the Parts

Picture of Arduino BT 4.0 Module -- Order the Parts

Alright, if I've not scared you away then the first thing to do is select a layout.

I designed two different layouts, a Xbee footprint and a full breakout, which will fit nicely into a breadboard.


Breadboard breakout (v.9.9). $6.80 for 3 boards.

Order the components listed

The bill-of-materials (BOM):

  1. HM-10 x 1
  2. BSS138 x 1
  3. 0603 LEDs x 3 (2 x Green, 1 x any other color)
  4. 0805 Resistors 10k x 3
  5. 0805 Resistors 20k x 1
  6. 0805 Resistors 470 x 2
  7. 0805 1uF capacitor x 2
  8. (OPTIONAL) SOT-23-5 LDO Voltage Regulator (it doesn't make sense to use this, but I put the option on the board just in case. I'll explain).


The total time on the boards is ~16 days.

If you are interested in my other HM-10 boards (like the ones that don't work). I've a lot of variants on the Github.

Step 4: Arduino BT 4.0 Module -- Soldering

Picture of Arduino BT 4.0 Module -- Soldering

A few notes on soldering the SMD pieces:

DON'T BE SCARED. It's really not that hard.
1. There are three musts to SMD, at least from my perspective: a small iron tip, precision tweezers, thread-like solder (at least .022" solder wire).

2. Other important soldering tools: A wet sponge and brass-ballwill keep your fine soldering tip fine. Sponge the solder tip, then run it through the brass-ball after each component to prevent build-up.

3. To speak blasphemy: Flux is ok, but I find the tweezers often take place of the flux.

4. Practice using both hands during soldering. Tweezers in one and solder-iron in the other.

5. The drag-to-solder method will be what you use on this board.

6. Patience.

7. Have a cup of wine. Alcohol reduces performance on most skills, except, skills that involve fine motor control, there is a marked 20% improvement. Though, this relationship is curve-linear. One glass is good, two glasses and you'll smoke something.

8. Honor the age old tradition: Don't solder in your boxers.

Here is a video of me soldering the first iteration of the breakout board.

Step 5: Arduino BT 4.0 Module -- Design Notes

Picture of Arduino BT 4.0 Module -- Design Notes

Ok. As I'm sure it is apparent by now, I'm all hack.

The interface between the HM-10 and the Arduino are really a pure steal from Sparkfun's posted schematic on level conversion. I believe it actually comes from the NXP application note here.

As for the linear regulator: I added this option to the board in case there is no pre-regulated 3.3v source, but it inherently contradicts the purpose of using a Bluetooth 4.0 module: extremely low power consumption. I tried to get a reading on the milliamps the HM-10 pulls, but my multi-meter only goes to the tenths (ma) and the module wouldn't show at all, even during active use. And as many already know, the linear regulator is extremely inefficient. So, it's much better to solder the jumper bypassing he regulator and leave it un-populated.



Step 6: Arduino BT 4.0 Module -- Firmware Master

Picture of Arduino BT 4.0 Module -- Firmware Master

The hookup is pretty simple.

    BT-3.3v <---> 3.3v
    BT-RX <---> FTDI-TX
    BT-TX <---> FTDI-RX
    BT-IO1 <--> LED <--> 220 Res. <--> GND
    BT-GND <---> FTDI GND

(For the 3.3v I used an external regulator and tied my grounds).

A few notes, the RX and TX lines are translated from 3.3v to 5v by way of a voltage divider and the BS1138.  All other lines will die at >3.3v. 

Now, as I've stated, I'm connecting two modules together, so you have to set one module as the slave.

I used RealTerm to access the HM-10s firmware via AT commands (full list in the manual).

    Under the "Port" tab
    Baud: 9600
    Parity: None
    Data Bits: 8
    Stop Bits: 1
    Hardware Flow Control: RTS/CTS
    Software Flow Control: Receive--Yes, Transmit--Yes
    Under the "Echo Port" tab
    Echo On: Yes
    Monitor: Yes

Then, under the "Send" tab type in AT commands and hit "Send ASCII":

   Send: AT
   Response: OK

Now, setup one unit as the slave (they default as master).

   Send: AT+ROLE1
   Response: OK+Role:Slave

That should be all we need to do to setup the connection.  Now, whenever they power on they will automatically try to mate.  You'll know if they are connected if the LED goes from blinking to solid.

Step 7: Arduino BT 4.0 Module -- Firmware Slave

Picture of Arduino BT 4.0 Module -- Firmware Slave

BT-3.3v <---> Arduino 3.3
BT-RX <---> Arduino TX
BT-TX <---> Arduino RX
BT-IO1 <--> LED <--> 220 Res. <--> GND (or if you've soldered on the 0603s you can skip that connection).

Notice the mistakes routing my board? :(
It was salvageable though.

Step 8: Questions and Gripes

That's it.

I'm still working with these little modules; so if I come up with new versions I'll try to keep this updated.

If someone wants to review my full work log, you're welcome to.

First Go
Second Go

If someone finds a mistake, just let me know, I'll correct it as quick as possible.   

Can't say it enough: I'm all hack.  And publishing my crap so someone can tell me what I'm doing wrong helps me a lot.


Comments

MangalaA1 (author)2016-11-11

I cant connect my hm 10 module with my phone. it displayed pairing rejected.. how do i solve it? plz help me..

SAADK8 (author)2016-10-08

my BT05 is not visible to any device ???????

marciokoko (author)2016-08-25

Can you help me understand how I would make an arduino with an hm10 send string commands to a relay board with an hm12? What would I need to write on the arduino sketch to send the commands?

LOFI Robot (author)2016-06-29

For anyone that might be interested. I just published free iOS and Android app, that lets you control Arduino with gamepad style interface. The app is compatible with the most popular HM-10 BLE to Serial module.

More info:

https://www.instructables.com/id/Controlling-Arduino-Robot-With-IOS-IPhone-IPad-or-/

Webpicasso (author)2016-03-29

Hi,

great work you did. I bought two HM-10 modules from China and I have problems to connect with. If I power the module the LED begins to blink. If I scan for bluetooth devices I can find it. If I try to connect, I got "connection refused". I tried with my HTC M8 Android device and my laptop. On my laptop I got the device name "BT05".

Could this be a problem with the firmware? Any suggestions how to solve it?

Thanks, Chris

Ladvien (author)Webpicasso2016-03-29

Hey Webpicasso,

Do you have a link to the modules you purchased? Often, the issue is counterfeit modules which do not conform to the original HMSoft firmware.

Webpicasso (author)Ladvien2016-03-29

Here it is http://s.aliexpress.com/ZVFRBJFf

Webpicasso (author)Webpicasso2016-04-01

Any helpful suggestions?Thx Chris

Ladvien (author)Webpicasso2016-04-01

Most likely, they are counterfeit HM-10 modules, which means the firmware is your issue. If you looks at the comments below ours perrygarg and kcender discuss the matter.

aampudia (author)Ladvien2016-05-17

just to let you know that Jeremy Prater's website is back online since a few days ago on this new address.. http://blog.dev-smart.net/ some of the links are broken because of the domain change, but you can manually change the domain in the URL's and get all the files, here's the firmware http://blog.dev-smart.net/wp-content/uploads/2014/03/Stock-HM-10-Firmware.zip

perrygarg (author)2015-07-23

Hi,

I have Arduino Uno R3 and BLE 4.0 module(Please refer to Photos attached) with breakout board attached. When powered and searched, it broadcasts its name as CC41-A. I am pretty new to hardware. What I am trying for now is to change any default properties (for example name) of this BLE module which this is broadcasting. I am also unable to execute any AT commands in serial monitor of Arduino IDE. No AT Command is responding anything. My connections are as follows:

Rx of BLE Module <-> Tx of Arduino (Pin 11 in my case)

Tx of BLE Module <-> Rx of Arduino (Pin 10 in my case)

GND of BLE Module <-> GND of Arduino

+5V of BLE Module <-> 5V of Arduino

(Left 2 pins of BLE Module unconnected - MCU-INT and CLEAR)

My code is as follows:

#include <SoftwareSerial.h>
SoftwareSerial BLE_Serial(10, 11); // RX | TX
void setup()
{
pinMode(9, OUTPUT); // this pin will pull the Module pin 34 (key pin) HIGH to switch module to AT mode
digitalWrite(9, HIGH);
Serial.begin(9600);
Serial.println("Enter AT commands:");
BLE_Serial.begin(38400); // Module default speed in AT command more
}
void loop()
{
// Keep reading from Module and send to Arduino Serial Monitor
if (BLE_Serial.available())
Serial.write(BLE_Serial.read());
// Keep reading from Arduino Serial Monitor and send to Module
if (Serial.available())
BLE_Serial.write(Serial.read());
}

I am getting "Enter AT commands" message, but not getting anything further when I enter AT commands. Please help. Its urgent. Please tell me whether there is something wrong in my code or in my connections. Thanks. :)

/perrygarg

kcender (author)perrygarg2015-09-13

Just following up on my preview reply. After searching Google and playing with it all day, I've found that you can flash the HM-10 firmware onto the fake CC41-A modules using an Arduino and a PC. The Arduino mimics a TI CCDebugger device, allowing you to flash the CC2541 chip on the board.

The following github has the Arduino sketch and Windows executable. *Note that Malwarebytes flags this program as a Trojan, but I didn't have any issues. There is also no source code or a way to dump the chip's current flash memory.

https://github.com/RedBearLab/CCLoader

Module Pinout: https://flashandrc.wordpress.com/2014/08/26/bluet...

You also need to get a full dump of a HM-10 firmware. This isn't the firmware on the manufacture's site. That firmware doesn't have the bootloader/low level firmware code. I Google'd for HM-10 open source firmware and found a project by jeremy-prater. He has on his site the stock firmware in the downloads section. I didn't care if I broke this module, so I changed the download file from .hm1 to .bin and flashed it. The module then booted to HM-10 v520 firmware, which I was able to flash using the official tool to the newest v540 firmware. So far I haven't had any issues with the module after flashing, but i haven't tested it extensively.

If you try this, it's at your own risk. Only try it if you don't mind throwing away the module if it doesn't work. I haven't tested it on the CC2540 chip, and I think you would need different firmware for it to work.

aampudia (author)kcender2016-05-17

just to let you know that Jeremy Prater's website is back online since a few days ago on this new address.. http://blog.dev-smart.net/ some of the links are broken because of the domain change, but you can manually change the domain in the URL's and get all the files, here's the firmware http://blog.dev-smart.net/wp-content/uploads/2014/03/Stock-HM-10-Firmware.zip

MilošK2 (author)kcender2016-03-10

Hello.

I am in same situation as perrygarg.

It seems the jeremy-prater's firmware is no longer available in his blog. Is it possible to update firmware directly to HM-10 v540?

aampudia (author)kcender2015-12-21

Hello!! i'm looking to do just that!! but the EXE just shows a cmd screen for a moment and then dissapears.. and i didn't find the .hm1 file in this project https://github.com/jeremy-prater/OS-CC2540 could you help me sending me the right file to burn?? and what's up with the .exe?? does it have to find the arduino with the sketch already connected or what?? thanks!!

kcender (author)aampudia2015-12-21

aampudia,
The EXE program is a DOS based application. You need to run it from the command prompt in Windows. When you run it from the command prompt, you will need to put in the COM port for your Arduino, the location of the firmware to flash, and other information before it will connect and flash.

It looks like that project was finished/abandoned and the .hm1 firmware file was deleted.

aampudia (author)kcender2015-12-21

yup.. i figured the exe part out a little after posting this... thank you!! don't you have a copy of the bin file??? that would be really helpful!! or at least the original bolutek firmware? help!! xD

kcender (author)perrygarg2015-09-10

perryg1, it looks like you have is the CC41-A clone. (I just received two myself.) The clone board doesn't have all the AT commands that the HM-10 board has, doesn't seem to be updatable, and requires a \r\n (+CR +LF) after the AT command.

Company Site: http://www.bolutek.com/Products_info.asp?TypeID=10...

AT Commands: http://www.hangar42.nl/wp-content/uploads/2015/08/...

aliemrey (author)2015-10-03

hi,
In the schematic AIO0,AIO1 and SPI pins are directly connected
to breakout board, but HM-10 datasheet says NC for these pins. So I am a
little confused. Can you please help me about it.
Regards.

rshnk90 (author)2015-05-02

Hi Ladvien, I recently bought TinySine Bluetooth LE module ( supposed to be a HM-10, I guess) from http://www.tinyosshop.com/index.php?route=product/product&path=65_110&product_id=705

and it doesn't work with Arduino. Their support is not responding as well. I hope you could show some light on where to proceed.

Please check your Private Message. I sent you more details.

looking forward for you reply.

RK

AndreaP38 (author)rshnk902015-10-02

Hi rshnk90, did you solve your problem? thanks

achand8 (author)2015-04-18

Datasheet has it that the CC2541 has a 8051 in it? Can we use it as a microcontroller in our projects? Is there any info about it ?

Ladvien (author)achand82015-04-19

It requires IAR tool chain. A very costly tool chain.

achand8 (author)Ladvien2015-04-19

What about TI's code composer Studio?

bparth.94 (author)2015-04-16

is this compatible with ccdebugger??? can i flash the firmware using cdebugger?

Ladvien (author)bparth.942015-04-16

Yes,

You might find more info here: Open-Source HM-10 Firmware

bparth.94 (author)Ladvien2015-04-17

Thank you :) will try making this and get back

ZephS (author)2015-04-01

I'm missing some simple core understanding here. The HM-10 module sounds like it works similarly to the SPP serial data stream in conventional bluetooth - use AT commands to set things up, then pump bytes through the stream.

But when I read about BLE / BT4.0, it involves reading and writing from services, characteristics, and attributes. And that there is no standard serial port emulation.

Of course you could build your own custom service which sent packets of stream data to an attribute of a custom service - but nobody else would be using the same UUIDs and higher level protocol (eg: on iOS or Android apps).

So what's up? In what manner is a transparent byte stream implemented on top of services, characteristics and attributes? Is there some newer profile I can read about?

Ladvien (author)ZephS2015-04-01

In short, the HM-10 firmware assigns characteristics for RX/TX--so, in essence, it is a simple serial stream. That stated, Jnhuamoa is on their way to adding a customizable characteristics. We'll see. The CC254X chip is more than capable.

Anyway, I'd suggest you read through the most recent datasheets to learn Jnhuamoa's latest implementations.

ZephS (author)Ladvien2015-04-01

Thanks.

So if the HM-10 defines a custom service and passes serial data (eg: around 20 bytes at a time) as attributes, then (1) it's probably incompatible with any (other) existing serial BLE implementation, and (2) given the service and attribute IDs one could perhaps communicate with it from other more general BLE interfaces.

Is there any doc for their protocol (atop GATT) for serial? Like the UUIDs they use, any framing or flow control headers used over the air, etc? I don't find those in the datasheets on the website.

electronichamsters (author)2015-02-13

Thanks for this Instructable!

Brock_lee (author)2014-08-28

Hi. Item #5 in the BOM says 20k and the silkscreen on the PCB says 20k but the digikey link is to a 220k resistor. Which one is correct?

Ladvien (author)Brock_lee2014-12-26

Addressed, my apologies.

Brock_lee (author)Brock_lee2014-08-28

Also, item #6 says 470 but the link is to a 220 ohm. Thanks.

moris_zen (author)2014-04-15

Hi Ladvien ,

Thanks for posting your work .

I purchased 3 PCBs v0.93 but could not get them to work .

I wanted to bypass the regulator and some resistors - what I need is just a breakout to properly connect to the small pitch of the HM-10 .

Can you pls share the schematics of the breakout you made and mention the latest correct version ?

Thanks.

B.T.W - What Android SW did you use for the BLE ?

Ladvien (author)moris_zen2014-04-15

The v0.93 had some mistakes. I've a later version boards (v0.9.9) I'll send you if you like, but if you are looking to make a dead-simple breakout, my Eagle files can be found on my Github. The linik is above :)

moris_zen (author)Ladvien2014-04-16

Hi Ladvein ,
I downloaded the PCB file but would like to better understand where and regulator is connected and which resistors I can short to work only with 3.3V .
I would appreciate if you can send me the schematics .
My email is moriszen[AT]gmail[DOT]com.
thanks
B.T.W - would you be interested to make a small PCB Arduino + BLE for a project I am working on (paid) ?
Thanks

schmoofer (author)2014-04-13

Has anyone at all gotten the commands "AT+DISC?" or "AT+ALLO?" to work? I've gotten almost every other command to work but those. I'm running v526 firmware and tried it both on an HM-10 and HM-11 module with CC2541 chips, but to no avail. I get no response with those commands (already switched to "Master/Central" role).

Ladvien (author)schmoofer2014-04-15

I've not played with either feature. I'm sure I'll get around to them, though.

But speaking from general experience, I'm guessing the firmware is incomplete; keep an on eye on future updates.

schmoofer (author)Ladvien2014-04-16

Thanks for letting me know. The firmware changelogs mentioned those commands being added around v523, so it wouldn't make sense to make such a bold statement and not implement them. Oh well.

dtrotzjr (author)2014-02-02

Quick update. I spent some time tonight doing some basic tests of Thomas' latest board schematic and the latest version does light up the LED's fine. :-)

Ladvien (author)dtrotzjr2014-02-02

Good to hear. I'll have the next iteration tested and posted by Tuesday.

dtrotzjr (author)2014-02-02

All of these tips were great!

One tip I have for the SM LEDs is to put a dab of of hot solder on one of the pads and while it is still hot carefully place the LED onto the pad with the tweezers, let it cool then solder the other side, once the other side is done come back and make sure the initial side is soldered well. Also be sure to note the polarity of the SM LED which is not as easy to determine as it is with their through hole counterparts.

dtrotzjr (author)2014-02-02

When you post the update, be sure to update the BOM to reflect the single 20K resistor and the optional 2x 0.1uF caps as well. Good work!

stvmac11 (author)2014-01-19

I really enjoyed reading this project. I'm all about diy. I've worked with bluetooth serial projects in the past, and I figured this wouldn't be any different. I see there might have been a few board versions floating around. I was able to order the 0.9.3 before you took it off OSHPark (I assume because of the non-functional TX,RX lighting - which is fine, I don't need to see them.)

Do you happen to see anything wrong with the board? I bridged 1 joint, left one open, and soldered 4 10k resistors. I'm using an arduino with a 3.3v source (no need for a voltage divider)

It powers on OK, the IO1 LED flashes when not connected, and stays HIGH when connected, but I'm unable to send or receive any AT query or communicate at all. I use SoftwareSerial - HM-10 RX to Arduino TX, and HM-10 TX to Arduino RX.

Being unable to communicate seems to be a problem with the TX, RX. Do I have the resistors on the correct joint?

Any help would be greatly appreciated! Keep up the good work!

Ladvien (author)stvmac112014-01-19

The reason I took the board down is because I had linked the wrong version. As dtrotzjr pointed out. The board version I linked still works as you have it soldered, except of course the RX/TX LEDs don't work. I'm currently working on corrections and will have new boards sent off by end of day. If you are able to Skype: thomas_ladvien. I would like to replace your boards for you :)

stvmac11 (author)Ladvien2014-01-19

What a simple fix! I switched the RX and TX lines and now we're rolling. TY

dtrotzjr (author)2014-01-14

Parts are starting to roll in, but I didn't realize that your latest boards do not properly light the TX/RX LEDs is that correct? Can you please update this instructable to reflect this? Can you update the board too?

Ladvien (author)dtrotzjr2014-01-15

Yes, yes, and yes.


I might need a day or two. I apologize, I thought I put a note in the Instructable stating they didn't work. I'll create a board with working TX/RX LEDs and post it, but I wont order myself. Sorry, too many irons in the fire right now.

musawir (author)2014-01-11

I purchased a BLE module that is based off of the same TI CC2540 chip you used in your project, but has a different PCB package which I don't quite understand. Here is the thing I have bought: http://www.aliexpress.com/snapshot/310173495.html


I have a couple of questions if you don't mind answering. First, are ALL the pins on these modules needed? Can't I just solder some wires out of the pin slots that I will use and leave the rest alone? Secondly, the debugger pins on my module are listed as: GND, 3.3V, P2.2, P2.1, RESET
How do I interface this to the FTDI?

About This Instructable

269,396views

411favorites

License:

Bio: I'm a homeless outreach worker in Fort Worth, Texas. I hack away on electronics as a way to deal with the stress; a type ... More »
More by Ladvien:IPhone to Arduino Using Bluetooth 4.0  --UUEncoding in CHEX File to Array in C
Add instructable to: