Stufin
Home Quick Cart Profile

M5 Stack PIR Motion Unit (AS312)

Buy Now on Stufin

Power Supply

3.3V to 5V

Power Consumption

1mA (typical)

Detection Range

Up to 3 meters

Detection Angle

120

Sensitivity

Adjustable via potentiometer

Output Signal

Digital (HIGH/LOW)

Operating Temperature

-20C to 80C

Dimension

25mm x 25mm

Applications

The M5 Stack PIR Motion Unit (AS312) is suitable for a wide range of IoT applications, including

Home automation systems

Security systems

Smart lighting control

Occupancy detection

Smart sensing devices

Resources

For more information and resources related to the M5 Stack PIR Motion Unit (AS312), including datasheets, user manuals, and sample codes, please refer to the M5Stack official documentation and community resources.

Pin Configuration

  • M5 Stack PIR Motion Unit (AS312) Pinout Guide
  • The M5 Stack PIR Motion Unit (AS312) is a compact, low-power PIR (Passive Infrared) motion detection module designed for IoT applications. It features a high-accuracy AS312 PIR sensor and is compatible with the M5 Stack ecosystem. This guide explains the pinout of the M5 Stack PIR Motion Unit, detailing each pin's function and how to connect them.
  • Pinout Structure:
  • The M5 Stack PIR Motion Unit has a total of 6 pins, arranged in two rows of 3 pins each. The pinout structure is as follows:
  • Row 1:
  • 1. GND (Ground)
  • Function: Provides a ground connection for the module.
  • Connection: Connect to the ground pin of your microcontroller or power supply.
  • 2. VCC (Power Supply)
  • Function: Supplies power to the module.
  • Connection: Connect to a 3.3V or 5V power supply, depending on your system's requirements.
  • 3. OUT (Output)
  • Function: Outputs a digital signal indicating motion detection.
  • Connection: Connect to a digital input pin on your microcontroller or a logic-level converter if necessary.
  • Row 2:
  • 1. NC (Not Connected)
  • Function: No internal connection.
  • Connection: Leave unconnected.
  • 2. NC (Not Connected)
  • Function: No internal connection.
  • Connection: Leave unconnected.
  • 3. SCL (Clock)
  • Function: Not used in this module.
  • Connection: Leave unconnected.
  • Important Notes:
  • The module operates on a 3.3V or 5V power supply, depending on your system's requirements.
  • The OUT pin outputs a digital signal, which can be connected directly to a microcontroller's digital input pin.
  • The SCL pin is not used in this module and should be left unconnected.
  • The NC pins have no internal connection and should be left unconnected.
  • Connection Diagram:
  • Here's a sample connection diagram to help you understand how to connect the M5 Stack PIR Motion Unit:
  • ```
  • +---------------+
  • | M5 Stack |
  • | PIR Motion |
  • | Unit (AS312) |
  • +---------------+
  • |
  • |
  • v
  • +---------------+ +---------------+
  • | Microcontroller | | Power Supply |
  • | (e.g., ESP32) | | (3.3V or 5V) |
  • +---------------+ +---------------+
  • | GND | | GND |
  • | 3.3V/5V |-------| 3.3V/5V |
  • | Digital Input |-------| OUT (Motion) |
  • +---------------+ +---------------+
  • ```
  • By following this pinout guide, you can successfully connect and integrate the M5 Stack PIR Motion Unit (AS312) into your IoT project.

Code Examples

M5 Stack PIR Motion Unit (AS312) Documentation
Overview
The M5 Stack PIR Motion Unit (AS312) is a Passive Infrared (PIR) motion sensor module designed for use with the M5 Stack ecosystem. This module is based on the AS312 PIR sensor, which detects changes in infrared radiation levels caused by movement within its detection range. The module is compact, low-power, and easy to use, making it suitable for various IoT and automation applications.
Hardware Specifications
PIR Sensor: AS312
 Detection Range: Up to 3 meters
 Sensitivity: Adjustable
 Power Supply: 3.3V to 5V
 Communication Interface: I2C
 Dimensions: 24 x 24 x 10 mm
Pinouts
GND: Ground
 VCC: Power Supply (3.3V to 5V)
 SCL: I2C Clock
 SDA: I2C Data
 OUT: Motion Detection Output
Software Requirements
M5 Stack Core/ATOM/CORE2 boards
 UIFlow or MicroPython firmware
Example Code 1: Basic Motion Detection using UIFlow
This example demonstrates how to use the M5 Stack PIR Motion Unit (AS312) with the UIFlow firmware to detect motion and trigger an event.
```blocks
from m5stack import 
from m5stack_ui import
powerOn()
# Initialize PIR Motion Unit
pir = unit.get(unit.AS312, unit.PORTA)
# Create a label for the motion detection status
label0 = M5TextBox(0, 10, "Motion:", lcd.FONT_Default, 0x000000)
while True:
    # Read motion detection output
    motion_detected = pir.get()
if motion_detected:
        label0.setText("Motion: DETECTED!")
    else:
        label0.setText("Motion: NOT DETECTED")
wait(0.1)
```
Example Code 2: Motion-Controlled LED using MicroPython
This example shows how to use the M5 Stack PIR Motion Unit (AS312) with MicroPython to control an LED based on motion detection.
```python
import machine
import time
# Initialize PIR Motion Unit
pir = machine.I2C(0, freq=400000)
pir.init(machine.Pin(26), machine.Pin(25))
# Initialize LED
led = machine.Pin(2, machine.Pin.OUT)
while True:
    # Read motion detection output
    motion_detected = pir.read_u8(0x00)
if motion_detected:
        led.value(1)  # Turn on LED when motion is detected
    else:
        led.value(0)  # Turn off LED when no motion is detected
time.sleep(0.1)
```
Additional resources
UIFlow documentation: <https://docs.m5stack.com/en/uiflow/>
 MicroPython documentation: <https://docs.micropython.org/en/latest/>
 M5 Stack API documentation: <https://docs.m5stack.com/en/api/>