Embedded SystemsBeginnerPRJ-049

Focus Monitoring Desk System for Study Using ESP8266

Notices when you leave your desk or stop moving, and nudges you back to study.

Built and tested by Shahan Fathima K · Industrial Robotics Institute

Circuit diagram of the Focus Monitoring Desk System for Study using ESP8266 NodeMCU
Circuit diagram · ESP8266 NodeMCU
LevelBeginner
Build time1–2 hours
BoardESP8266 NodeMCU
Parts8 components

What is the Focus Monitoring Desk System for Study?

A study helper that tracks whether a student is at the desk and active. An ultrasonic sensor measures how far the student is from the desk and a PIR sensor watches for movement. When the student is close and active, the green focus LED stays on; if they move away or go still, the buzzer sounds to bring their attention back.

How it works

  1. The ultrasonic sensor measures the distance between the student and the desk.
  2. The PIR sensor detects movement or activity.
  3. If the student is closer than 100 cm and moving, the system treats them as focused: LED on, buzzer off.
  4. If they move away or no motion is detected, it treats them as distracted: LED off, buzzer on.
  5. The check repeats every half second.

Parts list

ComponentQty
ESP8266 NodeMCU1
Ultrasonic Sensor (HC-SR04)1
PIR Motion Sensor1
LED1
Resistor 220Ω (for LED)1
Buzzer1
Jumper WiresAs needed
Power Supply1

Software

  • Arduino IDE

Wiring and connections

FromConnect to
Ultrasonic VCC / GND5V (VIN) / GND
Ultrasonic TRIGD1
Ultrasonic ECHOD2
PIR VCC / GND5V (VIN) / GND
PIR OUTD3
LED + (via resistor)D4
Buzzer +D5
LED − / Buzzer −GND

How to build the Focus Monitoring Desk System for Study

  1. Mount the ultrasonic sensor at the front of the desk, facing the chair.
  2. Place the PIR sensor where it can see the student’s upper body.
  3. Connect the ultrasonic sensor to D1 (TRIG) and D2 (ECHO), and the PIR output to D3.
  4. Connect the LED through a resistor to D4 and the buzzer to D5.
  5. Upload the code from the Arduino IDE.
  6. Sit at the desk and check that the LED stays on; step away and the buzzer should sound.
  7. Change the 100 cm limit in the code to suit your desk.

Focus Monitoring Desk System for Study code

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

#define trigPin D1
#define echoPin D2
#define pirPin  D3
#define ledPin  D4
#define buzzer  D5

long duration;
int distance;

void setup()
{
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(buzzer, OUTPUT);
}

void loop()
{
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.034 / 2;

  int motion = digitalRead(pirPin);

  if (distance < 100 && motion == HIGH)
  {
    digitalWrite(ledPin, HIGH);   // Focused
    digitalWrite(buzzer, LOW);
  }
  else
  {
    digitalWrite(ledPin, LOW);    // Distracted
    digitalWrite(buzzer, HIGH);
  }

  delay(500);
}

Real-world uses

  • Home study desks
  • Libraries and reading rooms
  • Hostels
  • Online-class setups

Frequently asked questions

What is a Focus Monitoring Desk System for Study?

A study helper that tracks whether a student is at the desk and active. An ultrasonic sensor measures how far the student is from the desk and a PIR sensor watches for movement.

What components are needed for the Focus Monitoring Desk System for Study?

You need: ESP8266 NodeMCU (1), Ultrasonic Sensor (HC-SR04) (1), PIR Motion Sensor (1), LED (1), Resistor 220Ω (for LED) (1), Buzzer (1), Jumper Wires, Power Supply (1). Software: Arduino IDE.

Is the Focus Monitoring Desk System for Study 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 Focus Monitoring Desk System for Study?

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 Focus Monitoring Desk System for Study?

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

Industrial Robotics Institute
Logo