All wiring guides

Free wiring guides

Wire the AM312 PIR motion sensor to the ESP32-C3

Motion sensor, PIR mini AM312. Notices a warm body moving in front of it.

When buying: The AM312 runs on 3.3 V. The larger HC-SR501 needs 5 V.

Which pin goes where

On the partOn the ESP32-C3
VCC3V3
OUTGPIO 3
GNDGND

Wire it with the USB cable unplugged. Follow the names printed on your own part: makers sometimes reorder the pins.

In 3D

Example sketch

// Motion sensor, PIR mini AM312
// on the ESP32-C3 Super Mini
// https://stem.manusignal.com/en/parts/am312-pir-motion-sensor-esp32-c3

const int PIN_OUT = 3;

int last = -1;

void setup() {
  Serial.begin(115200);
  pinMode(PIN_OUT, INPUT);
}

void loop() {
  int now = digitalRead(PIN_OUT);
  if (now != last) {
    last = now;
    Serial.println(now == HIGH ? "ON" : "off");
  }
  delay(20);
}
  • Tools > Board > ESP32C3 Dev Module (USB CDC On Boot: Enabled), then Tools > Port and choose the board's port.

This sketch is compiled for the board before the page is published. It has not been run on real hardware by us.

What you should see

Open the Serial Monitor at 115200. After half a minute to settle, it prints ON when you move in front of it.

If it does not work

It triggers for no reason in the first minute.
That is the sensor settling. Wait about 30 seconds after power-on.

The same part on the ESP32-S3

Build something with it

These Build Packs use this part on this board, with the same pins.

More parts on the ESP32-C3