Sunday, July 24, 2016

Arduino : Configuring HM-10 as iBeacon

I was so excited when found out that this HM-10 Bluetooth can be configured as iBeacon device. Bluetooth Low Energy beacon which the protocol was developed by Apple. But we will call this device or module as beacon.

The beacons will broadcast it's identifier to any nearby electronic devices. With this information, mobile app can perform actions if in the range or close to the device. The proximity to the device grouped by the range or regions which are Far, Near and Immediate. Each region can trigger the app to do call to action presented to the user. This range can be adjusted by configuring the transmitting power of the beacon.

For example we have store and beacons configured for some special products. When customer walk or pass in to the store, the app can present promo, sale or any interesting store information to the customer. When customer pass near to the discounted or sale product user can be presented with the discount information or product details. Then when customer put the device very close to the product, the app can add product to the app cart or do checkout automatically.

That is one of the scenario on the real world implementation. You can find many resources on the internet that explained better about iBeacon and examples of it's implementation. But on this post I'll try to explain how to configure HM-10 as iBeacon device. See screenshot below.

Commands explanation.
  1. AT+RENEW: restore software to factory default
  2. AT+RESET: reboot device
  3. AT: check at command is accepted by device, if its OK you are good to go
  4. AT+MARJ0xAAAA: set major device number in hexadecimal
  5. AT+MINO0xBBBB: set minor device number in hexadecimal
  6. AT+ADVI5: set advertisement interval to 5 second
  7. AT+NAMESMBEACON: set beacon name to SMBEACON
  8. AT+IBEA1: enable beacon mode
  9. AT+PRWM0: enable power on mode, this will save power
  10. AT+RESET: reboot device
So your bluetooth now ready to broadcast it's identifier to nearby supported device. Test using Beacon scanner available on the playstore or appstore. Here I tested the device using Beacon Scanner android app.

We can also modify device UUID by using AT command. On the real world implementation as example above, this UUID can be used for identify the store building then major number used as the store level and the minor number used to identify specific location or product on that store level. Then we can create the app that respond to those beacons. We can put as many beacons on but make sure to change major and minor number. I'll try to create app to demo the beacon usage.

Resources and links

  1. How to :
  2. 10 things about beacon :

Sunday, July 17, 2016

Arduino: Configuring HM-10

In my earlier post I mentioned about how to configure HM-10. My HM-10 by default has name BT05. I want to change it. But how ? That's not hard as long you have necessary tools to do it. In my case I setup it using breadboard and use Arduino 5v as power supply. To configure HM-10 you need to issue AT command. For that purpose you need to use serial communication between computer and the module. Here are  tools that I use:
  1. HM-10 BLE
  2. USB to Serial/TTL adapter or cable I use FT232RL USB to TTL adapter
  3. Arduino and Arduino IDE
  4. Male to male jumpers
  5. USB to mini usb cable data (for serial connection)
Here is HM-10 and FT232RL side by side.

For pinout for HM-10 and FT232RL based on above picture are below.

HM-10 (From left to right)
  • RXD
  • TXD
  • GND
  • VCC
  • EN
FT232RL (From left to right)
  • DTR
  • RX
  • TX
  • VCC
  • CTS
  • GND
The pin we will use for serial communication are below.

HM-10 TXD  <-------> FT232RL RX
HM-10 RXD  <-------> FT232RL TX

Since we use Arduino power for this purpose, make sure the jumper on FT232RL is on 5v voltage or it could burn the adapter.

After you finished all wiring, you are ready to go.

  1. Connect Arduino USB to your laptop/PC
  2. Connect USB data cable from FT232RL to computer
  3. Run Arduino IDE, and select serial port from Tools > Serial in my Arduino IDE detected as /dev/cu.usbserial-xxxxx
  4. Open Serial Monitor
  5. Set 9600 baud Newline and Carriage Return
Here the screenshot from serial monitor.

Command explanations.
  1. AT : check terminal command, all good if return OK
  2. AT+NAME: get device name
  3. AT+NAMESARANG MACAN: set device name to SARANG MACAN
  4. AT+NAME: get modified device name
  5. AT+RESET: reboot device/software
Now you can test it by scan the bluetooth from your smartphone. Here what I get when using my HM-10 BLE app.

For more command list supported by device you can type AT+HELP on terminal. Here the list.

I have mentioned that my HM-10 was cloned version. Turn out the module built by Bolutek. I am in process getting the original one. Will update it later. Next post I'll try to configure it as iBeacon. Happy hacking :)

Friday, July 15, 2016

Arduino : Controlling RGB led using smartphone and HM-10 Bluetooth 4.0 LE

My last setup as seen on previous post has been abandoned for a while. A bit busy with another work and holiday. About holiday I'll tell you in my upcoming post. Interesting place to visit and beautiful too. You probably will be interested too.

