Create A Bluetooth Joypad With App Inventor 2

BluetoothJoyPad_draftLayout_01_800Here we create a basic Classic Bluetooth joypad for use on an Android device to control a microprocessor (Arduino) connected to a Bluetooth module. The app is fairly simply. There are 2 screens; the first is the main control panel and the second is a connection page.

When the CONNECT button on the main screen is clicked the second screen is opened to allow the user to connect to a Bluetooth device. The direction buttons, when clicked, transmit codes to the Arduino.

Read more

HC-05 with firmware 2.0-20100601

There are now many cheap and no brand HC-05 modules that use the 2.0-20100601 firmware and rather than keep making the same post for different modules I will have a single main post which, as I update and add to it, will become a single point of reference.

The 2.0-20100601 firmware is originally by HC/Wavesen and as the version number may suggest it is from 2010. I am not sure if other manufacturers use it under license or simply copy it since the genuine HC/Wavesen modules now use version 2.1 firmware.

HC-05
HC-05 with 2.0-20100601: AT Command Mode
HC-05 with 2.0-20100601: Connecting to an Arduino
HC-05 with 2.0-20100601: Initial Communications Test
HC-05 with 2.0-20100601: Main AT Commands
HC-05 with 2.0-20100601: AT Commands Dealing With Connections
HC-05 with 2.0-20100601: Making A Connection
Downloads

Read more

HC-05 (ZG-B23090W) Bluetooth 2.0 EDR modules

HC-05 - ZG1643 - B23090W_001_800The HC-05 (ZG-B23090W) uses a regular Bluetooth smd module based on the csr BC417 with a MX 29LV800CBXBI-70G flash memory chip. It appears to be using the HC/Wavesen 2010 firmware and a Google search for “HC-05 2.0-20100601” should give you plenty to read, including some of my older posts.

 
I have received a few comments about HC-06 and HC-05 modules that use a new breakout board (new to me at least). When I received the first comment I hadn’t seen these modules, by the time I had received the 4th or 5th comment the modules were all over Taobao so I decided to order a few (2 x HC-06 and 2 x HC05). I have no real use for these except to see if they are different to previous versions.

 

HC-05s

HC-05s are Bluetooth 2.0/2.1 EDR devices that have a serial UART layer on top of the Bluetooth. The UART layer makes them easy to use but hides the Bluetooth functions from the user. This is good if all you want is to make 2 things talk to each other. The HC-05 has two modes of operation; AT command mode and transmission mode. When in AT command mode all data received over the serial UART connection is treated as a command, and when in transmission mode, all data received over the serial UART connection is treated as data.

When in communication mode, if there is an active connection the data is broadcast to the connected device. If not connected, the data, disappears in to some mysterious void.

The HC-05 can operate as either a slave or master device. Slave devices cannot initiate connections, they can only accept them. Master devices can initiate and (depending on the actual module) sometimes accept them. If you want to use the module with a mobile device such as an Android phone, the phone will be the master device and so the HC-05 will need to be the slave. If you want to link two HC-05s, one will need to be a master and the other one a slave.

Read more

HC-06 (ZG-B23090W) Bluetooth 2.0 EDR modules

HC-06 - ZG 1643 - B23090W_001_800The HC-06 (ZG-B23090W) uses a regular smd Bluetooth module based on the csr BC417 chip with a MX 29LV800CBXBI-70G flash memory chip. The firmware is well documented and a Google search for “HC-06 linvor V1.8” should get you more than a few hits.

I have received a few comments about HC-06 and HC-05 modules that use a new breakout board (new to me at least). When I received the first comment I hadn’t seen these modules, by the time I had received the 4th or 5th comment the modules were all over Taobao so I decided to order a few (2 x HC-06 and 2 x HC05). I have no real use for these except to see if they are different to previous versions.

 
The HC-06 is a Bluetooth 2.0/2.1 EDR device that has a serial UART layer on top of the Bluetooth. The UART layer makes them extremely easy to use but hides the Bluetooth functions from the user. This is good if all you want is to make 2 things talk to each other.

