Motion sensor notifier
人感センサー通知 ・ 人体感应通知
Detect motion with a PIR sensor on a tiny AtomS3 controller.
人や動物の動きを検知。小型のAtomS3で省スペース。畑の獣害チェックにも。
用 PIR 传感器检测人或动物的移动,小巧的 AtomS3 省空间,也可用于田间防兽害。
Parts (BOM)
| Part | Role | Ports | Links |
| AtomS3 |
Controller (compact) |
grove_i2c, i2c, spi, gpio, usb_c |
official page |
| M5Stack Unit PIR |
Motion sensor |
grove_i2c |
official page |
Wiring
- AtomS3 → M5Stack Unit PIR (grove)
How to build
Build a tiny motion alarm for your garden or doorway. An M5Stack AtomS3 watches the PIR (motion) sensor and, whenever something moves nearby, lights up its screen red and prints an alert. Great for spotting animals visiting your plants or knowing when someone walks past. No soldering and no engineering knowledge needed - just two parts and one Grove cable.
- Unbox and check parts — Lay out the two parts: the AtomS3 controller (the small cube with a screen) and the Unit PIR motion sensor. You also need the white 4-pin Grove cable that came with the PIR, and a USB-C cable to connect the AtomS3 to your computer.
- Connect the PIR with the Grove cable — Plug one end of the Grove cable into the PIR sensor and the other end into the Grove port on the bottom of the AtomS3. The connector only fits one way, so push gently until it clicks. The AtomS3's Grove port is its I2C/digital port - the right home for this sensor.
- Plug AtomS3 into your computer — Connect the AtomS3 to your computer with the USB-C cable. The screen should light up, showing it has power. If nothing happens, try a different USB cable - some cables only carry power and not data.
- Install MicroPython firmware — The easiest path: open the M5Burner app (free from m5stack.com), find the UIFlow2 / MicroPython firmware for AtomS3, and click Burn to flash it. Pick the COM port that appears when the AtomS3 is plugged in. This only needs to be done once.
- Load the alert program — Open Thonny (a free, beginner-friendly editor), select the AtomS3 as the connected device, paste the code below, and save it onto the board as main.py. Saving as main.py makes it run automatically every time the AtomS3 powers on.
- Test it — Wave your hand in front of the PIR sensor. Within a second the screen should turn red and show 'MOTION'. When you stay still, it returns to a calm green 'Watching' screen. Note: PIR sensors need about 30-60 seconds to settle after power-on, so give it a moment before trusting the first readings.
Sample code (micropython)
# Motion alert for M5Stack AtomS3 + Unit PIR
# PIR signal arrives on the Grove port. On AtomS3 that pin is GPIO 8.
from machine import Pin
import time
try:
import M5
from M5 import Lcd
M5.begin()
HAS_SCREEN = True
except Exception:
HAS_SCREEN = False # still works without the screen lib
# PIR output: HIGH (1) when motion is detected, LOW (0) when quiet
pir = Pin(8, Pin.IN)
def show(text, color):
if HAS_SCREEN:
Lcd.clear(color)
Lcd.setCursor(10, 50)
Lcd.setTextColor(0xFFFFFF, color)
Lcd.print(text)
print(text)
show("Watching", 0x00AA00) # calm green = no motion
last = 0
while True:
moved = pir.value()
if moved != last: # only redraw when state changes
if moved:
show("MOTION", 0xFF0000) # red = motion!
else:
show("Watching", 0x00AA00)
last = moved
time.sleep(0.1)
Tips & safety
- Let the PIR warm up: for the first 30-60 seconds after power-on the sensor stabilizes and may give false triggers. Wait before relying on it.
- Avoid heat and sunlight: PIR sensors react to moving heat, so direct sun, heaters, or a breeze of warm air can cause false alarms. Point it away from windows and vents.
- If 'MOTION' never appears, check the Grove cable is fully clicked in at both ends, and confirm the firmware flashed correctly. If it triggers constantly, move the sensor away from heat sources.
- Powered by USB only: this build uses safe 5V USB power - there is no pump, relay, or mains voltage involved. Still, keep the electronics dry if you place it outdoors.
Open the interactive diagram →
UnitKit — describe what you want to build, get a parts list and wiring diagram.