D1 Mini I2C Multisensor - AM312 not working

Hi all

So I’m trying to make a multisensor, using the following:

  • Wemos D1 Mini
  • HTU21D (I2C Temperature and Humidity Sensor) (VCC to 3.3V, GND to GND, SDA to D2, SCL to D1)
  • BH1750 (I2C Light Sensor) (VCC to 3.3V, GND to GND, SDA to D2, SCL to D1)
  • AM312 PIR Sensor (VCC to 3.3V, GND to GND, Signal to D3)

Diagram as follows:

Unfortunately, while the I2C devices work happily like this, the AM312 doesn’t seem to detect motion correctly. I’ve checked all the wires are sound and everything seems to be good, and the I2C sensors update, but the AM312 always shows as motion detected, and never stops showing that in HomeAssistant.

Any ideas?

Thanks!

Rob

Snippet of relevant parts of my .yaml in case that’s useful:

esphome:
  name: multisensor_1
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: SECRET
  password: SECRET PASSWORD
  ap:
    ssid: $hostname AP

captive_portal:

logger:

api:

ota:

web_server:
  port: 80

substitutions:
  hostname: 'Multisensor 1'

switch:
  - platform: restart
    name: $hostname restart

binary_sensor:    
  - platform: status
    name: $hostname Status
  - platform: gpio
    pin: D3
    name: $hostname Motion
    device_class: motion

sensor:
  - platform: wifi_signal
    name: $hostname WiFi Signal
    update_interval: 60s
  - platform: uptime
    name: $hostname Uptime
  - platform: htu21d
    temperature:
      name: $hostname Temperature
      icon: "mdi:thermometer-lines"
    humidity:
      name: $hostname Humidity
      icon: "mdi:water-percent"
    update_interval: 60s
  - platform: bh1750
    name: $hostname Illuminance
    icon: "mdi:brightness-percent"
    address: 0x23
    measurement_time: 69
    update_interval: 60s

text_sensor:
  - platform: version
    name: $hostname ESPHome Version
  - platform: wifi_info
    ssid:
      name: $hostname WiFi
    ip_address:
      name: $hostname IP Address

i2c:
  sda: D2
  scl: D1
  frequency: 100kHz
  scan: True
  id: bus_a

Try using the USB/5VDC power pin instead of 3.3VDC for the AM312.

Try a different pin for the motion sensor. D3 == GPIO0 which is not recommended as input.

1 Like

As Keith said, connect it to 5v. My configuration is very similar to yours (temp, pir, lux, wemos mini) only that the pir is connected to 5v instead of 3v

@exxamalte same problem on D4 == GPIO2.

@FredTheFrog & @mcarty I thought the GPIO pins on the ESP would only be 3.3V tolerant? (I’m assuming I’m wrong if you have this working!) - I’ll give this a shot.

Thanks to you all for responding :smiley:

Please have a look at the linked tutorial.
D5/D6/D7 are good.
D3/D4 are not.

4 Likes

And moving the signal wire to D5 solved it. I thought I shouldn’t use D5/D6/D7 because they were used for SPI… Thanks Exxamalte - if only I’d read the article properly to know which ones are good for general use!

If I get any erratic behaviours with it, I’ll try it on 5V. Thanks again all!

2 Likes

Second the solution to check the pins! My AM312 was constantly on till I moved it to D7 which is a “safe” pin to use. Although now it’s very twitchy with movement as it resets every 2 seconds, so I may swap to the other one!