The HC-06 has 2 modes of operation; AT mode and transmission mode. When the modules are first powered on they go in to AT mode. Here AT commands can be entered via the wired serial connection. After a connection has been made the modules go in to transmission mode. Here everything the modules receives via the wired serial connection is sent to the connected device. At commands cannot be entered again until the connection is broken.

HC-06s are slave only modules and require a master device to make a connection. Slave devices cannot initiate a connection which means you cannot link 2 HC-06s together. The master module is the HC-05 which can be either slave or master. Since the price for the HC-05 and the HC-06 is basically the same I would suggest buying HC-05s and not HC-06s.

Read more

HM-10 Bluetooth 4 BLE Modules

Since I first posted about the HM-10 the firmware has been updated many times and some of the commands have changed. Therefore, I decided to redo the guide. For the main article I am using modules with firmware 5.49 (regular) except the one I am using for the firmware update guide which started with v5.40 and become 5.47.

There have been several firmware updates since this guide was written, as of March 2020 the latest is v707.

 
Updated 2019-08-25
I thought it was time for a minor update.

Read more

HC-06 hc01.comV2.0

HC-06_hc01.com_02_800

ZS-040_HC-06_hc01.comV2.0

The latest zs-040 HC-06 modules have an updated firmware, hc01.comV2.0. This firmware has the following defaults:
– baud rate = 9600
– password = 1234
– nl/cr line endings not required.
– AT commands are required to be in upper case
– Firmware version = hc01.comV2.0
– Name = HC-06
– No parity
– SLAVE mode

Since the Bluetooth hardware is the same as the previous zs-040 HC-06s the Bluetooth specs are also the same. Bluetooth 2.0 EDR, SSP.
These use a slightly different BT module than the other zs-040 boards and there is a blue LED at the top left of the daughter board.

Read more

Arduino to Arduino by Bluetooth

Updated 12.06.2016: Added example 2

In the Connecting 2 Arduinos by Bluetooth using a HC-05 and a HC-06: Pair, Bind, and Link post I explained how to connect a HC-05 to a HC-06 so that when powered they automatically made a connection. Here we look at using that connection to get Arduinos talking over Bluetooth. Before continuing you need to have the Arduinos and BT modules set up as per the previous post. Here I am using 2 HC-05s. One in master mode the other in slave mode. The setup process for the slave mode HC-05 is the same as the HC-06 in the previous post.

Arduino2ArdionoBT_Breadboards_01_1600

Read more

Bluetooth Modules

Updated: 21.07.2017

new Bluetooth Modules

There are many very similar Bluetooth modules available and sometimes it can be difficult finding out, not only which one you have, but also how yo use them. Here I look at some of the modules I have and try to show the basic settings.

Getting Started
Connecting To A Computer
Android Apps

Bluetooth 2.0/2.1 EDR Modules
    HC-06 (ZG-B23090W) Bluetooth 2.0 EDR modules
    HC-05 (ZG-B23090W) Bluetooth 2.0 EDR modules
    SPP-C HC-06 / BT06 HC-06
    HC-06 zs-040 hc01.com v2.0
    HC-05 zs-040 hc01.com V2.1
    HC-05 FC-114 and HC-06 FC-114
    HC-05 and HC-06 zs-040 Bluetooth modules

Bluetooth 4 / BLE Modules
    HM-10
    HM-11
    BT05-A mini BLE Bluetooth V4.0 iBeacon
    AT-09 Bluetooth V4.0 CC2541

Read more

Android MIT App Inventor – Auto Connect To Bluetooth

In a previous post I showed how to connect an app inventor Android app to a Bluetooth module connected to an Arduino to control an LED. See Turning a LED on and off with an Arduino, a HC-06 and Android

A few people have asked how to make it so that the app auto-connects to the Arduino on start up and I thought I would offer my solution. This example adds to the previous guide.

Read more

HC-05 FC-114 and HC-06 FC-114. Part 3 – Master Mode and Auto Connect

Update 19.09.2015
The FC-114 boards I have have the Bolutek firmware. User DS has reported that he/she has FC-114 boards that have the linvorV1.8 firmware. So if the below does not work for you then check what firmware you have.

