AM312 motion sensors going crazy

I have several esp32 with AM312 motion sensors and LED lights configured about my house. I’ve only recently noticed that they all are turning on and off rapidly. I don’t know when this started happening. I wirelessly reinstalled my config to each, performed an update all, rebooted them, and tried adding and removing the pull-up line - none of these changes made a difference.

Any other suggestions? Thanks

esphome:
  name: esp32-office-closet
  platform: ESP32
  board: esp-wrover-kit

# OTHER STUFF

binary_sensor:
  # yellow
  - platform: gpio
    # pin: GPIO21
    pin:
      number: GPIO21
      mode: INPUT_PULLUP
    id: office_closet_motion
    name: "Office Closet Motion"
    device_class: motion  

I have been using the same for several years without a problem.
How do you have a long cable to the sensor? Some interference on a long cable.
My simple configuration:

binary_sensor:
  - platform: gpio
    name: "xxxxxxxx"
    pin: GPIO23
    device_class: motion

3.3V power supply

Me too. Cable is short (at most 6 inches). This use to work perfect for months. Don’t know what happened.

I’m having the same issues here.
I have several AM312 motion sensors and several ESP32 (ESP32, ESP32CAM) and ESP8266 (D1 mini) devices and tried to set them up with home assistant.
No matter what combination i try it results in constant false positives. The things i tried:

  • Different ESP devices with cables (soldered and pins) connected to AM312
  • Different AM312 units connected using different cable setups (with lenghts ranging from 3cm to 30cm
  • pullup activated and disabled
  • filter on settings ranging from 10 ms to 500 ms
  • shielding the sensor with grounded alu foil

All result in either constant ON or switching ON intermittendly without any apparent reason (had the sensor for instance in a closed container not “seeing” anything yet constant ON/OFF)

I cannot figure out what to do.
Have you been able to solve the issue?

No, I gave up

Hey I managed, after much frustration and random triggers, to solve this. Taking a look at the datasheet (and verified on my scope), this is a non-inverted signal. Therefore a pullUP is not as useful as a pulldown. I’m using esphome.io, so the enablement of a pulldown was quite easy. Pretty similar in arduino, etc.

Note I’m using a RPI Pico W, not an ESP32/8266. Datasheet seems to indicate that the range is 50-80kohms for the pullup/down.

binary_sensor:
  - platform: gpio
    name: "Motion PIR Sensor 1"
    device_class: motion
    pin: 
      number: GPIO16
      mode:
        input: true
        pulldown: true

Thins work for me on a ESP32. Thank You!

1 Like

Hi. When I tried enabling the pulldown on my devices it disabled the sensor working.
I’m suffering from false triggers and tried varous methods. It can fine for days and then false triggers. strange… Esp32 and AM312 used.

I have a few ESP32’s lying around. I’ll try it on mine. You could also try this externally with a resistor to GND.
Update: my wemos D1 mini wouldn’t allow for a pulldown on an available GPIO, so I measured with external resistor (to GND). A 47kohm measured 2.0v when motion was detected. Worked… but too close to the hysteresis level of the GPIO for my liking.

I used a 220kohm and it was at 2.8v.

Will leave this setup for a few days and see if it works without false alarms.

Some more research. Summary below:
-WEMOS D1 Mini works with the external 220k pulldown resistor to GND, but has some other source of instability (losing/reconnecting to the HA API).
-HUZZAH32 (ESP32 adafruit feather) supports internal “software” pulldown, but the AM312 can’t pullup strong enough to overcome it. 220k resistor yields 2.7v on detect – within spec.
-Pico works with the “software” pulldown, but haven’t measured the voltage. It’s pretty rock solid.

My updated esphome code block:

binary_sensor:
  - platform: gpio
    name: "Motion PIR Sensor 1"
    device_class: motion
    pin: 
      #number: D5 #(wemos)
      number: GPIO21 #(Huzzah32 feather)
      mode:
        input: true
        #pulldown: true #works on RPI PICO.  N/A on wemos D1 mini, used 220k pulldown.  too strong on HUZZAH32, 220K pulldown used
    filters:
      - delayed_off: 30s  #2s is hardware default -- too frequent for my tastes
1 Like