Skip to content
Tutorial
13 min read
October 17, 2026

PIR Motion Notifications with Blynk Events on ESP32

Use an ESP32 PIR input to send Blynk event notifications on a new motion transition. Configure the event, add a cooldown to reduce repeated alerts, and handle sensor warm-up and cloud disconnection.

PIR Motion Notifications with Blynk Events on ESP32

A PIR sensor output may remain HIGH for a period after movement, and retriggers can occur while someone moves around a room. If the firmware sends a notification on every loop pass, one motion event can create a flood of alerts.

This tutorial uses a state transition and a cooldown so the ESP32 sends a Blynk event only when it detects a new inactive-to-active transition and the cooldown has expired. Configure the event in Blynk before testing. This is a convenience notification path, not a certified alarm system or a replacement for local safety equipment.

Image pending: Image placeholder: PIR module → ESP32 transition detector → cooldown gate → Blynk event/notification, with a separate local status path.

Hardware and event configuration

Use an ESP32, a PIR module compatible with the board's input voltage and jumper wires. Example input GPIO is 27, but verify availability for your board. PIR modules often require a warm-up period after power-up and may keep the output HIGH for a configurable hold time.

In Blynk.Console, create an event code such as motion_detected and configure notifications for it using the current event settings available to your account. The event code in firmware must match exactly. Verify current platform feature and notification limits before describing a plan-specific entitlement.

Image pending: Image placeholder: PIR module OUT connected to ESP32 GPIO27, plus supply and GND. Include module-specific voltage and warm-up note.

1. Detect a new motion event

The sketch below samples the digital input using BlynkTimer. It reports only a LOW-to-HIGH transition and enforces a 60-second cooldown. Change the pin and cooldown to match your sensor placement and use case; after boot, allow the module to settle before treating its output as a valid motion event.

C++
Image pending: Image placeholder: Arduino IDE event callback showing rising-edge detection, warm-up interval and cooldown logic; credentials replaced.

The sample does not queue alerts generated while Blynk is disconnected. It logs the condition locally instead. If you need event buffering, design a bounded queue and a retry/deduplication policy. Do not simply retry a notification forever: reconnect bursts can cause duplicate or delayed alerts.

Image pending: Image placeholder: Blynk dashboard showing device online status and a recent motion event indicator; no personal location details.

2. Tune the sensor and alert policy

Mount the PIR according to its datasheet and test across the actual field of view. Pet movement, sunlight, heating, reflections and sensor placement can affect false triggers. Adjust module sensitivity/hold-time controls where available and validate the software cooldown separately.

The cooldown limits duplicate notifications, but it can also suppress a second genuine event. Choose the interval based on the room and whether the requirement is convenience notification, occupancy awareness or a monitored alarm. Display sensor availability and recent event time rather than inferring “room empty” just because no message has arrived.

3. Test failure cases

  1. Wait through the PIR warm-up.
  2. Trigger motion once and confirm one event.
  3. Keep the sensor output HIGH and verify no repeated message is sent.
  4. Trigger again inside the cooldown and confirm suppression.
  5. Trigger after the cooldown expires and verify a new event.
  6. Disable network connectivity and confirm the local sensor still operates and the firmware records the missed notification condition.

Record actual behavior on the installed sensor module; the code's 30-second warm-up and 60-second cooldown are starting values, not universal specifications.

Image pending: Image placeholder: test matrix for PIR warm-up, one motion event, sustained HIGH state, cooldown suppression, cooldown expiry and Wi-Fi disconnection.

Next steps

Official references: Blynk documentation and the documentation for your exact PIR module. For a security-critical application, use a suitable dedicated alarm architecture rather than relying on a cloud notification as the sole alert path.

Signal In

Built from what makers search for

The lookups piling up in SolderHub's search bar every day shape what we publish next — new component pages, board guides, and firmware notes, sent out as they go live.

By subscribing you agree to our Privacy Policy. Unsubscribe anytime.