I may be missing something but I can not get the HC-05 FC-114 boards in to Master Mode and connect to other BT devices with just AT commands. The modules say they have accepted the commands, such as AT+ROLE1 but when I try to connect to other modules I get the error message “Can only be used in Lord Mode”.

The modules accept “AT+ROLE1” and report they have changed mode but they haven’t really.

In an earlier post I mentioned that it looks likes pin 27 or pin 28 has to be pulled HIGH to enter Master Mode and this does indeed seem to be the case. Everything I have tried without pulling the pin(s) HIGH has failed.

HC-05_FC-114_autoConnectSerialMonitor01
They reply with “OK” and if you interrogate with “AT+ROLE” they report “+ROLE=1” but they are actually still in Slave Mode.

Read more

HC-05 FC-114 and HC-06 FC-114. Part 2 – Basic AT commands

Update 19.09.2015
The FC-114 boards I have have the Bolutek firmware. User DS has reported that he/she has FC-114 boards that have the linvorV1.8 firmware. So if the below does not work for you then check what firmware you have.

Since the HC-05 FC-114s and the HC-06 FC-11s share the same firmware the following should work on either module.

The default setting on start up is Slave Mode waiting for pairing or a connection and also accepting AT commands. This means it is fairly simply to start using AT commands.

HC-05 FC-114 & HC-06 FC-114_1200

Read more

HC-05 FC-114 and HC-06 FC-114. First Look

I have just received some new HC-05 and HC-06 Bluetooth modules. These were sold as zs-040s which is the module I actually wanted but I received modules marked FC-114. They share the same breakout board as the zs-040 but have different pins soldered between the Bluetooth module and the breakout board and have a very different firmware.

HC-05_FC-114_&_HC-06_FC-114_001_1600

The small push button switch still has traces to pin 34 and still pulls pin 34 HIGH, however, on the FC-114 boards, pin 34 is a regular IO pin and closing the button switch doesn’t do anything. On the zs-040 boards, closing the button switch and pulling pin 34 HIGH puts the modules in to AT mode. Since the FC-114 starts in AT mode this is no big loss.

It took me a while to figure out the differences.

Read more

HC-05 fs-040 State Pin

This post follows on from Arduino With HC-05 Bluetooth Module in Slave Mode

The STATE pin on the HC-05 zs050 board is connected to the LED 2 pin on the small bluetooth module and the LED 2 pin is used to indicate when there is an active connection. This means the Arduino can connect to the STATE pin and determine when we have a connection. The STATE pin is LOW when the HC-05 is not connected and HIGH when the HC-05 is connected.

As a quick visual indicator you can put a LED + suitable resistor on the STATE pin. When the module is connected the LED will light.

You can also use the Arduino to read the value of the STATE pin.

Read more

arduinoBTcontrol

Updated on 06.08.2016

Controlling an Arduino over Bluetooth from Android using App Inventor 2

Here is an example of controlling the Arduino over Bluetooth using a HC-06 bluetooth module and an Android app. The example uses an Arduino Nano but other Arduinos will work just as well. A HC-05 module can be used stead of the HC-06.

arduinoBTcontrol - breadboard

The Android app was created in app inventor and the aia file can be downloaded at the bottom of the page.

Read more

Connecting 2 Arduinos by Bluetooth using a HC-05 and a HC-06: Pair, Bind, and Link

In a previous post I showed how the HC-05 can auto connect to other Bluetooth devices by setting the HC-05 to pair with any device using CMODE=1. This is quick and easy but does not give any control over which other device the HC-05 connects to.

In this post I show how to set up the HC-05 to always connect to the same HC-06 (or HC-05 in Slave mode). For this we use PAIR, BIND, and LINK.

NOTE: There are now newer modules that use a 3.0-20170601 firmware. This guide does not work for these modules (AT+INQ gives an error). I do not have any of the new modules and cannot find a reliable supplier. I have ordered 3 sets of BT modules believing they were the newer ones only to receive old ones.

