Madison Metro Sewerage District made a big investment in the Public Market. I even had a part in that with the refurbished sign work I did. But they wanted to know how impactful this investment was. Were people engaging with it? Was it interesting? Were they learning anything? This is the kind of thing project managers and grant funding organizations want to know. Because of my work on the sign, I was top of the list to implement something to capture some metrics.
The problem is that this is a public bathroom, and cameras are a big no-no, and anything that required touch is gross. So I opted for something simple; a PIR sensor on the ceiling at the entrance/exit to the area containing the bathrooms. It’s not perfect. It can’t tell the difference between two people walking quickly and one person walking slowly. If you dwell motionless for too long it stops counting you. And because there are two entrances to each area, you sort of have to add both sensors together and divide by two to get an accurate count of how many people used the space. But it’s better than nothing, and gives some interesting results. Because we can measure the dwell time (mostly), we can see if the areas under the sensors are getting more engagement, as measured by how long people stand under it.
The solution I developed was an ESP32 DevKit V1 attached to a simple PIR sensor module. This was embedded inside a custom enclosure that was 3D printed with a captive 1/4″ 20 nut so that mounting it was simple. A USB cable was also captured inside the enclosure, and went out to a USB charging brick. Fortunately there were outlets everywhere I needed them, and plenty of surfaces to mount the sensor. I didn’t want anything permanent or destructive, so I opted for adhesive tape and zip ties.


I installed four sensors. On the first floor there are two ways to get into the bathrooms, and each has some signage in it, so I put one above the signage. On the second floor there is a hallway that contains the bathrooms, flanked on either side by some offices. I put a sensor at each end of the hallway, but just outside of the reach of the offices, so that going into an office shouldn’t trigger the sensor, though it might.


The operation of the sensor is simple. At regular intervals (daily) it connects to the WiFi and uploads a heartbeat event to a server to say “hey, I’m still alive” and give some status information. It also uploads its data and updates its timestamp and checks for any firmware updates. When someone walks by the PIR sensor triggers a GPIO pin and the sensor counts how long the PIR sensor detects something. Then it creates an event that is stored internally and contains the sensor ID, timestamp, and duration of the event. This gets uploaded with any other events.
On the server each event is stored to a log file and also to a MySQL database, where it can be queried for some simple reports.

The market is closed on Mondays and Tuesdays, and this is readily apparent. It was also closed on Thanksgiving. On the other days it looks like most people are visiting the first floor bathrooms.

Digging in to a specific day, we can see the distribution across each hour to see the open hours. This also includes a filter of dwells longer than 5 seconds.
We’ve only got a few weeks of data so far, but it’s interesting. It’s not perfect, but it’s more than we would have otherwise, and it’s certainly enough to gain some actionable intelligence. Plus, the sensors are cheap and easy to make. All that’s needed is WiFi and a power supply.
