Android App using Sensoro Beacons and Azure IoT Hub

Giuseppe Capaldi
6 min readApr 11, 2019

In this article we will talk about our group mini project at IoT course in Sapienza University of Rome, called Easy2Park.

Github reposiotry of project: https://github.com/GianlucaCapozzi/Easy2Park

Starting from three different Sensoro beacons and the suggestion to use Azure IoT Hub cloud service, we managed to build a simple demo Android App. Our goal was to exploit Bluetooth connection towards smartphone and cloud potentiality in order to help people finding parking lots inside car parks.

The working group

Group was composed by three students:

What is a beacon?

In a nutshell, beacons are hardware devices, sometimes equipped with some additional built-in sensors , which constantly broadcast Bluetooth frames through radio signal within range of few square meters. The name “beacon” derives from the lighthouse helping sailors as soon they approach its visible area. The same logic is present in our beacons where the lighthouse is the beacons device, the visible light is Bluetooth radio signal and the sailors are bluetooth-equipped devices like smartphones (receiver-side). Many beacons work with Bluetooth Low Energy, so batteries can last at least five years on average still guaranteeing enough data rate for many IoT applications.

Bluetooth (Classic) vs Bluetooth low energy:

In Classic (not BLE) Bluetooth we have these features:

Pro

  • It can handle lot of data consuming more power

Cons

  • Low data transfer rate.
  • Short range of operation
  • Classic Bluetooth once initiated , it always in wake up mode even not in use raising power consumption.

While Bluetooth Low Energy (BLE or Smart Bluetooth) improved Bluetooth in small data packet transmission situation like this:

Pro

  • High data transfer rate
  • Medium range of operation
  • BLE goes to sleep once not in use and wakes up once data/information transfer happens.
  • Low power consumption

Cons

  • Handle very less data

BLE Beacons vs GPS sensors

We all know how much GPS tracking can be useful and easy to use (consider where you’d be without Google maps) but it’s still not perfect. If you are in a building with multiple floors in it, GPS cannot tell you accurately floor or room in which you are standing. Also in places like underground car parks, GPS signal can be easily lost.

Here beacons come into play.

First thing is to place beacons in specific high point of the room (the higher the better, cause Bluetooth signal suffers from bodies and building penetration resistance). So you need to choose a right spot depending on how much distance range you need to cover. Once beacons are set you will only need an app with active Bluetooth connection receiving packets containing:

  • Beacon SN
  • Major ID
  • Minor ID
  • Sensor Data (temperature, accelerometer…)
  • Device Data (battery status, system info …)

The first three fields help the receiver to distinguish between different beacons, sensor data are used in your application and device data are useful for debugging and monitoring purpose.

Beacon or device exact position can be triangulated, where distance is retrieved by RSSI level, there are several projects on the web with this purpose (e.g. https://proximi.io/accurate-indoor-positioning-bluetooth-beacons/). However the most reliable distance based application is the kind based on signal area covered by beacons or at most beacons-receiver point to point distance.

Triangulating schema

Who is Sensoro ?

SENSORO is a company that is developing Bluetooth low-energy smart sensors and transmission technology. Its focus is on front-end sensors, alpha-based IoT base stations, big data analytics and marketing. They produce four different types of Bluetooth beacon devices.

What were our starting ingredients?

We had 3/4 different types of beacons to be used.

These were the devices Professor give us.

They are three BLE beacons, two of them featuring temperature sensors.
To hide low-level BLE protocol communication we found a useful (but a bit out-dated and under-documented) repository with sdk ready to be implemented: https://github.com/Sensoro/SDK-Android

Here we found a useful sample to start with: “BootCompleted” Android app. It contains simple callback methods called when entering/leaving beacon signal areas. They can be easily customized for your application.

How we used them?

Unfortunately our beacon built-in sensors was just about temperature in the room, this made difficult to do something like presence recognition of cars in parking lots (which was our starting idea). However we decided to use presence based connection to beacons to do some simple statistical data analysis and then get back result to user.

So the next step we took was about Azure Iot Hub.

What is Azure Iot Hub and how does it works?

Microsoft Azure is a complex set of cloud services ready to be configured and used in pay as you go fashion. Letting you create, manage and deploy professional application very quickly. At first the challenging part is to choose the right services for your application, understand how they can be managed and connected between them. The best thing is to read carefully the online documentation and Microsoft Azure pdf guide.

Global view of some Azure services interconnections.

How we used Azure

Our idea about Azure implementation in our project was to establish a bi-directional communication between the user device and Azure cloud system. This was possible integrating different services of Azure system e.g. stream analytics, database servers and online API. In this way user could take advantage of data integration happened in cloud and visualize otherwise impossible to obtain information such as the number of people entered the parking that day.

Azure back-end services we used.

From mobile app to Azure

The first part is made customizing azure example to send data from a mobile app to Iot Hub and then Azure stream analytics to visualize data sent from the android mobile app in Cloud. However we also needed to add a db server able to store data received from android application which are beacons-client information. So we chose a MySQL server service in Azure and created the correct tables. After some string connections specification made on the Azure website portal the three services on Azure were talking to each-other and we were able to store data from the smartphone onto the server db. Now we needed to bring back data to client in order to make the app somehow useful.

From Azure back to mobile app

Our idea was to group user data by beacon ids (identifying a sector of the car parking) and specific days counting how many different devices entered into the parking. To do so we customized an example making a TodoList cloud app in order to connect it to our database and execute our query from API callable from device. As far as we went, we were able to have the API making the query that we managed to insert into Android code in the future.

Final Conclusion

This project was very interesting and involved many different coding languages (nodejs and Linq for the backend, SQL for the d.b., Java for the Android) and knowledge about Azure portal (very powerful but not so well documented because of its frequent changes and sometimes dispersed), Android Studio app developing, Beacons SDK.

Sources

--

--