Embedded SystemsBeginnerPRJ-063

Digital Detox Box Using ESP8266

Lock your phone away for a set time to beat distractions.

Built and tested by Shahan Fathima K · Industrial Robotics Institute

Circuit diagram of the Digital Detox Box using ESP8266 NodeMCU
Circuit diagram · ESP8266 NodeMCU
LevelBeginner
Build time1–2 hours
BoardESP8266 NodeMCU
Parts9 components

What is the Digital Detox Box?

A phone-locking box that helps you focus. Put your phone inside and press the button: a servo locks the lid, the LED lights and the buzzer beeps. The box stays locked for the set time, then unlocks itself with another beep.

How it works

  1. You place your phone in the box and press the button.
  2. The servo turns to 90° to lock the lid; the LED turns on and the buzzer beeps.
  3. The ESP8266 starts a timer (10 s in the demo).
  4. When the time is up, the servo turns back to 0° to unlock, the LED goes off and the buzzer beeps again.

Parts list

ComponentQty
ESP8266 NodeMCU1
Servo Motor (SG90)1
Push Button1
Buzzer1
LED1
Resistor 220Ω (for LED)1
Box with lid1
Jumper WiresAs needed
Power Supply1

Software

  • Arduino IDE
  • Servo library

Wiring and connections

FromConnect to
Push buttonD1 and GND
Servo signalD2
Servo VCC5V (VIN)
Servo GNDGND
LED + (via resistor)D3
LED −GND
Buzzer +D4
Buzzer −GND

How to build the Digital Detox Box

  1. Fix the servo inside the box so its arm acts as a latch for the lid.
  2. Connect the button between D1 and GND (the code uses the internal pull-up).
  3. Connect the servo to D2, the LED to D3 and the buzzer to D4.
  4. Set lockDuration in the code (e.g. 1800000 for 30 minutes).
  5. Upload the code, put your phone in and press the button.

Digital Detox Box code

Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP8266 NodeMCU.

#include <Servo.h>

#define buttonPin D1
#define servoPin  D2
#define ledPin    D3
#define buzzer    D4

Servo lockServo;

bool locked = false;
unsigned long lockStartTime = 0;
unsigned long lockDuration = 10000;   // 10 s for demo

void beep()
{
  digitalWrite(buzzer, HIGH);
  delay(500);
  digitalWrite(buzzer, LOW);
}

void setup()
{
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
  pinMode(buzzer, OUTPUT);

  lockServo.attach(servoPin);
  lockServo.write(0);       // unlocked
}

void loop()
{
  if (digitalRead(buttonPin) == LOW && !locked)
  {
    locked = true;
    lockStartTime = millis();
    lockServo.write(90);    // lock
    digitalWrite(ledPin, HIGH);
    beep();
  }

  if (locked && millis() - lockStartTime > lockDuration)
  {
    locked = false;
    lockServo.write(0);     // unlock
    digitalWrite(ledPin, LOW);
    beep();
  }

  delay(200);
}

Real-world uses

  • Study time for students
  • Family dinner time
  • Focused work sessions
  • Screen-time habits

Frequently asked questions

What is a Digital Detox Box?

A phone-locking box that helps you focus. Put your phone inside and press the button: a servo locks the lid, the LED lights and the buzzer beeps.

What components are needed for the Digital Detox Box?

You need: ESP8266 NodeMCU (1), Servo Motor (SG90) (1), Push Button (1), Buzzer (1), LED (1), Resistor 220Ω (for LED) (1), Box with lid (1), Jumper Wires, Power Supply (1). Software: Arduino IDE, Servo library.

Is the Digital Detox Box project good for beginners?

Yes. It is rated beginner and takes about 1–2 hours to build, using the ESP8266 NodeMCU. The guide on this page explains every connection and step.

Where can I get the code for the Digital Detox Box?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.

Can I buy a kit for the Digital Detox Box?

Yes. IRI sells a kit with the parts for this project (PRJ-063). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.

Industrial Robotics Institute
Logo