Menu Close

LED Control with BLE Module HM10 – MIT App Inventor

This tutorial of Robo India explains how to make an application to control led with ble module hm10 using mit app inventor

1. Introduction:

Go to the link ai2.appinventor.mit.edu. Sign In with your existing gmail account. To start making your application, click on the Projects menu on the top left of the screen and select the “Start new project” and then give the name of your project.

BLE is all about services and characteristics. HM10 has a set of services and each service has a set of related characteristics. MIT App BLE extension allow us to write various types of data.

You can download the BluetoothLE from here.

Or you can go to the link, https://puravidaapps.com/extensions.php to download.

After downloading, import this into your project by clicking on Extension from palette. Then click on Import Extension and import the file.

2. Designer Panel:

Add the components from user interface. We have added a label, to get status about ble connection. One button for scanning. One listpicker component to display list of available devices and again a button to get connect and disconnect with module.

Then, we added a couple of buttons to send controlling data.

we have renamed all the components.

Now, add the ble extension to your project.

Add Notifier from user interface. The Notifier component displays alert dialogs, messages, and temporary alerts. Users can dismiss that by pressing a button.

App on phone screen will looks like:

3. Block Editor:

The Blocks Editor is where you program the behavior of your app. There are Built-in blocks that handle things like math, logic, and text with each components you have added.

Add blocks for scan button.

If we want to check, that bluetooth is enabled before scanning. If it is than we can scan for new device and if it is not, than we will get notification message by adding bluetooth client component,

After scanning, when device is found, listpicker elements will set to available devices.

After picking the element from listpicker, press the connect button.

You can also apply disconnect function on the same button.

To send the control codes with ble, we need to write the data to specific characteristics. For this we need to know the UUID (Universally unique identifier ) for that characteristics and the UUID for the service, the characteristics is under.

In this code, we have used default HM10 custom characteristics 0000FFE1-0000-1000-8000-00805F9B34FB, which is under service 0000FFE0-0000-1000-8000-00805F9B34FB

Adding blocks, to make led on and off.

String received block is used to read current value of characteristic.

Here,we need to process the list, because it gives data in form of list.

You may download the source code of this App from here.

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
https://roboindia.com

1 Comment

  1. BestDewey

    I see you don’t monetize roboindia.com, don’t waste your traffic, you can earn additional cash every month
    with new monetization method. This is the best adsense alternative for any type of
    website (they approve all sites), for more details simply search
    in gooogle: murgrabia’s tools

Leave a Reply