I have been doing some research and learning to build mobile app for my last project with RGB led and Bluetooth LE. So i end up learning Ionic 2. The reasons are it has beautiful UI and has plugin for BLE. I have done small work using Ionic 1 in the past, but with Ionic 2 it completely different. I also need to learn Angular 2 and typescript.

Below is the wiring for the project. It's combination from my previous projects. The wiring for bluetooth module are below.

TXD (ble) <--> Pin 7 digital
RXD (ble) <--> Pin 8 digital

Pin 6 digital used for DIN (RGB Led data in)

To test it, you can follow below steps.
  1. Download Arduino sketch from my github 
  2. Upload sketch to arduino.
  3. Download my compiled apk on my github
  4. Enable smartphone bluetooth
  5. Run the app and enjoy
Here is video demo:

So it's time to move on from RGB led project. I have purchased 2 small servo and pan/tilt servo bracket. It could be interesting project. Controlled by smartphone ? Why not.

Resources and links

Monday, June 27, 2016

Arduino : Connecting Arduino to HM-10 Bluetooth 4.0 LE module

We will learn more interesting stuff with Arduino and bluetooth. Basic stuff is connecting Arduino to HM-10 Bluetooth 4.0 LE module which also known as Bluetooth Smart and doing some serial communication. This module has has some interesting feature. Beside of it's reduced energy consumption, another feature that quite interesting is that we can use it as iBeacon.

You can learn more about this module by reading the datasheet here. You can tell the difference with the real one is that it has small crystal on it's board.

Mine looks like the one on the left, but it has no crystal component on it. But I can tell you it working just fine.

Here the breadboard wiring created using Fritzing.

Please note that we use digital pin 7 and 8 as serial RX and TX using SerialSoftware library, we can't use TX (pin 1) and RX (pin 0) because it used by computer through USB. 

And here what is looks like on real breadboard.

The power led will blinking when it's connected correctly. Note that the module has it's own breakout when I bought it. So it will safe to connect it directly to the Arduino 5V pin. On the market it may sold as just the module. You need to use 3.3V Arduino pin or you can create voltage divider circuit to drop voltage to 3.3V.

Test using your phone by enabling bluetooth. You should see the BT05 on your bluetooth device list like below. Note that this default bluetooth settings. I'll cover how to configure bluetooth on my next post.

To test serial communication between Arduino and phone follow below step.
  1. Download Arduino sketch here compile and upload.
  2. Open Serial monitor on Arduino IDE (Tools > Serial Monitor) use 9600 baud rate.
  3. Download MSMBle from Google Play Store, this app easy to use and just works, not like other app I have installed
  4. Start the app and scan for existing BLE device.
  5. Select service for bidirectional communication, so phone and Arduino can talk each other (Service UUID: 0000ffe0-0000-1000-8000-00805f9b34fb)
  6. Try to send text from MSMBle and it should displayed on Arduino Serial  monitor instantly
  7. Then try to send text from Serial Monitor and it also should displayed instantly on MSMBle app
If above test working, you have basic understanding on serial communication. You can create any device application controlled by phone. From home automation to robotics. The limit is just your imagination.

Here is the video demo.

Next post, I'll post how to control RGB led from Smartphone using bluetooth. Happy hacking!

Saturday, June 25, 2016

Arduino : Controlling PL9823-F8 RGB LED

I have great passion about electronics since I was in middle school then high school. With some of my school friend that has same passion in electronics, we built radio transmitter so we can communicate each other at anytime. It was so cool back then. Thats why I took study on electrical Engineering. Instead of working on Electrical engineering field, I end up become web programmer. Something I found interesting when i was in college.

That's old story. But lately I get bored and try to get another hobby. I have many hobbies and creating electronics stuff is one of it.

So I bought my self Arduino Uno and few electronic components to get started learning Arduino programming. So my first project is controlling RGB Led. Here what you need:
  1. Arduino Uno with usb data cable and Arduino IDE
  2. Install Adafruit Neopixel library
  3. 3 PL9823 RGB led
  4. Breadboard
  5. Jumper cables (mostly male to male)
First you need to install Arduino IDE. You can download it here.  That would depend on your operating system. I have Mac OS X version installed. Here what we have after installation.

Install Adafruit Neopixel library. From Sketch > Include Library > Manage Libraries and click install then restart IDE. You will need internet connection to  do it.

For RGB led, I use PL9823. Download the datasheet here. Make sure you have correct pinout connected to each other and power source. If not you will burn your LED and not usable anymore. Below is correct pin according to datasheet.

Check the breadboard wiring below.

These RGB led are common cathode. Which mean the long led pin will be connected to ground. DIN first led connected to pin 6 Arduino digital output pin. Then DO will be connected to another DIN led and perform led strip. 

Power up your Arduino by inserting the USD cable data to the computer. Configure port and board type. Download my sketch for this here then run and upload to Arduino.

Here is the demo:

Interesting right! I'll upload and post another article of my learning on Arduino. Good luck and Happy hacking!