Build a Motion‑Controlled AWS IoT Button with Raspberry Pi, PIR Sensor, and MQTT
Use this motion‑controlled IoT button as a remote switch, anti‑theft beacon, counter, or movement detector. It combines the simplicity of a Raspberry Pi, the sensitivity of a PIR sensor, and the scalability of AWS IoT.
After three weeks of experimentation, I successfully deployed a project that mimics Amazon’s IoT Button. The system detects motion with a PIR sensor, publishes the event to AWS IoT using MQTT, and triggers predefined actions on a subscriber Pi—such as turning on lights, activating a camera, or sending alerts via Amazon SNS.
Key Components
- Raspberry Pi (Gateway) – Publishes motion events to AWS IoT via MQTT.
- Second Raspberry Pi (Subscriber) – Listens for MQTT messages and executes actions.
- PIR Sensor – Detects infrared changes when a warm body enters the field of view.
- AWS IoT – Acts as the MQTT broker and device registry.
- Amazon SNS – Sends email or SMS notifications when motion is detected.
Why MQTT?
MQTT is a lightweight publish/subscribe protocol designed for M2M and IoT applications. Unlike HTTP’s request/response model, MQTT pushes messages to subscribers via a broker, enabling efficient, low‑bandwidth communication—ideal for remote sensors.
Learn more about MQTT at https://www.hivemq.com.
PIR Sensor Overview
A passive infrared (PIR) sensor measures IR light from objects in its view. When a warm body crosses one half of the sensor’s field, it generates a positive differential pulse; when it leaves, a negative pulse follows. These pulses are used to trigger motion detection.
PIR sensor pin‑out
PIR sensor details
Setting Up AWS IoT
While AWS offers extensive REST APIs and SDKs, the following steps use the AWS Management Console for clarity. All actions can be scripted if preferred.
- Sign up for an AWS account at https://aws.amazon.com/.
- Log in to the AWS Management Console and navigate to AWS IoT Core (see Fig‑1).
- Click Get started (Fig‑2).
- Choose Create a thing and name it (e.g., raspberry). Click Create (Fig‑5).
- The new thing is now registered in your AWS IoT registry.
Once the thing is registered, configure its certificates, policies, and MQTT topics to complete the setup.
Source: Motion Controlled AWS IoT Button
Manufacturing process
- The Button: From Ancient Fastener to Modern Innovation
- Upgrading and Configuring IoT Devices with AWS Jobs: A Practical Guide
- Privafy and Micron Introduce Embedded SECaaS for IoT Data in Motion
- Temperature‑Controlled Fan: DIY Relay System for Media Furniture Cooling
- Build a Speech‑Controlled Robot with Windows 10 IoT Core on Raspberry Pi 2
- AWS IoT Solutions Design Best Practices
- AWS Greengrass: Edge Computing & Data Caching for IoT Developers
- Azure vs AWS: Which Cloud Platform Wins for IoT?
- Smart Plant Monitoring System Powered by AWS IoT
- Motion‑Activated RGB LED Color Changer – Arduino Project