Introduction: Toilet Occupancy Notifier Built Based on ESP32 and Home Assistant

The toilet - it may seem a bit inconspicuous, but in fact it is one of the key points supporting comfort, especially in a dynamic office environment. At the company, our daily challenge became the perpetual queue for the bathroom. As the number of employees increased, the number of available toilets remained constant, resulting in increasing levels of frustration and wasted time trying to get to the restroom.

We realized that we couldn't change the number of available toilets, but we could optimize the way people were informed of their availability.

Our solution is based on an intelligent system consisting of two types of devices. First, we have a main module located above the toilet door that informs people about the status of the toilet. Second, we have wireless beacons placed in various locations around the office. The entire system is based on a Raspberry Pi, with Home Assistant as the main management system. As a result, all devices are connected via WiFi. The ESP32-based modules connect to the network and are integrated into the system via an add-on to Home Assistant, known as ESPHome.


With this innovative approach, employees can now easily check if a toilet is available before they go there. It's a simple but effective solution that has greatly improved the workplace experience and reduced the frustration of waiting in line for the restroom.

Supplies

Step 1: Home Assistant With ESPHome

In our project, we used a Raspberry Pi 4B 4GB with Home Assistant installed. To make the whole thing work properly and without problems we used the HA add-on ESPHome, details about the add-on can be found on their website.

There is very extensive documentation on the site, which makes installing, configuring and using the add-on much easier.

Step 2: Main Module

Previously prepared ESP32 module in a case is mounted above the door frame, but how does it know that the door is closed? To do this, I used a piece of Plexiglas and springs from a battery basket and placed it in the doorframe. One spring is connected to ground and the other to the signal pin on the ESP. The door lock closes the circuit and the ESP receives information about this fact. The relay then switches the LEDs from green to red and the module sends the information to the Home Assistant.

  • Green - vacant
  • Red - occupied

Step 3: Indicator

After the main modules mounted above the toilet doors send a signal to the Home Assistant, the corresponding automation is triggered to control the ESP32s tucked inside the indicators. It outputs 2 signal pins that trigger the corresponding relays. Unlike the main modules, when the toilet is unoccupied no light is illuminated, only when the door in one of the two toilets is locked, the LEDs located in the corresponding segment of the indicator are lit, indicating that the toilet is occupied.


- red - men's restroom

- blue - women's toilet


Currently, the system has been in operation at our facility since November 2021 and has significantly improved work comfort.