Arduino, HM-10 and App Inventor 2: Adding a slider

This post continues the Arduino, HM-10 and App Inventor 2 guide. A few people asked about adding a slider so here it is. Please beware; this is not a basic guide for using a slider in App Inventor 2. I am adding a slider to an existing app and have certain things (semi advanced) that I want to achieve.

Arduino_HM-10_AI2_Adding_Slider_33 - updateApp_04

In the previous guide we created a basic Android app to control 3 LEDs. The app was developed in such a way to make adapting it as easy as possible. So let’s see if that is true and add a slider to control the brightness of one of the LEDs. We start with extending the app and then update the Arduino sketch.

Using the same command method as before, we will create an ascii command and send it to the Arduino. The command will be in the form “[Snnn]”. Where S is used to denote slider and nnn is a value from 0 to 255, or more specifically “000” to “255”. The Arduino will read the command and set the LED brightness accordingly. Using ascii for this keeps things fairly simply but it is not the fastest way to do it. The slider value will be from 0 to 255, this is actually the same value range as an 8bit byte. Using the ascii command we need 6 characters (including the square brackets). To send the actual value only would require 1 character (2 with a label/marker character). If all you are using is a single slider then there is no reason to use ascii.

Continue reading

Arduino, HM-10 and App Inventor 2

Update: The BLE extension included with the examples is out of date and does not function fully any more. Download the latest version from the app inventer BLE extention download and replace the existing extension. Do not delete the old version, upload the new version and it will over write the older version.

You can check the latest version of the BLE extension on the app inventor BLE page.

 
 
Hopefully this guide will give you a good introduction to using the HM-10 with App Inventor 2. I also hope that this takes you beyond the usual starter guides that do not go past very basic information.

Although I am using an Arduino the principles will be the same for any other microprocessor or indeed for using the HM-10 on its own. Warning: This is going to be a very long post.

ARD_HM-10_AI2_01_00.gif

To use this guide you should be somewhat familiar with App Inventor, have a BLE enabled Android device, and of course have an Arduino and a HM-10.

Continue reading

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.

Please note that this new guide is starting to get old and if you have problems you should check the latest firmware.

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

There are now 4 versions of the HM-10. The differences are usb pads and a crystal.
1 – with usb pads and the additional crystal
2 – with usb pads without the extra crystal
3 – no usb pads but with the additional crystal
4 – no usb pads, no extra crystal.

HM-10_4Versions

Docs and data sheet
The docs zip file is available by clicking on one of the HM-10 images on the Huamao Technology products page or download directly here.

HM-10_zipFileContents_20190825

The data sheet in the download shows v606/v701 and is not up-todate; it does not include the new AT+READOF command and has the old AT+CO command. It does include AT+PACK which was introduced in v702 though. Huamao version control looks to be as good as mine…..

The readme in the archive is not up-to-date either, see the one that comes with the firmware download.

Firmware
The latest firmware is v705 and can be downloaded from Huamao here. Here are all the changes since v700. I have not used any of the 7xx firmwares.
If you update from < v700 remember the default UART baud rate changed to 115200.

HM-10/11 CC2540/1

V705
-Add AT+READOF command
AT+READOF ?, used to read long char value
P1: 2 Bytes, Start Index.
P2: 4 Bytes, Char Handle.

V704
-Modify AT+CO command
AT+CO [P3][P4][P5], used to make connection.
P1: 1 Byte, Devie type.
P2: 12 Bytes, Device MAC
P3: 4 Bytes, Notify Handle
P4: 4 Bytes, Write Handle
P5: 2 Bytes, Write property.
P1 and P2 must be input;

V703
-Add AT+INDICA_ON command

V702
-Made wakeup function better
-Add AT+PACK command used to modify data in Advertisement package.
AT+PACK[P1][P2][P3][P4][P5][P6]
P1, P2, P3, P4, P5, P6 length all is 2.
P1, P2, P3, P4, P5, P6 value 00~FF

V701
-Add AT+SET_WAY command

V700
-Default baud rate change to 115200
-Removed AT+ANCS command
-Removed AT+COMP command
-Removed AT+128B command
-Added new function used to support different brand BLE device
-Added AT+FINDSERVICES? command
-Added AT+FINDALLCHARS? command
-Added AT+NOTIFY_ON command
-Added AT+NTOIFYOFF command
-Added AT+READCHAR command
-Added AT+CHAR command
-Added AT+READDATA command
-Added AT+READDESC command
-Added AT+SEND_DATA command