If you have not yet bought BT Classic modules. I recommend buying the original HC ones. These are slightly (just a little bit) more expensive but are well supported and full documentation is available. Original HC modules have the HC logo screen printed on the main BT board and the current boards have a blue LED top left.

I am using 2 separate Arduino IDEs; version 1.6.3 which is installed, and version 1.0.5 which I run from a folder (it is the non install version). This allows me to use 2 IDEs at the same time, each connected to a different Arduino. It also gives me 2 serial monitors, one for each Arduino.

The modules used are the zs-040 versions of the HC-05 and the HC-06. The HC-05 has the Wavesen/HC firmware 2.0-20100601 and any any module running the same firmware will be the same.

The HC-05 has 2 AT command modes which I refer to as “mini” AT mode and “full” AT mode and some commands only work when in “full” AT mode. To enter “full” AT mode pin 34 needs to be HIGH and kept HIGH. To accomplish this I have made a connection from pin 34 to +3.3v. See the diagram below (or after the jump).

If you are not sure about At command mode take a look at Arduino with HC-05 (ZS-040) Bluetooth module – AT MODE

If you are not familiar with how the HC-06 and HC-05 work it may be worth while checking out some of the other posts:
HC-05 and HC-06 zs-040 Bluetooth modules
Arduino and HC-06 (ZS-040)
Arduino With HC-05 Bluetooth Module in Slave Mode
Connecting 2 Arduinos by Bluetooth using a HC-05 and a HC-06: Easy Method Using CMODE

Read more

Connecting 2 Arduinos by Bluetooth using a HC-05 and a HC-06: Easy Method Using CMODE

Making a connection Between a HC-05 and a HC-06: Method 1

Using the CMODE command we have an easy way to connect the HC-05 and the HC-06 (or 2 HC05s). When the HC-O5 is configured to pair with any address (AT+CMODE=1) it should connect to a Slave module automatically. No binding etc is required.

I am using the zs-040 modules with firmware 2.0-20100601 and other modules with the same firmware will be the same. If you have issues check the data sheet for your module.

The Set Up

I am using 2 different Arduino IDEs; version 1.0.5 and version 1.6.3. This gives me 2 separate serial monitors. The Arduino connected to the HC-05 is on COM8 and the Arduino using the HC-06 is on COM17

ARD2ARD_SETUP_IDE

Read more

Arduino with HC-05 (ZS-040) Bluetooth module – AT MODE

Since writing the below many more modules have been released using the zs-040 breakout boards. Some of the newer ones include modules with a version 3.0-20170601 firmware that work in a slightly different way. I still do not have any of these and so cannot help directly but searching for the firmware should get plenty of hits online and a good place to start is stack overflow and the Arduino forum.

 
Update 20.07.2017

The zs-040 breakout boards are now being used for many different modules and you may not have the exact same boards as those shown below. The modules I am using here use the EGBT-045MS Bluetooth module and have the HC/Wavesen 2.0-20100601 firmware. They also have an EN pin rather than a KEY pin and they have a small button switch just above the EN pin.

There are now newer zs-040 modules that use the real HC SMD modules, these have a newer firmware and include a blue LED at the top right of the SMD daughter board.

There are also modules that use the same breakout board but have different board markings such as the fc-114 modules:
HC-05 FC-114 and HC-06 FC-114. First Look
HC-05 FC-114 and HC-06 FC-114. Part 2 – Basic AT commands
HC-05 FC-114 and HC-06 FC-114. Part 3 – Master Mode and Auto Connect

Read more

Arduino With HC-05 Bluetooth Module in Slave Mode

Arduino and HC-05 in communication mode

Updated on 18.07.2015.

Updated 01.12.2016
There are now newer HC-06s and HC-05s that use the zs-040 breakout boards. These new modules have a LED (usually blue) at the top left of the Bluetooth daughter board and have a different firmware to the below. See HC-06 hc01.comV2.0 for an introduction to the HC-06. I haven’t written up details on the HC-05 yet.

 
 
Here is the zs-040 version of the popular HC-05. The HC-05 is based on the EGBT-045MS Bluetooth module. It can operate as either a slave device or a master device. As a slave it can only accept connections. As a master it can initiate a connection.

