Warning
The Android app aspect of the project is vibecoded. Apart from that, everything else is developed by me.
A phone lockbox system designed to encourage quality sleep and better bedtime habits.
- Arduino Nano 33 IoT
- Elechouse PN532 Module V3
- IR Obstacle Sensor
- FS90MG Micro-servo motor $\times$2
- Piezo buzzer
- Generic 0.96-inch I$^2$C OLED Display
- Push button (12mm x 12mm)
- Electrolytic Capacitor (47 $\mu$F $\times$1, 100 $\mu$F $\times$1, 1000 $\mu$F $\times$1)
- 400 tie point breadboard $\times$2
- 3M 16mm nuts and screws $\times$8
- Raspberry Pi (or any general-purpose computer with Wi-Fi and Bluetooth capability)
Smartphones have become an increasingly significant source of distraction, most prevalent during night hours, providing an addictive source of time killer when quality sleep and downtime are most needed. This can cause later rising times, longer sleep latency, worse sleep efficiency, daytime sleepiness, and mental consequences such as anxiety, stress, and mental disorders. Existing solutions either take a software approach that can easily be bypassed, or a physical lockbox approach that may not be suitable for individuals who need emergency accessibility. This project aims to contribute a new and unique implementation that limits physical access during bedtime, while accommodating emergency accessibility.
The lockbox system is built with 3D printed parts with the provided CAD models in cad/. These should be printed as a casing and base for the circuits to be placed into. Note that the provided CAD models were designed specifically for a Google Pixel 9 device, and the components attached in the beginning. Other devices and components may risk functionality or fitting issues.
The public repository attached below contains all the source code, including the Arduino sketch inside the arduino/ directory. This can be uploaded to the Arduino Nano 33 IoT using Arduino IDE. Most of the required libraries are available from the Arduino IDE library manager, which include:
- ArduinoBLE (by Arduino)
- Servo (by Michael Margolis, Arduino)
- Adafruit GFX Library (by Adafruit)
- Adafruit SSD1306 (by Adafruit)
- PN532 Arduino (by Seeed Studio, available here)
The wiring of each component to the Arduino, as assigned by the provided source code, is as below:
- PN532 module: 3.3V, HSU mode connected to TX and RX
- IR obstacle sensor module: 3.3V, digital output connected to digital pin 2
- Generic OLED display: 3.3V, connected to SDA and SCL
- Micro-servo motors: 5V, PWM connected to digital pin 10 (left), and digital pin 12 (right)
- Piezo buzzer: connected to digital pin 5
- Push button: connected to digital pin 3
Each component can be fitted into different parts of the printed models, and is built together to form the completed lockbox.
- The base box part is fitted with two of the breadboards, along with the Arduino Nano 33 IoT, PN532 module, piezo buzzer, and push button.
- The top slant - back part is fitted the OLED display and the IR sensor in its designated places, and can be fitted with the top slant (front) part as a front cover.
- The phone base part is fitted with the two servo motors, along with its wall part.
- All built parts can be joint together as shown, and secured with the screws and nuts in the screw holes.
The source code in the public repository provides a Python server in the server/ directory to be ran on a general-purpose computer such as a Raspberry Pi 3B, or any computer with WiFi and Bluetooth. The following procedures have been tested on a Raspberry Pi 3B with Python 3.13 or higher:
- Clone the repository.
git clone https://github.com/ponleou/sleeper-agent.git
cd sleeper-agent/server- Create a Python virtual environment and download the required packages.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt- Start the server by running
server.py.
python server.py- Ensure the server is connected to a local Wi-Fi for the initial register with the Android phone.
The following setup instructions have been tested on a Google Pixel 9:
-
Download and install the provided APK.
-
Open the installed application, named Sleeper Agent, and enable notifications, notification access, and location permissions with the buttons inside the application.
- Ensure mobile device is connected to the same local Wi-Fi as the server for the initial registration.








