All wiring guides

Free wiring guides

Wire the AM312 PIR motion sensor to the ESP32-S3

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-S3
VCC3V3
OUTGPIO 5
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-S3-DevKitC-1 (N8R2 or N16R8)
// https://stem.manusignal.com/en/parts/am312-pir-motion-sensor-esp32-s3

const int PIN_OUT = 5;

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 > ESP32S3 Dev Module, 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-C3

More parts on the ESP32-S3