Saturday, October 25, 2014

The proper way of turning the HM-10 into Ibeacon

From my few days of testing of HM-10 as Ibeacon, I noticed that just by activating the ibeacon with the following AT command is not enough:
AT+IBEA1

With this configuration alone, HM-10 will still be consuming its normal rated power which is
about :
Rated Power = 3.3V*8.5mAmp = 28.05mW
This would mean it would only take a few days to drain the 580mAH Lipoly battery with this configuration but of course, the broadcasting range is still be at the confirmed value of above 100meters.


But if your requirement is just for indoor use and would want it to consume much less power, here is the proper way to configure the BLE module but take note that the lesser power it consumes, the shorter the broadcasting range it becomes and for sure with this configuration, it can not go further than 10meters:



 With this configuration, the HM-10 BLE Module can drain the fully charged 580mah lipoly battery in 6 months.

Friday, October 24, 2014

More Fun with HM 10

I got more curious about how to use the HM 10 BLE(Bluetooth low energy) module and asked myself if it will really be able to pair with arduino and instruct the arduino to do some tasks via an android phone. So did some research if anyone from the internet has posted similar project and I was so lucky that I found one that I thought is easy and would simply answer my question.

The original post can be found through this link: Control RGB lights from Android with Arduino & Bluetooth LE (BLE)

Aside from following the processes exactly as described in the article, I also did some twist to adapt it to what is available in my chest. The first thing I did is to deactivate the ibeacon function by issuing the following AT command:
AT+IBEA0
To check whether ibeacon function is activated or not, this AT command is used:
AT+IBEA? 
HM-10 will respond: OK Get 1|0

Ibeacon is activated if it returns 1 and deactivated when it returns 0.

Here are the materials and components I used:
1. HM10 BLE module
2. Arduino Pro Mini 8Mhz and 3.3V
3. Dupont wires
4. The RS232-TTL Adaptor that I used to upload sketch on the Pro Mini
5. Li-Poly Battery
6. BreadBoard

I will still be using the same connection just like what I did in my previous testing of HM-10 and was described in detail in my previous post. If you haven't read it yet, you may click on this link: HM10 BLE Module with Ibeacon .

With that set-up, all I need is to upload the sketch as described in the reference article but since I don't have an RGB LED, I could just use the LED in the arduino pro mini which is connected to digital pin 13. Digital pin 13 is not a PWM pin so I can only turn it on or off and not able to dim it.

I also downloaded the android app in the reference article and installed on my android phone.

Test Result:
It was awesome!!!

Here's the video of my testing:

This is the sketch that I used:
#include <SoftwareSerial.h> 
int bluetoothTx = 3;  // TX-O pin of bluetooth mate, Arduino D2
int bluetoothRx = 2;  // RX-I pin of bluetooth mate, Arduino D3
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
const int redPin = 13;
 const int greenPin = 5;
 const int bluePin = 6;
void setup() {
   // initialize serial:
   Serial.begin(9600);
   // make the pins outputs:
   pinMode(redPin, OUTPUT);
   pinMode(greenPin, OUTPUT);
   pinMode(bluePin, OUTPUT);
  bluetooth.begin(115200);  // The Bluetooth Mate defaults to 115200bps
  delay(100);  // Short delay, wait for the Mate to send back CMD
  bluetooth.println("U,9600,N");  // Temporarily Change the baudrate to 9600, no parity
  // 115200 can be too fast at times for NewSoftSerial to relay the data reliably
  bluetooth.begin(9600);
}
void loop() {
   // if there's any serial available, read it:
  
     if(bluetooth.available())  // If the bluetooth sent any characters
  {
  while (bluetooth.available() > 0) {
     // look for the next valid integer in the incoming serial stream:
     int red = bluetooth.parseInt();
     // do it again:
     int green = bluetooth.parseInt();
     // do it again:
     int blue = bluetooth.parseInt();
     // look for the newline. That's the end of your
     // sentence:
     if (bluetooth.read() == '\n') {
       // constrain the values to 0 - 255 and invert
       // if you're using a common-cathode LED, just use "constrain(color, 0, 255);"
       red = 255 - constrain(red, 0, 255);
       green = 255 - constrain(green, 0, 255);
       blue = 255 - constrain(blue, 0, 255);
       // fade the red, green, and blue legs of the LED:
       analogWrite(redPin, red);
       analogWrite(greenPin, green);
       analogWrite(bluePin, blue); 
 }
 }
}
}

