Cannot get my door sensor to work

I have never tried to do a multi-sensor before but thought that I would give it a go. Started off downloading ESPhome but ran into the integration not see my usb connection. Tried tasmotizing and then converting to ESPhome and got a “connection refused” error. So Tasmota it is. I am trying to keep track of the temp in my server closet so I have a DHT22 sensor for temp and a reed switch for the door that will turn on a light when the door is open connected to a D1 mini. The DHT22 part was simple enough.

Connections:

  • – 3.3V
  • – GND
    data – D4 (GPIO2)

Works great and came in to home assistant perfectly.

The reed switch however is a different story. I connected it between GND and D5 (GPIO14) as SWITCH1 but nothing is in home assistant. I understand that there is no relay on the D1 mini so I tried to bring in the state of SWITCH1 using an MQTT binary sensor.

- platform: mqtt

    name: "Server Door"

    state_topic: "stat/SW_Server_Node/SWITCH1"

    payload_on: "Closed"

    payload_off: "Open"

    qos: 0

    device_class: door

I am pretty sure that I am missing something but I have been trying to find examples and documentation and coming up short. Does anyone have any references or examples they could share?

Can you use


or

I cannot get ESPHome to work at all if that is what you mean? I have created a new node, tried several usb cables, restarted and uninstalled and reinstall the add-on several times. I am never able to use usb to upload to the D1 mini and when i try OTA, i get that the connection is refused,

Did you try setoption78 1 ?

I saw that but I thought that meant if you received an error in tasmota saying the upload of the ESP binary wasn’t successful. I would download successfully but when I go to the ESPHome add-on, I get the connection refused error when I try to edit the configuration and upload the changes. I can give it a try though,

SO78 1 did not change anything for me

I figured out that it was not connecting to my d1 mini because the wifi network I was adding the device to is a hidden network that does not broadcast publicly. Once I changed the network settings, it is now online. But now I am having an issue with my DHT22. As I am uploading the new edits, I am getting that the data transferred from the sensor is not correct.

[11:35:28][W][dht:162]: Requesting data from DHT failed!
[11:35:28][W][dht:060]: Invalid readings! Please check your wiring (pull-up resistor, pin number).

Here is the ESPHome config:

esphome:
  name: server_node
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: "my SSID"
  password: "my PASSWORD"
  use_address: 192.168.30.29
  manual_ip:
    static_ip: 192.168.30.29
    gateway: 192.168.30.1
    subnet: 255.255.255.0
    dns1: 192.168.30.1

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Server Node Fallback Hotspot"
    password: "zMu0AVEuhrb9"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

sensor:
  - platform: dht
    pin: GPIO13
    model: DHT22
    temperature:
      name: "Server Temp"
      unit_of_measurement: "F"
    humidity:
      name: "Server Humidity"
    update_interval: 30s

binary_sensor:
  - platform: gpio
    pin: GPIO14
    name: "Server Door"
    device_class: door

I have tried using the D# and the GPIO# for the pin and it has the same result.

Try switching pins, adding pulllup, and manually specifying the DHT type.

I have manually specified the DHT type and tried switching pins. Not sure why I would need a pullup when the sensor worked correctly in tasmota without one. I tried adding INPUT_PULLUP in the config but that didn’t change anything. The kind of DHT22 I have come on a tiny circuit board that has a resistor on it already.

What GPIO numbering system are you using?

I am getting the numbers from a d1 mini pinout diagram.

Try “D5” instead.

Tried D5 and no change so I went back to the ESPHome docs and it gives you a list of DHT models. I know it is a DHT22 but there was a DHT22_TYPE2 listed. I gave that a try and now it is reading the sensor. I guess the TYPE2 is for sensors that have the circuit board. Not 100% sure. Now I just need to get the reed switch to work.

Got it all sorted. Here is the final ESPHome yaml:

esphome:
  name: server_node
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: "my SSID"
  password: "my PASSWORD"
  use_address: 192.168.30.29
  manual_ip:
    static_ip: 192.168.30.29
    gateway: 192.168.30.1
    subnet: 255.255.255.0
    dns1: 192.168.30.1

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Server Node Fallback Hotspot"
    password: "zMu0AVEuhrb9"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

web_server:

sensor:
  - platform: dht
    pin: D5
    model: DHT22_type2
    temperature:
      name: "Server Temp"
    humidity:
      name: "Server Humidity"
    update_interval: 30s

binary_sensor:
  - platform: gpio
    pin: GPIO2
    name: "Server Door"
    device_class: door

Thanks for all the help.