DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • Cypress Tutorial: A Comprehensive Guide With Examples and Best Practices
  • How Agile Works at Tesla [Video]
  • Which Is Better for IoT: Azure RTOS or FreeRTOS?
  • RAML vs. OAS: Which Is the Best API Specification for Your Project?

Trending

  • Cypress Tutorial: A Comprehensive Guide With Examples and Best Practices
  • How Agile Works at Tesla [Video]
  • Which Is Better for IoT: Azure RTOS or FreeRTOS?
  • RAML vs. OAS: Which Is the Best API Specification for Your Project?
  1. DZone
  2. Data Engineering
  3. IoT
  4. Automatic Detection of iBeacon Failure Using Raspberry Pi

Automatic Detection of iBeacon Failure Using Raspberry Pi

Ashok Yalamanchili user avatar by
Ashok Yalamanchili
·
Apr. 14, 15 · Interview
Like (0)
Save
Tweet
Share
6.28K Views

Join the DZone community and get the full member experience.

Join For Free

1. abstract

the emergence of ibeacons as a micro location provider has created a number of solutions provided by different vendors in this space. given the quantity of beacons involved in each implementation, monitoring and maintaining the beacons have become time consuming and effort intensive increasing the maintenance & operational costs. this paper discusses about igate’s solution to detect the ibeacon failure using raspberry pi and the probable challenges that could be faced during the implementation.

2. problem statement

recent trends show that ibeacons, small battery powered bluetooth low energy (ble) devices, are being extensively used in retail stores for pushing promotions and indoor positioning. each of these beacons has a typical battery life of 6-8 months depending on the type of battery used. with a relatively huge setup that needs managing at least 500-600 beacons, manually monitoring the health of each beacon is time consuming and increases maintenance costs significantly. also if any one of the beacons has malfunctioned, detecting it might take more time which can result in loss of revenue to the retailer.

3. about raspberry pi

the raspberry pi is a credit card-sized single-board computer developed in the uk by the raspberry pi foundation with the intention of promoting the teaching of basic computer science in schools.


figure 1: raspberry pi

in 2014, the raspberry pi foundation launched the compute module, which packages a raspberry pi model b into module for use as a part of embedded systems, to encourage their use.

the raspberry pi is based on the broadcom bcm2835 system on a chip (soc), which includes an arm1176jzf-s 700 mhz processor, videocore iv gpu, and was originally shipped with 256 megabytes of ram, later upgraded (model b & model b+) to 512 mb. the system has secure digital (sd) or microsd (model a+ and b+) sockets for boot media and persistent storage.

the foundation provides debian and arch linux arm distributions for download. tools available are python as the main programming language, with support for bbc basic , c, c++, java, perl and ruby.

4.proposed solution

the proposed solution uses a raspberry pi and usb bluetooth adapter to detect the beacons in its vicinity and communicate the information to the server every 10 minutes using a shell script. the shell script is run as a cron-job every 10 minutes for a duration of 1 minute to scan the ibeacon bluetooth packet data. once the ibeacon data is uploaded to the server, it will decide the ibeacon status based on the last updated timestamp of the  beacon on the server.

5.components of the system

hardware : raspberry pi, usb bluetooth 4.0 adapter, ibeacons
software : shell script, server application

figure 2: components of the system

6.implementation:

here is a list of steps involved for implementing the solution

6.1 preparing the raspberry pi

installing the bluez sdk, will add bluetooth capability to the pi.

once the usb bluetooth adapter is connected to the pi, the device status can be checked using the shell command

sudo hciconfig hci0 status

if the status shows “down”, the device has to be started using the command

sudo hciconfig hci0 up

once the device is up and running the shell script to detect the beacons can be run through command line or added as a cron-job that will run continuously for every 10 minutes

ibeacons are placed around the raspberry pi for it to be detected

6.2 shell script:

the shell script uses the hcitool to read the bluetooth packets near its vicinity and the script is used to filter the ibeacon packets in the list.

the shell command to read the bluetooth packets is
sudo hcitool lescan –duplicates &

the shell script, in turn, processes the ibeacon packets to retrieve the uuid, major id, minor id, rssi, and power which will be uploaded using curl to the server using a web service.

one major challenge was that the hcitool scan sniffed the packets at a higher rate than the script could process, which resulted in the readings getting processed very slowly. as the script runs continuously to scan bluetooth packets, there was a major delay in processing by the script which will led to delayed messages sent to server. to avoid this the script is run as a cron-job every 5 minutes and will last for 20 seconds every time.

timeout 20 ./ibeacon_scan.sh

this will make sure that there would be minimal delay in sending the bluetooth scan readings to the server for processing, and the server can, in turn, detect the ibeacon failure with a maximum delay of 10 minutes.

6.3 server application:

the server application consists of a web service and also a web based front end to show the beacon status on a store layout. the web service gets the data from the raspberry such as the ibeacon’s uuid, major id, minor id, rssi, and also the time stamp of the ibeacon packet reading. this data is updated on the database for the beacon table with the last  updated time stamp for the beacon. a cron scheduler will check the current server time with the last updated timestamp for the beacon, and if this difference is more than 10 minutes, the beacon status will be updated as not working. the web based front end that shows the beacon status as red/ green will get updated accordingly.

7.challenges in implementation

some of the challenges faced during the implementation is listed below

the raspberry pi itself can fail for multiple reasons like power failure or some other reasons. this can be taken care by maintaining the last updated date of the raspberry pi.

detecting multiple beacons with the same uuid on the raspberry pi will fail as the ibeacon packet read by the raspberry pi will not have the mac address of the beacon

absence of any http framework on raspberry pi for handling web service calls to server for data exchange ended up in using a lot of low level functions on the raspberry pi.

8.conclusion

as 500-600 beacons are involved in an implementation, beacon failure detection will be time consuming and expensive, if done manually.  a raspberry pi combined with a bluetooth adapter and a server application can be used to detect ibeacon failure with a maximum delay of 10 minutes as given by the solution given in this paper. this solution eliminates the need for manual checking of  the beacons failures.

raspberry pi Web Service shell Shell script Database application Data (computing) Implementation Command (computing)

Published at DZone with permission of Ashok Yalamanchili. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Cypress Tutorial: A Comprehensive Guide With Examples and Best Practices
  • How Agile Works at Tesla [Video]
  • Which Is Better for IoT: Azure RTOS or FreeRTOS?
  • RAML vs. OAS: Which Is the Best API Specification for Your Project?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: