Monthly Archives: April 2014

How to: Build you own Bluetooth Low Energy IBeacon for 10 $ DIY

IBeacons become more and more popular but most companys charge about 30$ for them. Thats way to much, so lets to it ourselves.
But first… the Shoppinglist:

HM-10 ( 6,50$
Battery Holder for Coincells ( 0,20$
Protoboard ( 0,60$
Steel Pins ( 1,50$
CR2025 CoinCell  1,00$

HM10 BLE Module

HM10 BLE Module

First we should have a look in the datasheet (HM10 are made by and search for this graphic:

HM-10 Wiring

HM-10 Wiring

Important for us are actually only UART_TX, UART_RX, GND and 3.3V. If you want you can also use pin23 and pin24 to have leds on you beacon. But using the leds will cost energy.

Next we take the steel pins and bend them in a way that they match the indentations on the HM-10 board. Than we can start soldering.

HM-10 soldered to pins

I also soldered some pins on the right side of the HM-10 this give more stability and it won’t break so fast.
We also need Pins to connect them to a serial interface and flash new firmware or configure the module.

DIY IBeacon with HM-10

to be continued … 🙂

Fix: Bluez keeps crashing

I had the problem that my BlueZ was continuously crashing. Even when I was just using a few commands of for example hcitool or scanned for advertising BLE devices (as example). 

Set scan parameters failed: Input/output error.

I than checked dmesg to find out more:

Bluetooth: hci0 command tx timeout.

At the beginning i tried to shut it down and up again.

hciconfig hci0 down 
hciconfig hci0 up


service bluetooth restart
service dbus restart

And it worked – sometimes :-/ Even better was removing the Bluetooth Stick and plug it in again. But that was annoying. So i figured out how to reset a usb device from command line tool. First use lsusb to find the vendorId and use grep to search for it.

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 004: ID 0a5c:21e8 Broadcom Corp. 

cd /sys/bus/usb/devices/

grep -i -s -r 0a5c *

cd 1-1.2

echo 0 > authorized
echo 1 > authorized

So my usb device was in /sys/bus/usb/devices/1-1.2/. In the moment when you set the value in authorized to 0 the usb bluetooth device is not longer allowed to communicate with your computer (this is what I guess). And after setting it to 1 it is forced to re-init. Awesome. This is a solid solution.


Anyway I was looking for a solution that totally fixes the problem permanently. 
First I updated the kernel to the latest version. Since I was using an raspberry pi this can easily be done be using this commands:

cat /proc/version
sudo rpi-update
sudo reboot

Than i change the content of my /boot/cmdline.txt to:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline dwc_otg.microframe_schedule=1 dwc_otg.speed=1 rootwait

And after rebooting my problem was fixed. 🙂 Change to your cmdline.txt may cause problem with others USB devices. So to change it back later. Backup it first.

HowTo: Install bluez and dbus

I had a lot of trouble installing bluez-5.16 on my Raspberry Pis. But finally i made it and i wrote a little script. Which might be helpful for many of you.

Bluez is supporting the Bluetooth Low Energy (BLE) or Bluetooth Smart stack. So first thing i did was buying a Bluetooth LE USB Dongle on Amazon (DE / US).

Anyway here is the script. It’s pretty ugly written any maybe you should just copy and paste it line by line to install it on your machine otherwise i might miss some error messages that could occure. I’m using bluez-5.17 amd dbus-1.8.0.



if [ “$(id -u)” != “0” ]; then
echo “Sorry, but you have to be root.”
exit 1
apt-get update
apt-get upgrade
apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev
echo “Creating bluez_temp folder”
mkdir bluez_temp
cd bluez_temp
echo “Download: bluez-5.17”
echo “Download: dbus-1.8.0”
echo “uncompressing”
tar –xz -xvf bluez-5.17.tar.xz
tar xzf dbus-1.8.0.tar.gz
cd dbus-1.8.0
echo “install dbus-1.8.0”
make install
cd ../bluez-5.17
echo “install dbus-1.8.0”
./configure –disable-systemd –enable-library
make install
sudo apt-get install python-bluetooth python-requests
sudo hciconfig hci0 up

To avoid a problem that might occur we need to add a permission to the dbus bluetooth config.

sudo su –
cd /etc/dbus-1/system.d
nano bluetooth.conf

and add this


Than restart the service: service dbus restart.