Blog

Using the power of the cloud for restroom occupancy awareness

1 lddklx1rukpfh8rsrkrqgg

DoiT International has experienced a significant growth during the past year and effectively doubled its team size. However, as we are now occupying two floors with only one restroom to share (located on the 2nd floor), we needed a solution that will enable each and every member of the team to know if he can get out of his chair and make the trip to the bathroom. And that’s how Ma-Stool came to life.

We opted to create our own Arduino based solution. We started by getting an Arduino board and a Wifi Module. Then I started to search for a good library to use in order to utilize the Wifi module, I settled down on using WifiESP, but it was missing a few featured that I needed. We have a few Wifi access points in our office and I wanted to connect to the one with the strongest signal

// Sort scan results by RSSI

sendCmd(F(“AT+CWLAPOPT=0,31”));

(which means that I have to pass the MAC address as well to the connect function), so I forked the library and add the code that I needed (the fork is here).

Once I was able to connect to the network the next step was to actual detection of the bathroom occupancy state. I opted for using a simple solution of Reed Switch. I installed a small magnet on the door lock and inserted the reed switch into the door latch. I made sure that we will get a reading only if there is a real lock and not when just closing the door without locking.

1 cune2qah3f7d7fewowwcma

I wanted to decouple the detection of the state from the Indicator to the users. I decided to send all the events from the reed switch to a cloud-based MQTT server. Before sending the status I had to make sure that I have a stable reading

1 foqtxrars3r3 qdg8ntnfw

Once we were done with the event generation the next step was the events consumption. We choose to write a small Slack bot that will run as a Google App Engine application. I created two services, the first one is always listening for incoming events from the MQTT server.

1 btj znpcliajw1sytmzlpg

When events arrive it updates the state of the bathroom in a DataStore record.

The second service is Slack slash command handler. When a user asks for the bathroom Status it will retrieve the status form Google DataStore record and will display it to the user.

1 uupugmkrtbqa51fxng7ceq
1 uxyeg6x15wjq4au3i joq

Want more stories? Check our blog, or follow Aviv on Twitter.

Subscribe to updates, news and more.

Related blogs

Connect With Us