Configuration for AM2303 sensor

I am new on Home Assisant but have installed Hass.io image on my Raspberry Pi 3B+ because I want to check the temperature of my freezer.
After the Hass.io insatll, I have add the Esphome add-on because I want to measure the temperature (and humidity) with a AM2302 sensor connected to a ESP32 board.
For the first test and trainning myself, I have connected a led on a GPIO of the ESP32 and I have created YAML file to control it with a switch on Home Assistant according to code below:

esphome:
  name: freezer
  platform: ESP32
  board: esp32dev

wifi:
  ssid: "*********"
  password: "********"

 # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "*************"
    password: "********"

captive_portal:
    
# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "*******"

ota:
  password: "*******"
  
# Example configuration entry
switch:
  - platform: gpio
    pin: 4
    name: "Led switch"

After a short time to understand I have to add the device on the dash board, it works well.
After, I have add temperature and humidity sensor AM2303 and I have modified the YAML file as below:

esphome:
  name: freezer
  platform: ESP32
  board: esp32dev

wifi:
  ssid: "*********"
  password: "********"

 # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "*************"
    password: "********"

captive_portal:
    
# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "*******"

ota:
  password: "*******"
  
# Example configuration entry
switch:
  - platform: gpio
    pin: 4
    name: "Led switch"

# Example configuration entry
sensor:
  - platform: dht
    pin: 5
    temperature:
      name: "Freezer temeprature"
    humidity:
      name: "Freezer Humidity"
    model: AM2302
    update_interval: 60s

Now, nothing works and I have a WARNING in the log. Do you have in idea of the root cause?

Welcome to the forum!

What is the WARNING, and how have you wired up the sensor? Should be pin 1 (or red wire) to 3.3V, pin 2 (or yellow wire) to ESP pin 5 pulled up to 3.3V (a 1k-ish resistor between pins 1 & 2 (or red & yellow wires)), pin 3 & 4 (or black wire) to ground.

1 Like

Concerning the WARNING, I have not the exact output but I will send the output log when I am going to come back to home.
For the wiring, it is :
Pin 1 —> 3.3V (of ESP32 board)
Pin 2 —> GPIO5 (of ESP32 board)
Pin 3 —> Not connected
Pin 4 —> GND (of ESP32 board)
I have tested with a pull-up resistor 4.7kohms and 10kohms between Pin 1 and Pin 2 but I have the same behavior.
After checking the AM2302 datasheet (AM2302 datasheet), I am seeing that the Pin 3 shall be connected to GND too according to the table and the pull-up resistor shall be 1kohms.
I will add the connection to Pin 3 and change the pull-up resistor value to 1kohms and test again to check if it is the cause of my issue.

I have changed “board: esp32dev” by “board: nodemcu-32s” because I think it was a mistake and I have add a static IP.
My YAML file is now :

esphome:
  name: freezer
  platform: ESP32
  board: nodemcu-32s

wifi:
  ssid: "**********"
  password: "**********"
  
  manual_ip:
    # Set this to the IP of the ESP
    static_ip: 192.168.0.17
    # Set this to the IP address of the router. Often ends with .1
    gateway: 192.168.0.254
    # The subnet of the network. 255.255.255.0 works for most home networks.
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "**********"
    password: "**********"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "**********"

ota:
  password: "**********"

# Example configuration entry
switch:
  - platform: gpio
    pin: 4
    name: "Switch LED"

# Example configuration.yaml entry
sensor:
  - platform: dht
    pin: 5
    temperature:
      name: "Freezer temperature"
    humidity:
      name: "Freezer Humidity"
    model: AM2302
    update_interval: 60s

I have always warnings:

INFO Reading configuration /config/esphome/freezer.yaml...
INFO Starting log output from 192.168.0.17 using esphome API
INFO Connecting to 192.168.0.17:6053 (192.168.0.17)
WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Error connecting to 192.168.0.17: [Errno 111] Connection refused). Re-Trying in 1 seconds
INFO Connecting to 192.168.0.17:6053 (192.168.0.17)
WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Error connecting to 192.168.0.17: [Errno 111] Connection refused). Re-Trying in 1 seconds
INFO Connecting to 192.168.0.17:6053 (192.168.0.17)
WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Error connecting to 192.168.0.17: [Errno 111] Connection refused). Re-Trying in 2 seconds
INFO Connecting to 192.168.0.17:6053 (192.168.0.17)
WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Error connecting to 192.168.0.17: [Errno 111] Connection refused). Re-Trying in 3 seconds
INFO Connecting to 192.168.0.17:6053 (192.168.0.17)
WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Error connecting to 192.168.0.17: [Errno 111] Connection refused). Re-Trying in 5 seconds

I don’t understand the warning because I see that my esp32 board is connected to WIFI in my router manager.

Since there is an issue with WIFI, I don’t think problem is on the wiring of the AM2302 sensor. So I have not tested with different pull-up resistor.
One strange thing is Esphome detects the ESP32 because there is the green light to indicate that the device is detected.
Thank in advance for your help.

I wonder if it’s this issue (and this one)? Do you know what version of EspHome you have installed? The latest 1.14.4 seems to have broken a few things.

1 Like

Tron, thank you Tron for your reply.
For you information, I have downloaded last week the Hass.io image for Raspberry Pi 3 Model B and B+ 32-bit from the Home Assisattn web site https://www.home-assistant.io/hassio/installation/ and I have installed it on the SD card of my Raspberry PI 3 Model B+.
I don’t know the installed Home Assistant version and I am not at home but I am going to check the Home Assistant version and give you the answer.
Just to save time, do you how and where I can easily find the Home Assistant version?

It’s the ESPHome version that matters. I don’t run the image: I run HA under a Python virtual environment on a Linux installation, and run ESPHome on a separate machine.

Try under Developer Tools (the hammer icon) then Info.

Please find the screenshot of my Home Assistant system:


I don’t find the version 1.14.4.
Do you abnormal things?

Please the screenshot of Esphome add-on:


I find the version 1.14.4.

I think your problem is caused by that version. I don’t use addons so I can’t help with downgrading to an older version.

Finally, it is a known bug in the esphome version 1.14.4.
I have upgraded esphome add-on to version 1.14.5 in home assistant to fix it ( see topic) and now, all works fine.
Thank you for your help.

1 Like