Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

Raspberry Pi–Based Bathroom Occupancy Sensor with Voice & SMS Alerts via Twilio

Overview

During our time at the Hacker School, we observed that the facility’s two restrooms—one adjacent to the main workspace and another on the lower level—could benefit from a real‑time occupancy status indicator. By knowing whether a bathroom is occupied before heading downstairs, we could reduce unnecessary wait times and improve convenience.

Our solution enables users to check bathroom status via phone call or SMS. A simple light sensor, mounted on a Raspberry Pi, monitors the bathroom’s illumination; if the lights are on, the system assumes the bathroom is in use.

The Raspberry Pi sends periodic updates to a Heroku‑hosted Flask application, which also receives incoming Twilio requests. When a user calls or texts the dedicated Twilio number, the application replies with the current occupancy status—either spoken through text‑to‑speech or sent as an SMS message.

In addition to the voice/SMS interface, @gelstudios developed an intuitive web dashboard that displays the real‑time sensor state.

Server

Twilio

Twilio is a cloud communications platform that simplifies sending and receiving phone calls and SMS via a RESTful API. We leveraged Twilio’s Python helper library and Quickstart tutorials to wire our phone number to the Flask endpoints.

Heroku

Heroku offers a managed platform for deploying full‑stack applications. Using the Heroku Dev Center guide, we set up a Python/Flask app and exposed it over HTTPS for secure communication with Twilio.

Server Code

The complete source code for the web application is available on GitHub: twilio-light-sensor-server/run.py.

The /twilio/voice and /twilio/text routes accept incoming requests from Twilio. Depending on whether the user called or sent an SMS, the server crafts a response that reflects the current bathroom occupancy and returns it to Twilio for delivery as voice or text.

The /update route receives HTTP POST payloads from the Raspberry Pi sensor. Each payload must include sensor_id and sensor_val parameters so the server can identify the source and update the internal state accordingly.

For further details, see the original project write‑up: Voice– and SMS–Enabled Light Sensor Using Raspberry Pi and Twilio.

Manufacturing process

  1. TMP006 Infrared Temperature Sensor with Raspberry Pi: Python Library & Setup Guide
  2. Build a Remote Temperature Sensor with Raspberry Pi and Python – Step‑by‑Step Guide
  3. Control an LED with a PIR Motion Sensor on Raspberry Pi
  4. Build a Multi‑Sensor Temperature & Light Monitoring System with Raspberry Pi & DS18B20
  5. Mastering Raspberry Pi Sensor & Actuator Control: Accelerometer, Servo, and Data Streaming
  6. Build an Automated Aeroponics System with Raspberry Pi and Humidity Sensor
  7. Raspberry Pi Light Sensor Tutorial – Wire an LDR and Read Light Levels with Python
  8. Integrating the Acconeer A111 Pulsed Radar with a Raspberry Pi: A Practical Guide
  9. Capacitive Touch LED Switch with Arduino UNO – Easy DIY Project
  10. Build an Ambient Light Sensor with Photoresistor and LED: Step‑by‑Step Guide