I always had issues using the HM-10 with other modules. I never got them to fully work with modules like the BT05 and the AT09. The BT05 & AT09 could receive data from the HM-10 but not the other way round.
I emailed Huamao a few times about this a while ago and didn’t get any replies but it looks like they at least addressed the problem. I haven’t had time to try though.

Firmware download page You can get the how to update guide from the same page (or see below). I note that firmware v703 and v701 are no longer available.

2019-02 Firmware version 7.02 now available. The download link says V701 but the file says 702.
Note that in V700 onwards:
– the default baud rate change to 115200.
– accepts commands with and without line endings.
– better compatibility for other BLE modules. See the readme file that comes with the download.

2018-03-24 Jinan Huamao support say that the HM-10 (original ones, not copies) are compatible with Android 8. I do not have Android 8 so have not tried and cannot confirm.
They have now added a comment on their website saying the HM-10 works with Android 8.

2018-03
HM-10s with firmware V605 are now available but Jinan Huamao are not releasing the firmware. Not sure if this is just for now or permanently. V603 is the latest firmware available for download.

It appears that Jinan Huamao are trying to crack down on fakes. Apart from not releasing the latest firmware the latest HM-10s have “HM-10″ screen printed on the PCB. EDIT: looks like they changed their mind. Newer firmwares are now available.

Image taken from the Jinan Huamao website

Image taken from the Jinan Huamao website

2017-09
Firmware 6.01 now available (bug fixes, no new commands)
2017-10.xx Firmware 6.03 now available Extended the CO command. Added AT+MPIO (multi PIO control). See the readme file for details. The manual has not been updated at this time (Nov 2017).

2017-07
Firmware version 5.49 is now available from the Jinan Huamao website. There are 2 versions; regular and long name. The regular firmware does not have an updated read me so I don’t know what changes, if any, have been made. The long name firmware adds, you guessed it, long names. Device names can now be up to 29 characters. At the same time the iBeacon function and the ANCS function have been removed. Unless you desperately need long names I suggest you stay with the regular firmware.

 
 
Introduction
Bluetooth 4 BLE
HM-10 Services and Characteristics
Get Started With the HM-10
Getting an Arduino talking to the HM-10
HM-10 AT Commands: Using the Arduino’s serial monitor to talk to the HM-10
Scanning for other HM-10s
Arduino to Arduino using HM-10s
HM-10 to HM-10: Turning an LED on and off
HM-10 Programmable Pins
HM-10 Stand-alone MODE 2 and Controlling LEDs
HM-10 Stand-alone: Remote Light Sensor
HM-10: Add a second Custom Characteristic
Using the HM-10 with non-HM-10 modules (not fully working)
HM-10 as an iBeacon
HM-10 Updating the firmware
HM-10 Downloads

 
 

 

Introduction

The HM-10 is a small 3.3v SMD Bluetooth 4.0 BLE module based on the TI CC2540 or CC2541 Bluetooth SOC (System On Chip). The HM-10 is made by Jinan Huamao and is one of many Bluetooth devices they produce including the HM-11 which is operationally the same as the HM-10 but has a smaller footprint with fewer pins broken out.

There are 2 versions of the HM-10; the HM-10C and the HM-10S
HM-10C-HM-10S

The HM-10C does not have the pads along the bottom (the usb connections) and has 26 pads instead of 34 which makes it a little cheaper to produce. There may be other differences (such as the type of crystal used) due to the date of manufacture. Operationally the two are the same though.

HM-10 Basic specs

  • +2.5v to +3.3v
  • Requires up to 50mA
  • Uses around 9mA when in an active state
  • Use 50-200uA when asleep
  • RF power: -23dbm, -6dbm, 0dbm, 6dbm
  • Bluetooth version 4.0 BLE
  • Default baud rate pre firmware V700 is 9600
  • Default baud rate firmware V700 and up is 115200
  • Default PIN is 000000
  • Default name is HMSoft
  • Based on the CC2540 or the CC2541 chip

The latest HM-10s all appear to the the CC2541 chip. This is the same as the CC2540 except it is lower power and has a shorter range. The CC254x is based on the 8051 and runs at 32MHz.

The HM-10 is has become a very popular Bluetooth 4 BLE module for use with the Arduino. In part due to the standard UART serial connection that makes it fairly straight forward to connect to an Arduino. The UART layer is a good thing and a bad thing, it allows ease of use but it hides the BLE layer so you have no control over the actual BLE side of things. The HM-10 is Bluetooth version 4.0 only. This means it cannot connect to Bluetooth 2/2.1 modules such as the HC-06 and HC-05.

The HM-10 is controlled via AT commands which are sent over the serial UART connection. There are a host of commands, some simple, some more complex, and these are covered later.

Continue reading