HC-05 zs-040

The EGBT-045MS Bluetooth modules (the smaller daughter board) is a 3.3v device. The HC-05 break out board has a 3.3v regulator that allows an input voltage of 3.6v to 6v but the TX and RX pins are still 3.3v. This means you can use the 5V out from the Arduino to power the boards but you cannot connect the Arduino directly to the HC-05 RX pin.

For the HC-05 RX pin (data in) we need to convert the Arduinos 5V to 3.3v. A simple way to do this is by using a voltage divider made from a couple of resistors. In my case I use a 1K ohm resistor and a 2K ohm resistor.

As a quick guide to the voltage divider; 1K + 2K = 3K. 1K is a third of 3K so it reduces the voltage by a third.
One third of 5V is 1.66 and 5-1.66 = 3.33 which is what we want. Putting the resistors the other way would reduce the voltage by 2 thirds.
For more information on voltage dividers have a look at the Sparkfun tutorial

Since the Arduino will accept 3.3 volts as HIGH you can connect the HC-05 TX pin (data out) directly to the Arduino RX pin (The 5V Arduino takes a voltage of 3V or more as HIGH).

Read more

Turning a LED on and off with an Arduino, Bluetooth and Android. Part II: 2 way control

In the first part I showed how to control a single LED from an app created in App Inventor. This worked OK but was very limited. You could control only 1 LED and the control was one way; from the app to the Arduino. What if you want to have 2 way control of the LED and to be able to also control the LED from the Arduino side? What if you want to control more than 1 LED?

In this guide we look at adding two-way communication. Here we control an LED but you could have it doing anything.

Arduino-AI2-Bluetooth_1LED_01In first example you could only control the LED from the Android app, here we extend the example so that we can also control the LED at the Arduino side. When the LED is turned on or off by the Arduino we want the button in the app to update to show the correct LED status.

The first example used methods only suitable for controlling one LED, this time we will try to make it so the Arduino sketch and also the AI2 app can be easily scaled and so once you have the basic app in place adding extra buttons and controls should be fairly straight forward.

Read more

Turning a LED on and off with an Arduino, a HC-06 and Android

Although I use a HC-06 in the below examples the HC-05 in slave mode can also be used.

Using MITs app inventor it is fairly easy to create an app that can turn a LED on and off from an Android device.

This is a fairly simply example of sending commands to the Arduino to turn a LED either on or off. The Android app sends ascii codes to the Arduino via the HC-06 BT module; “ON” for on and “OF” for off.

Load the app, connect to the HC-06 and then use the LED button to turn the LED on and off.

Arduino_Android_LED_AppUse_Screen_001
Arduino_Android_LED_on-off_1600

You can also open the serial monitor to see the commands as they are received
Arduino_Android_SerialMonitor

Read more

Arduino and HC-06 (ZS-040)

The HC-06 is a slave only BT module that is fairly easy to use with the Arduino using serial communication. Once it is connected it simply relays what it receives by bluetooth to the Arduino and whatever it receives from the Arduino it sends to the connected device. There are several slightly different versions of the HC-06, however, all seem to use the same firmware and have the same AT commands. The ones I have are labelled as zs-040. I also have some HC-05s which share the same PCB and are also labelled as zs-040.

HC-06 zs-040

The HC-06 defaults to AT mode at power on. This is indicated by a rapidly flashing LED. After the HC-06 is connected to another device the LED stops flashing and is constant on.

Read more

HC-05 and HC-06 zs-040 Bluetooth modules. First Look

Update: If you have modules that have a blue LED in the top left hand corner then you have a newer model with a slightly different firmware although they should operate the same.

I recently bought some HC05s and HC-06 Bluetooth modules. These are pretty standard, especially when using with the Arduino and I was surprised at how easy it was to get basic serial communication working. There are several slightly different modules available. The ones I have are marked zs-040. The zs-040 boards differ from some of the other modules in that they have a EN pin rather than a KEY pin.

HC-05 & HC-06 - ZS-040

Read more