Schluggi / AIOsense

ESPHome based all-in-one sensor
https://aiosense.readthedocs.io/en/latest/
MIT License
124 stars 22 forks source link

PIR not working on ESP8266 #78

Closed CappyT closed 1 year ago

CappyT commented 1 year ago

Category

Version of ESPHome / AIOsense ESPHome 2023.3.2 / 2.0.0 board

Describe the bug The esp8266 (D1 Mini) PIR pins are configured incorrectly as reported by esphome, GPIO13 does not have an internal pulldown

Failed config

binary_sensor.gpio: [source /config/esphome/.esphome/packages/6d7fe4d6/esphome/packages/sensors/pir.yaml:6]
  platform: gpio
  name: PIR
  id: motion_pir
  pin: 
    number: GPIO13

    Only GPIO16 supports pulldown.
    mode: INPUT_PULLDOWN
  device_class: motion
  filters: 
    - delayed_on: 0s
    - delayed_off: 1s

I managed to fix 2 other small bugs for the esp8266 (D1 Mini), I don't know if i should send a PR.

How can I fix the PIR sensor? I don't know much about electronics, I just know enough about ESPHome

Schluggi commented 1 year ago

You're welcome :)

ESP8266 are not in use at my flat, so I haven't test it yet. I've fixed the led and CPU Temp sensor based on your changes :)

I've also fixed the PIR (9111b0f). A pulldown is not really necessary. It's only there because someone has problems with there PIR (#52).

You can try all fixes by changing the refresh interval to 1s and recompile.

packages:
  remote_package:
    url: https://github.com/schluggi/AIOsense
    ref: main
    refresh: 1d  # <--- change it to "1s"
CappyT commented 1 year ago

You're welcome :)

ESP8266 are not in use at my flat, so I haven't test it yet. I've fixed the led and CPU Temp sensor based on your changes :)

I've also fixed the PIR (9111b0f). A pulldown is not really necessary. It's only there because someone has problems with there PIR (#52).

You can try all fixes by changing the refresh interval to 1s and recompile.

packages:
  remote_package:
    url: https://github.com/schluggi/AIOsense
    ref: main
    refresh: 1d  # <--- change it to "1s"

Thank you for the quick fix, however the PIR stays always on... this is my main file:

substitutions:
  name: "aiosense-gabry"  # lowercase only, have to be unique
  friendly_name: "AIOsense Camera Gabry"  # device name and entity prefix
  version: "2.0.0"  # your AIOsense version

  bh1750_update_interval: 5s

  bmex80_address: "0x76"  # for some modules you have to change it to 0x77
  bmex80_offset_humidity: "0"
  bmex80_offset_temperature: "0"
  bmex80_update_interval: 30s

  # bme680_bsec_sample_rate: lp # lp -> 3s, ulp ->5min
  # bme680_bsec_temperature_offset: "0"

  # ld2410_max_distance_move: 4.5m
  # ld2410_max_distance_still: 4.5m
  # ld2410_timeout: 5s

  # pir_delayed_off: 1s
  # pir_delayed_on: 0s
  pir_pin_mode: "INPUT"

packages:
  remote_package:
    url: https://github.com/schluggi/AIOsense
    ref: main
    refresh: 1s
    files:
      - esphome/packages/config/base.yaml

      # --- select your board ---
      # - esphome/packages/config/esp32-c3-mini.yaml
      # - esphome/packages/config/esp32-d1-mini.yaml
      # - esphome/packages/config/esp32-s2-mini.yaml
      - esphome/packages/config/esp8266-d1-mini.yaml

      # --- select your sensors ---
      - esphome/packages/sensors/bh1750.yaml
      # - esphome/packages/sensors/buzzer.yaml  # AIOsense >= 2.1.x only
      - esphome/packages/sensors/bme280.yaml  # enable for bme280
      # - esphome/packages/sensors/bme680.yaml  # disable for bme280
      # - esphome/packages/sensors/bme680_bsec.yaml  # does not work yet
      - esphome/packages/sensors/occupancy.yaml  # only if pir & mmWave are on
      - esphome/packages/sensors/pir.yaml
      # - esphome/packages/sensors/rgb_led.yaml  # esp32-c3-mini only
      - esphome/packages/sensors/led.yaml  # d1-mini only

      # --- select your radar sensor ---
      # - esphome/packages/sensors/ld2410.yaml
      - esphome/packages/sensors/sen0395.yaml

# Enable Home Assistant API
api:
  encryption:
    key: "ih3kU+z9htu/Toh8KE9r7vrxQd3+faKuyeLwfPiP6MQ="

ota:
  password: !secret password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # manual_ip:
  #   static_ip: 192.168.1.111
  #   subnet: 255.255.255.0
  #   gateway: 192.168.1.1

# bluetooth_proxy:
CappyT commented 1 year ago

After some digging, the problem boils down to the pulldown input. It needs to be there to prevent "floating" (idk if it's the correct term in electronics). My board has this kind of issue.

I'd leave this open (feel free to close it if you want), but I would try to put a physical resistor in the board for ESP8266 compatibility, I'll let you know how it will go.

I just ask you, how big of a resistor I may need?

Schluggi commented 1 year ago

Hey @CappyT,

sorry for late reply. This is strange, because the PIR should pulldown the pin when no motion is detected.

Anyway, you can try a 4,7k resistor.

Good look :)

Schluggi commented 1 year ago

Closing because of inactivity