Head office, Rana Pratap Bagh, Delhi011 2721 1512+91 97116 99511

Science project idea

PIR intruder alarm that sends a phone message through an ESP8266

A PIR sensor watches a room; when it triggers while the system is armed, a NodeMCU sends a message to the owner through a free bot on a messaging app and sounds a local buzzer. The system is armed and disarmed by a message from the phone.

What it shows

A PIR sensor watches a room; when it triggers while the system is armed, a NodeMCU sends a message to the owner through a free bot on a messaging app and sounds a local buzzer. The system is armed and disarmed by a message from the phone.

The science

The PIR output is 3.3 V, so it connects straight to a NodeMCU pin. The ESP8266 connects to Wi-Fi and uses an HTTPS client library to call the bot API, which delivers text to the phone. The same sketch polls the bot every two seconds for incoming commands such as arm and disarm, giving two-way control. A cool-down timer prevents a stream of messages from one person walking across the room.

Materials

Cost: under Rs 500. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.

  • A NodeMCU ESP8266 and USB cable
  • An HC-SR501 PIR sensor
  • A 3.3 V or 5 V buzzer
  • An LED and a 220 Ω resistor
  • A 5 V power bank
  • A phone with a free messaging app that supports bots

Safety

For this project: USB power only. Tell people in the house that the sensor is running during the test.

Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.

All the safety rules

Step by step

9 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.

  1. Create a bot in the messaging app as the ebook shows and note the token and your chat ID.

  2. Wire the PIR: VCC to Vin, GND to GND, OUT to D2. Wire the buzzer to D5 and the LED through its resistor to D6.

  3. Install the ESP8266 bot library from the library manager and open its echo example; add your Wi-Fi details and token.

  4. Upload and send hello to the bot from the phone; the board should reply.

  5. Add a boolean armed flag that the commands /arm and /disarm change, replying with the new state.

  6. In the loop, if armed and the PIR goes high, send Movement detected with the time since boot, beep the buzzer and light the LED.

  7. Add a 30 second cool-down after each alert before another can be sent.

  8. Add a /status command that replies with armed or disarmed and the last alert time.

  9. Mount the sensor in a corner facing the door and test by arming from another room.

What you should see

With the system armed, walking into the room produces a phone message within a few seconds and a local beep; disarming by message stops further alerts.

Viva questions

A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.

1How does the board receive commands without a server?

It polls the bot API every few seconds, asking for any new messages addressed to the bot.

2Why is HTTPS used?

The messaging service only accepts encrypted connections so the token and messages cannot be read on the way.

3What limits how fast alerts can be sent?

The cool-down in code and the rate limits of the messaging service.

4Can the PIR see through glass?

No. Glass blocks most of the far infrared it detects, so it must face the room directly.

Free ebook: Viva Questions for Science Projects

Take it further

Add a magnetic reed switch on the door and report which sensor triggered.

Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.

Free ebooks for this project

WhatsApp us