I am still using the software serial library because that was my previous setup and I wanted to use the original serial port to communicate with the pc when ever it is needed or necessary.

Saturday, October 18, 2014

HM10 BLE Module with Ibeacon

Upon learning that somebody has just posted a HM10 BLE module at olx.ph, I immediately contacted the seller and bought 1 for my testing. HM-10 is not only just a Bluetooth low energy(ble) module but can be used as ibeacon as well.

It is so easy to use and adding an arduino is very easy. I used the following circuit diagram and it just so happened that my arduino pro mini is a 3.3V 8mhz which is just perfect for the HM-10.


I also bought a small lipoly battery(580mah) just to do some experiments on how much time it will take before hm-10 can drain the battery.

Here are some pictures of my setup:




 

As usual, I could have never done the soldering part without the help of my cellphone technician friend.

During my testing, the battery with 1 hour of charging could last up to 1 day, that is just probably at 15% charging, so may take a week when fully charged.

I used the following sketch to test the HM-10 Module with arduino:
#include <SoftwareSerial.h> 
int bluetoothTx = 2;  // TX-O pin of bluetooth mate, Arduino D2
int bluetoothRx = 3;  // RX-I pin of bluetooth mate, Arduino D3
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup()
{
  Serial.begin(9600);  // Begin the serial monitor at 9600bps
  bluetooth.begin(115200);  // The Bluetooth Mate defaults to 115200bps
  delay(100);  // Short delay, wait for the Mate to send back CMD
  bluetooth.println("U,9600,N");  // Temporarily Change the baudrate to 9600, no parity
  // 115200 can be too fast at times for NewSoftSerial to relay the data reliably
  bluetooth.begin(9600);  // Start bluetooth serial at 9600
}
void loop()
{
  if(bluetooth.available())  // If the bluetooth sent any characters
  {
    // Send any characters the bluetooth prints to the serial monitor
    Serial.print((char)bluetooth.read()); 
  }
  if(Serial.available())  // If stuff was typed in the serial monitor
  {
    // Send any characters the Serial monitor prints to the bluetooth
    bluetooth.print((char)Serial.read());
  }
  // and loop forever and ever!
}

To test the sketch,  just open the serial monitor of the arduino IDE and type in "AT" at the text box then press the "send" button. If the HM-10 is connected properly, it will respond "OK". All AT commands are available at the datasheet which can be easily found on the internet.

I also tested the transmission range if it can reach 100meters, and here's the result on my android phone:

It was able to reach 125.5meters.

I am very satisfied with the results of my testing and this is really one of the best Ibeacons that is on sale at olx. But for some other purposes, like when you just need simple ibeacon apps that are short range these ibeacons can be very useful too:

Monday, October 6, 2014

Just another Ibeacon App Idea

You can not just let chance get you find it. I am quite sure that it is but natural to find or look for someone that is very much compatible to you somewhere. And you can increase further the probability of finding that someone with technology and perhaps ibeacon with a nice app for this purpose could be the best answer.

The Hardware
The hardware need not be expensive, find an ibeacon and configure it to describe your self. This is done by just renaming your personal ibeacon with your name. And of course a phone capable of receiving ibeacon signals. If you still don't have a pc, you can go to an internet cafe or you may use your phone as well.

The Software
An android or IOS app must not only be obviously installed in your phone but must also be installed in that special someone's phone in order for him or her to receive your message ans so do you. So the app must be opened all the time and the phone must be connected to the internet. If ever you get near that someone, the app will alert you and he/she as well. The alert should be like your picture should appear on his/her phone with 3 buttons that should allow both of you to either just ignore the alert, invite for a short chit chat, or just send a message.

This is a social networking app so there must be a website where you have registered and uploaded your picture and some personal information, the description of your special someone. The latter is very important because the android app will use it as basis for locating that special someone.

Someone can be very dishonest about their preferences so perhaps the web based application would use data mining to increase the accuracy of matching the perfect someone that you are looking for.