Being safe and being aware go hand-in-hand. Many corporations and governments focus on the safety of their employees and invest in teams of OH&S (Occupational Health and Safety) personnel dedicated to training employees to assess risks in the work place. Countless procedures and documents are made available for all staff to review, understand, and remember.
However, it could be considered short sighted to expect employees, whether they work at the same location every day or just pass by on occasion, to actually be aware of what hazards could potentially affect their health and well being.
So how can employees become aware of local hazards and stay safe? The answer is the Hazard Zone Awareness mobile app constantly scanning for hazard zone beacons to immediately alert the employee of nearby hazards and provide them meaningful information to properly assess the risk to their health and others nearby.The Answer
What we have here is proof that a low cost and easy to maintain system can be put in place to help protect people by providing immediate and relevant information about their location that works in any indoor or outdoor environment. This project will explain how to get started with integrating a low cost, low maintenance Bluetooth beacon that can collect data about its environment that includes an Android app and simple configuration of an open source web site to manage data.
Quite simply, a beacon is placed in a zone with some kind of hazard for a mobile device to discover and alerts its operator of the local hazards.
This project focuses on hazards in an industrial work place, primarily thinking about chemicals used throughout facilities or for vehicle maintenance.
However, this beacon alerting concept could be applied to many scenarios, not just hazardous chemicals.
- Inspectors can place beacons where regular inspection is required and specific forms are required for each location. Instead of carrying around paper, the beacon could instantly open the correct webpage form on their tablet device.
- Contractors could place beacons to instantly have access to relevant documents to finish constructions.
- Cleaning staff could receive special instructions about offices or meeting rooms.
- Guests could be alerted to stay within their designated areas and have access to facility phone numbers for help
- Outbreak awareness could use beacons to alert various staff or patrons that certain areas are quarantined or safe. The app connects to a server in real-time so information is always up-to-date.
- Asset tracking beacons could be left in containers to identify contents, destinations, and contacts.
- Museums could use beacons to provide information about the current space patrons are visiting.
- Beacons could help the elderly remember to check in when they return to their home.
Here is a video demonstrating how the app responds to beacons each with its own hazard severity:
VIDEO: HZA Live Test (with sound)
Here is a screen capture of the same app with a little more depth (and visual clarity)Self Introduction
I did this project as part of a competition on Hackster.io called Transform Your Thinking with ON Semiconductor. I immediately found the hardware to be intriguing especially because I work in a large organization that maintains many buildings and vehicles. Every time I walk through these buildings, I pass by all sorts of equipment connected to containers with faded labels. Some of them appear to be leaking. Or is that condensation? How can I find out? Who would I talk to? I always feel uneasy not knowing and surprised at the number of people I ask about it that also have no idea. There must be a better way. And then I found this competition looking for ways to show off the extremely low power Bluetooth device. And so it began.
I had never used this hardware before but am familiar from many years ago with embedded design and coding. I also had a good sense on what web server package to use.
Mobile development on the other hand is completely new to me. I had never made a mobile app before, but for someone with some experience a very nicely polished app can be done easily.
Let's gone on with it now.The Parts
- Segger J-Link LITE Cortex-M debugger
- Computer for developing code
- Computer or web server to host website
- Android Oreo device with Bluetooth low energy (BLE)
Outside of the typical installation documentation, there is nothing physical to build unless you require an enclosure for the beacon.The Development
Here are the high-level steps to have a functional system with the ability to customize the user experience.
1. Program RSL10-SENSE-DB-GEVK to act as Bluetooth beacon
2. Create mobile app to monitor for the beacon and alert the user
3. Create a web server to manage the severity of certain hazards and to log human traffic near the beaconRSL10-SENSE-DB-GEVK Code
A Bluetooth beacon can be used to announce to any nearby device listening that there is something of interest here. Bluetooth beacons are not new, but also have not always been practical for all scenarios due to power requirements. Bluetooth has evolved and new technologies allow low-power devices with advanced sensors to make these beacons much easier to manage. This is where the ON Semiconductor steps in with the RSL10 series of ultra low-power chips to play. The RSL10-SENSE-GEVK can run up to a year on a single CR2032 coin cell and is the device is not much bigger.
The RSL10-SENSE-DB-GEVK is programmed using the Segger J-Link Lite Cortext-M debugger. It’s important to follow the instructions exactly as they are written in the RSL10 guide. Skipping ahead may lead you down a path to register the Segger software which is not necessary. If you follow well, you’ll have quick success. The product datasheet has the required steps to install the development library and get programming. All the links to the J-Link software and ON Semiconductor IDE are included in the product data sheet.
When attaching the J-Link to the low cost debugger, the red wire on the towards the bottom and the cable should be stretching across the board. Here is the picture right from the installation guide:
Since I was new to this RSL10 board, I experimented programming with the included examples, such as a the Blinky sample program; another example of where following the instructions leads to quick success, but also to become familiar with the environment. After a few attempts, I was able to understand the work flow and was ready to take on making a Bluetooth beacon.
While testing Blinky, I became familiar with the CMSIS Pack Manager. In here, I found exactly what I needed – A complete and well documented example of a Bluetooth beacon using the Eddystone standard. The catch was the example was built for a different RSL10 board, the RSL10-COIN-GEVB. That board has the same great RSL10 BLE capabilities but lacks additional sensors. What was also very interesting was the included FOTA (Firmware Over-The-Air) that would allow me to update the program using my mobile phone instead of the Segger J-Link debugger cable.
Before compiling the Eddystone Beacon Firmware, it’s important to remember it was written for the COIN board, not the SENSE board. Once again, learning with Blinky makes this easy to resolve. Since the RSL10 is the same, all the Bluetooth work should be compatible, but anything depending on off-chip input/output needs to be mapped correctly. Fortunately, the code is done well enough that reviewing Blinky’s PIN MAP identified what the correct settings should be for this beacon sample.
Can’t say this enough, following the instructions as is without skipping ahead saves a lot of headache.
Getting the FOTA bootloader loaded depends on careful attention to the instructions. Read the readme files in ON Semiconductor IDE project.
Installing the beacon firmware is done using the RSL10 FOTA mobile app. The app worked very well but I did struggle to get the beacon to enter what's called "DFU" (Developer Firmware Upgrade) mode which loads the bootloader for 30 seconds if no connection from the RSL10 FOTA app is made. I found that pressing Button 1 (on the edge) three times quickly was not sufficient. Pressing the button as fast as I can until the GREEN LED stayed solid for a moment worked really well! It may take a few attempts.
To test, you can install the RSL10 Sensor Beacon app or any other generic beacon scanner app.The Web server
The web server is intended to allow customization and tracking of what is happening with the beacons. You could easily adapt this for other purposes but this project is to make people aware of potential hazards in the area.
I chose to use the open source Drupal content management system to manage the data. Drupal 8 has a lot of flexibility to design the type of content and an API using JSON format to read and write content using a mobile app. If you don’t already have a compatible server, the free XAMPP package of open sourced software tools is simple to install and use and meets all the basic needs to get going.
Here is a thought exercise to think about what and how the data is managed.
A “Facility” is a building or place that houses smaller spaces or zones that may contain some type of hazard. For instance, imagine a beautiful botanical garden and think about what is required to maintain such a large space for visitors to enjoy. Located throughout the different gardens could be sheds that contain fertilizers, herbicides, insecticides, fuel, and antifreeze. Perhaps hazards include dangerous equipment or tools or even structures that contain asbestos and no one should enter. Not everyone will know what potential risk lies before them, so a “Beacon” will be placed in a “Hazard Zone” containing one more “Hazards” all of which are located at one “Facility”. A mobile app will detect the beacon, exchange data with the server, and alert the phone’s owner of the severity of the risk, a link or document to understand how to handle the hazards, and provide a phone number to call.
In Drupal, various content types are needed to accomplish the bare minimum for Hazard Zone Awareness and need to define their relationships. Really plan out how the data flows and what data needs to be stored.Content Types for Drupal
Facility – Name, phone numbers, Hazard Zones
Hazard Zone – Name, owning Faciliy, Hazards, Beacon
Hazard – Name, severity or risk level, document or link to safety information
Beacon – Unique beacon ID, Hazard Zone, Facility
Imagining the garden again, it may be necessary to collect data about who is visiting Hazard Zones. Creating a log of activity could be hugely useful to an OH&S group that strives to continuously improve. With only minimal data, it would be possible to know the number of people coming and going out a Hazard Zone, how much time is spent there and when the busy times are.
Beacon Log – Beacon ID, date and time, entering or exiting Hazard Zone
If the capability exists to log beacons, then there is potential to collect data about the Hazard Zone itself. The RSL10-SENSE has many sensors that could be invaluable to safety conscious organizations.
Some modification to the firmware different sensor data could be captured and embedded into the beacon message. The Eddystone TLM allows just two 16 bit messages be sent. Keep in mind that some sensors, like Air Quality, require more battery power then others.
- Absolute Orientation
- Air Quality
- Ambient Light Sensor
If the Beacon Log includes a unique user ID, suddenly it is possible to track who is going to a Hazard Zone without the proper training. It’s also possible to identify some users as OH&S Inspectors and keep report when a Hazard Zone was last inspected – critical for keep documentation up-to-date.
Configure the following content types in Drupal
The Beacon Log is generated by the mobile device app, so look at this as an example, not to create manually.
Include any fields that make sense for your project.
After creating your projects content and running the beacon and app, you may see similar content in Drupal like pictured below. You can see the content types. Clicking on any of them will show the details you entered. There is a lot of flexibility here so you can tune this to meet your needs.
If you are new to mobile device development, like I am, then choosing the right tool to get started is important. After testing several platforms, I decided to go with the latest Android Studio development environment (I was at version 3.6.1). It has thoughtful intelligent helpers to catch programming errors and makes suggestions. The main reason I selected Android Studio was the vast amount of YouTube videos showing how to do whatever it is you are stuck on. Programming in Java was also a first for me, but it is similar to C language so it is quickly familiar after working with Blinky and Eddystone Bluetooth Beacon firmware.
What helped me most working on something I had never done before was planning small milestones, something that could be reasonably be achieved in a few hours of Googling.
Thankfully, the good people of Radius Networks released to open source the Android Beacon Library that takes care of all the complicated coding to control your mobile device’s Bluetooth Low Energy device and reads the beacon generated by the RSL10 device. Without this library, a new user could be overwhelmed, especially with managing newer version of Android OS.
If you don’t want to use Eddystone beacon format, both the RSL10 and the Android Beacon Library can be updated for your proprietary format with little effort. The sample code and reference app have everything that is needed to get started and the Stack Overflow community has lots of help waiting. This library is also available for iOS and Windows and the code, though different syntax, should have similar workflow.
It's important to learn about the OS features. The internet is filled with advice about older versions but as time goes on, both Google and Apple change behaviors at the core of the OS. One example for Android is some power management features. In older versions, background scanning for beacons was allowed. Then Google put time restrictions on background tasks and limited Bluetooth scanning to 15 minutes. And so, for this project to be useful, foreground scanning needed to be implemented. This creates a permanent message on the notification screen that this app is running constantly. This is great for the end-user, but something that needs to be understood for the developer.
Below is a flow chart illustrating the core logic. The mobile device is always scanning for beacons. On one side, a broadcasting beacon comes into range. The mobile device continues to scan and sees the same beacon over and over until suddenly the beacon is no longer seen, illustrated on the right side.
Mobile Device Workflow
The Hazard Zone Awareness app's user interface is simple and demonstrates the concepts. You may not want to show place holders in a production application.
In the screenshot below, it should be apparent how all three core components fit together. There is a placeholder for the beacon ID and a rough idea of the its distance and the data configured in Drupal will populate as well.
When a beacon is observed the app creates a notification, plays an appropriate sound based on the health risk, and updates the screen content. The app will automatically launch when a beacon is detected.
Clicking on the Safety Data Sheet link will open the mobile devices default browser. In this example a PDF file is loaded.
And finally, when the beacon is out of range for 10 seconds, the phone is alerted again with a more pleasant sound and the log is updated on the Drupal site.
Because I was interested in tracking users, I also set up a "Settings" page to hold the user name. Pop ups will notify the user that a blank name is not allowed. I thought that since I have a settings page, it might be nice to give the user the change to disable the beacon scanner in case they have no need to use it want to maximize battery life.
Here is the same video provided at the beginning that shows how these features work.
VIDEO: HZA Live Test (with sound)The Final Steps
At this point, the beacon is broadcasting, the mobile device is receiving those signals and exchanging data with server. If you followed along, you'd have set up just one record set for a garden shed in a botanical garden that has oil stored in it. The next steps would be to populate the database with meaningful, real-world data while considering what the end user will get out of the experience. Documents and links should be informative to the person being alerted.
Since there is the ability to log employees entering and exiting hazard zones, there exists a lot reporting potential.
The Training content type can be used to find users that are entering zones but don't have the right training. It would also become possible to only alert employees that have not been trained by making a few changes to the code.
Looking at amount of foot traffic through a zone may prompt some safety changes.
Utilizing different sensors on the beacon could have enormous potential for monitoring working environments.
Please enjoy whatever project you have in mind next and keep doing on those milestones.