Gym Attendance Monitoring
Gym Attendance Monitoring is a proof of concept of an android application which tracks the user through the gym to monitor the use of the rooms and to have a customer loyalty system. The project is part of the Internet of Things course held at Sapienza University of Rome.
For the correct functioning it is necessary to own the Estimote branded beacons; Microsoft Azure and Grafana technologies will also be used.
How does it work
Track User
GPS cannot be used to track a user inside a building. This requires a different solution. The best method is to use beacons, Bluetooth Low Energy (BLE) components that communicate their presence to the devices around it. It is powered by a non-replaceable lithium battery. They work like a lighthouse, so your smartphone can know which is the nearest one. For our purpose, we have used the Estimote Beacons. We have associated a room with each beacon, so you can know which room the user is in. To integrate them into the application, Estimote SDK have been used.
Store and analyse data
To store user data from the application, you need to store it in a database on the cloud. To do this we used Azure IoT Hub, an open and flexible cloud platform as a service that supports open-source SDKs and multiple protocols. This makes it possible to securely connect, monitor, and manage billions of devices to develop Internet of Things applications. Two databases were used: the first one for user's data and the second one for events (entrance to a room, change of room, abandonment of the room...). The data is sent by the application to Azure thanks to Azure IoT SDKs.
Graphicize the analyzed data
To graph the data stored on Azure, we used Grafana,an open-source, general purpose dashboard and graph composer, which runs as a web application. Thanks to the Azure Monitoring plugin for Grafana, it's possible to queries Azure SQL database to create statics useful for gym's owner.
Installation
First step: configure project
- Import ConnectedGym folder as project into Android Studio.
- In MainActivity.java, replace room_# with the minor number of your Beacons.
Second step: register device on Azure IoT Hub
- Download Azure Cloud Shell
- Login to Azure from command line:
$: az login
- Register your device on the Azure IoT Hub platform:
$: az extension add --name azure-cli-iot-ext
$: az iot hub device-identity create --hub-name YourIoTHubName --device-id MyAndroidDevice
where YourIoTHubName
is the name of the device registered on the azure iot hub platform.
Third step: obtain the connection string for your device
$: az iot hub device-identity show-connection-string --hub-name YourIoTHubName --device-id MyAndroidDevice --output table
Fourth step: send data to Azure IoT Hub platform
- Put the connection string obtained in step 3 in the file gradle.properties
- App will send data automatically if configured
- In order to check if data are sent to azure iot hub you can check this from the azure cloud shell with the following command:
$: az iot hub monitor-events --hub-name YourIoTHubName --output table
Run Android App
- Make sure your Android device is connected to your computer via a USB cable.
- Connect the device to WiFi/UMTS network that allows for communication with the server.
- Make sure your device is set up for development as explained here.
- Change USB mode to data transfer and allow the RSA fingerprint request of access if asked.
- Click on run button on Android Studio GUI and select your device.
Alternatively you can use adb from shell (How to do it)
N.B. You cannot run the app through android studio emulator due to the lack of bluetooth connection.
How to use the app
- Launch the application on your smartphone
- Grant location permissions
- Turn on Bluetooth and GPS
- Enter your details in Account section
- Click Save