IoT Bathroom occupancy indicator

SONOFF B1 as occupancy indicator

I used to work in an office where about 200 people would share 3 toilet stalls. Because of this sub-optimal ratio, one would rarely find a vacant stall on the first try. Here, people would either wait around the bathroom until they can use it or walk back to their office space to try again later. In both case, a massive of time was wasted. Ideally, one should be able to check the occupancy of the bathroom without having to walk all the way there. Thus, I set up an IoT system to do exactly that.

I installed read switches on the each toilet stall door in order to detect if the latter is open or closed. The doors were installed in a way that they could not remained closed unless locked. As such, the reed switches would effectively detect if the stall is in use or not.

At this point, all that remained was to connect the reed switch to an ESP8266 in order to broadcast the stall occupancy over WiFi.

As an occupancy indicator, I installed SONOFF B1 lightbulbs around the office. These ran a custom firmware so as to turn red if the stalls were all occupied and green otherwise. This state is communiated by the sensing modules using REST API calls.

However, I was not allowed to use the office wifi for this purpose so I had to come up with my own networking method. Consequently, I made is so that the lighbulbs generate access points to which the stall sensors connect directly.

A web interface is also available, which allows to check the bathroom occupancy from one's computer. However, since the system runs on a separate network, nobody actually accesses it.

The source code for this project is available on GitHub: