Wednesday, April 29, 2015

Configuring the Ibeacon to Detect other BLE(Bluetooth 4.0) Devices with Raspberry Pi and Python

The Ibeacon from Ziruz Technologies is not just simply an Ibeacon, it can also be configured to detect other Bluetooth Low Energy(BLE) devices. And more recently, one AT command has been added to make the Ibeacon detect other Ibeacons, but the HM10 module will need a firmware upgrade so that the new command will be available for use.

We can use the previous setup we used in my previous article(Configuring Ibeacons using Raspberry Pi B+ and Python) so that all we need to do is create a python program. And here is the python program I used to scan other BLE devices:
import serial
import time
port = serial.Serial("/dev/ttyAMA0", baudrate=9600, timeout=3.0)
port.write("AT+RENEW")
rcv = port.readline() 
print rcv
rcv = ""
port.write("AT+RESET")
rcv = port.readline() 
print rcv
rcv = ""
port.write("AT+ROLE1")
rcv = port.readline() 
print rcv
rcv = ""
port.write("AT+IMME1")
rcv = port.readline() 
print rcv
rcv = ""
port.write("AT+SHOW1")
rcv = port.readline() 
print rcv
rcv = ""
while True:
    port.write("AT+DISC")
    rcv = port.readline() 
    print rcv
    rcv = ""
    time.sleep(10)

The AT+DISC will scan all BLE devices and will just return the MAC address, the newest firmware version has the command AT+DISI? and this command will return the UUID, RSSI, Major, Minor, Measured Power and the MAC Address. The command AT+DISI? is available with firmware version V539, to check the version of the firmware use AT+VERS?

If your current Ibeacon does not support the latest version, you can update the firmware by following this procedure.

6 comments:

  1. Hi John,

    Thanks for your blog on the HM-10.

    I've been trying to get these to work with the AT+DISI? command without any success.

    I wish to connect an HM10 to an ESP8266 and put one in each room in my home. the HM10 would just provide the esp8266 with any ble devices it sees and their respective rssi values which can then be centrally processed on a RPi and determine the location of a beacon device.... i just cant get the HM-10 to work as i think they should!


    Have you had any luck with the AT-DISI? command??

    Cheers,
    Greg

    ReplyDelete
  2. Hi Greg,

    Thank you for visiting my blog. I have upgraded my firmware to 5.40 and I had no problem with AT+DISI? It worked the first time I tested it.

    In case you are having problems this is the file I used:
    https://drive.google.com/file/d/0B1tuk2j-arZSVTc3R1hEbXFuRms/view?usp=sharing

    ReplyDelete
  3. Hi John,

    Yes thats the same version i am using, - could you please confirm the comands you sent before AT+DISI?

    Cheers,
    Greg

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Can anyone post latest command sheet for v540

    ReplyDelete
  6. Great article! Thank you so much for sharing this one really well defined all peaceful info regarding iBeacon BLE Device,I Really like it,Love it- ibeacon app development | ibeacon application development

    ReplyDelete