Pressure Mat ESPHome

Hi! I want to create a pressure sensor that when my dog walks on, will open his doggy door. I’d just have it placed under a welcome mat of sorts. I purchased a pressure sensor mat here:

I’ve extended the wires and attached jumper wires, tested it with original battery alarm that came with it, and ensured the alarm still went off when I applied pressure on the mat. All good there.

However when I attached it to my ESP32 is where I get stuck. I applied the below code. But when I check the logs, I don’t get any response to applied pressure. This is my first ESP32 project, so I’m sure I’ve messed up, however I can’t pinpoint it even after watching various ESP tutorials.

I’m using the below ESP board, connecting one wire to ground and the other to D4. I’ve also tried various other pins.

Also, would I need to set the noise encryption to yes? If so how would I do that?

I get this from the logs: [C][api:143]: Using noise encryption: NO

Any help would be appreciated!

Best

esphome:

  name: "doggy-door-pressure-mat"

esp32:

  board: esp32dev

  framework:

    type: arduino

# Enable logging

logger:

# Enable Home Assistant API

api:

ota:

wifi:

  ssid: !secret wifi_ssid

  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails

  ap:

    ssid: "Esphome-Web-C92A14"

    password: "3nTfEoSedK9M"

captive_portal:

binary_sensor:

  platform: gpio

  pin:

    number: 5

    inverted: true

    mode:

      input: true

      pullup: true

  name: Doggy Door Pressure Mat
1 Like

Is the mat circuit normally-open or normally-closed?

The mat is normally-open.

Then it looks like it should work. Possibly your pin numbering is wrong - you mention D4 above then your code is going to pin 5.

This works for me and if your mat is normally-open it should work for you:

binary_sensor:
  - platform: gpio
    id: button1
    pin: 
      number: GPIO05
      mode: INPUT_PULLUP
      inverted: True   
api:
  encryption:
    key: "some_hectic_encryption_code"

Will encrypt the data between the node and HA.

This is where I’m currently placing my wires.


Tha’s GPIO04.

On some of the ESP8266 breakout boards the Dx pins don’t match the GPIO numbers - for instance D4 was GPIO02 on NODEMCU boards.

For the DEVKIT you have - D4 is GPIO04.

GPIO05 is 3 pins to the right.

That did it! My goodness you can’t believe how happy I am that this is working. Thank you so much!

1 Like

I wonder if this would work with a door sensor?