Hygiener- IOT Hack


Last week had the chance to participate in a hack with fellow Microsoft'ians at an internal hack event. Our team had four participants - Manish Sharma, Deepthi Anatharaman, Shubham Kumar and yours truly. The hack was around the concepts of  IOT, Azure IOT Hub, Azure Machine learning, Power BI and Azure Data factory.

Our topic was 'Hygiener' - A product that aims at finding the hygiene index of a workplace by placing sensors at Doors and on the Disinfectant bottles, Sensors send information about how many times the door was operated to get inside/outside the workplace/Washrooms/Hospital Wards, and how many times the dis-infectant bottle may have been used by finding if a person's hands were too near the bottle. The data is sent to Azure IOT Hub, where the stream analytics Jobs make sense of data and sends it over to SQL from where the Power BI Reporting could show views over this data. Additionally the raw data is dumped in Azure Data lake for further analytics. A Machine learning implementation on top of the same data can reveal interesting insights like predictive Hygiene Index, or if one can gather the relative attendance in the workplace, Machine learning models can also suggest how attendance will fares against the hygiene index of the workplace.

Hygiener Architecture

Hygiener Architecture

The product consists of an ultrasonic sensor based device and a door toggle device.

The ultrasonic sensor based device is placed on the disinfectant bottles and if someone goes quite near the bottle to get the disinfectant the ultrasonic sensor readings will tell us.

The door toggle device on the other hand provide the information about if the door was opened or closed, a couple of these readings will tell you that approximately how many people entered the area, it may not be too accurate as more than one people can enter a workplace while one person opens the door, but lets say its a corner case for us for now, later on one can use techs like Kinect based sensor to find out exact number of people entering or exiting.

Both sensors are attached to Raspberry Pi's running Raspbian, and registered with an Azure IOT hub.

HCS04

The Wire diagram for the connecting is as follows

HC-sr04 wiring with Raspberry PI

HC-sr04 wiring with Raspberry PI

 

while making toggle switch was easy, its wiring was as follows

Raspberry Pi with toggle switch

Raspberry Pi with toggle switch

 

Code for both sensors to send data to Azure IOT hub is available at GitHub repository.

Once the data is sent to Azure IOT Hub, for both sensors the data is sent to Azure blobs, as well 2 separate stream analytics for both sensors process this data, with cool down periods in mind (sensor may send multiple reading very quickly when someone is near it, or the door toggle happens too quickly). The processed data is -

  • How many people used the disinfectant - as in how many people got near the bottle enough.
  • How many times the door was operated

Both processed outputs are connected to PowerBI and a dashboard is prepared to see a nice chart (will share the snapshot soon..) is shown.

DevOPS for IOT - A question that kept bugging me all the time was this - "How do you push code to thousands of IOT devices ?" for now I needed something which is simple, push the code to git and pull it automagically at the raspberry pi for which I wrote a simple shell script that can pull the code by checking for the update at the git repo; essentially there is hardly a way by the git commands to find the update at server, I did some research at SO and nothing substantially came out, I did a simple thing thus, Pull the latest from the git repo to a temp folder, check the git branch -v at the temp and at the deployment folder, if there is a mismatch, you move temp to deployment, and clear the temp folder. Keep checking for the same at periodic interval by scheduling your DevOPS script in the cron scheduler.

The code, diagrams and scripts will be available at GitHub.

Comments (0)

Skip to main content