Component guide · Beginner · 3 min read
AM312 Mini PIR Motion Sensor

Pinout, Wiring and Code
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The AM312 is a tiny passive infrared motion sensor with the lens and electronics in one small package. It runs from 2.7 to 12 V, draws only about 0.1 mA and gives a 3.3 V HIGH output for about 2 seconds when it sees movement, which makes it a good fit for ESP32 and battery projects. Range is about 3 to 5 m, with no adjustment pots.
Key specs at a glance
- Supply
- 2.7 to 12 V DC
- Idle current
- About 0.1 mA
- Output
- Digital, 3.3 V HIGH on motion
- Hold time
- About 2 s, fixed (retriggers while motion continues)
- Range
- About 3 to 5 m, about 100 degree cone
- Adjustment
- None: no sensitivity or time pots
A shorted, over-charged or damaged lithium cell can get very hot and catch fire. Use a protection board or BMS, never short the terminals, charge on a non-flammable surface and do not leave a charging pack alone. Throw away cells that are swollen or dented.
What the AM312 PIR sensor is
Like the larger HC-SR501, the AM312 watches for changes in infrared (body heat) across its lens. It has no trim pots and no jumper, so it is simpler to fit but less flexible: the hold time and sensitivity are fixed.
Its small size and very low current suit door sensors, battery night lights and ESP32 boards that sleep until something moves.
AM312 PIR sensor pinout
The pins on the AM312 PIR sensor and what each one does.
| Pin | Function |
|---|---|
| VCC | Supply, 2.7 to 12 V (marked + on the board) |
| OUT | Digital output, HIGH (3.3 V) while motion is seen |
| GND | Ground (marked -) |
- VCC
- Supply, 2.7 to 12 V (marked + on the board)
- OUT
- Digital output, HIGH (3.3 V) while motion is seen
- GND
- Ground (marked -)
Wiring the AM312 PIR sensor
The pin order is printed under the lens cap on most boards; check it before powering. The 3.3 V output is safe for both 5 V and 3.3 V boards.
| AM312 PIR sensor pin | Arduino Uno | ESP32 |
|---|---|---|
| VCC | 5V | 3V3 |
| GND | GND | GND |
| OUT | D2 | GPIO 33 (RTC pin for deep-sleep wake) |
- VCC
- Arduino Uno:
- 5V
- ESP32:
- 3V3
- GND
- Arduino Uno:
- GND
- ESP32:
- GND
- OUT
- Arduino Uno:
- D2
- ESP32:
- GPIO 33 (RTC pin for deep-sleep wake)
Example code
On an Uno, use digitalRead(2) in loop() and act when it reads HIGH, as in the PIR motion sensor guide.
#define PIR_PIN GPIO_NUM_33
void setup() {
Serial.begin(115200);
if (esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_EXT0) {
Serial.println("Motion detected!");
// send a message, turn on a light, take a photo...
delay(3000);
}
esp_sleep_enable_ext0_wakeup(PIR_PIN, 1); // wake when OUT goes HIGH
Serial.println("Sleeping until motion");
esp_deep_sleep_start();
}
void loop() {}Setup and tuning
give it about 30 to 60 seconds after power-on before trusting the output.
it sees movement across its view best; walking straight towards it is detected later.
heaters, sunlight and air-conditioner vents cause false triggers.
pair it with deep sleep so the controller only wakes on motion.
What you need
Shop this list4 of 5 found in our store · ₹568
Generic AM312 Mini IR Pyroelectric PIR Motion Sensor Module – 2.7-12V DC: the part this guide coversAM312 Mini IR Pyroelectric PIR Motion Sensor Module – 2.7-12V DC₹62- Uno R3 development board: the controller used in the wiring tableFind this part
ESP32-WROOM-32 38-pin development board: for Wi-Fi logging and dashboardsESP32-WROOM-32 38-Pin Development Board₹389
Solderless breadboard: to try it without solderingSolderless Breadboard₹68
Dupont jumper wires: for the connectionsDupont Jumper Wires (40 pcs)₹49Closest match, check the specs
Alternatives and when to choose them
- PIR motion sensor (HC-SR501): bigger, with adjustable range and hold time and a retrigger jumper.
- mmWave radar sensor: detects people who are sitting still, and works through thin plastic.
- Ultrasonic sensor: measures distance rather than motion.
Common mistakes to avoid
- Expecting to adjust range or hold time: the AM312 has no pots.
- Mounting it facing a window, heater or vent, which causes false triggers.
- Reading it before the warm-up time has passed.
- Wiring VCC and OUT the wrong way round because the pin labels are under the lens.
Frequently asked questions
What is the AM312 range?
About 3 to 5 m in a cone of roughly 100 degrees.
Can it run from 3.3 V?
Yes, it works from 2.7 V up, so it runs directly from an ESP32's 3.3 V pin.
Can I change the 2 second hold time?
Not on the sensor. Keep a timer in code that stays on for as long as you want after the last trigger.
Does it detect a person sitting still?
No, a PIR sensor needs movement. Use an mmWave radar sensor to detect presence.
Is it good for battery projects?
Yes, it draws about 0.1 mA, so it suits sleep-and-wake designs.
Parts for this guide
Projects that use it
Put this into practice: 57 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
- AM312 digital pyroelectric infrared sensor datasheet (Nanyang Senba Optical)
- ESP32 deep sleep (ext0 wake-up) in the ESP-IDF documentation
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

