ESPHome NodeMCU Issue after loss of power

I have an ESP8266 NodeMCU with a DHT22 and 0.96 OLED attached. All working well, except when there is a loss of power.

When power is restored the readout on the screen shows temperature as a negative number. The only way to restore correct operations is to upload to the device again from ESPHome.

Here is my config…

esphome:
  name: housemon
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "<SSID>"
  password: "****************"

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

captive_portal:

time:
  - platform: homeassistant
    id: esptime

font:
  - file: 'slkscr.ttf'
    id: font1
    size: 9

  - file: 'BebasNeue-Regular.ttf'
    id: font2
    size: 48

  - file: 'arial.ttf'
    id: font3
    size: 14

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

status_led:
  pin: GPIO2

sensor:
  - platform: dht
    pin: GPIO14
    temperature:
      name: "Family Room Temperature"
    humidity:
      name: "Family Room Humidity"
    update_interval: 60s
  - platform: homeassistant
    id: inside_temperature
    entity_id: sensor.family_room_temperature
    internal: true

i2c:
  sda: GPIO5
  scl: GPIO4
  scan: false

display:
  - platform: ssd1306_i2c
    model: "SH1106 128x64"
    address: 0x3C
    lambda: |-
      // Print "gregoinc" in top center.
      it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "gregoinc");

      // Print time in HH:MM formatsensor.family_room_temperature
      it.strftime(0, 60, id(font2), TextAlign::BASELINE_LEFT, "%H:%M", id(esptime).now());

      // Print inside temperature (from homeassistant sensor)
      if (id(inside_temperature).has_state()) {
        it.printf(127, 23, id(font3), TextAlign::TOP_RIGHT , "%.1f°", id(inside_temperature).state);
      }

Have tried a number of things, including config changes, but none seem to work?

Any ideas greatly appreciated.

Hi,

I have similar issue, but the power reset on NodeMCU solves the issue. But I do not understand, why ?
If I power off and on DHT provides crazy data, power reset (not off/on) solves the issue.
Do you have any idea ?
thanks

Power supplied to oled and dht via nodemcu board? Maybe external power source could help, ex. The VIN pin on the board (which is connected to the usb +5v directly)

I have tried VIN and external 5V also, same result.
Shorter cables, another NodeMCU → same issue.
I have tried to power on and connect the DHT later, same issue, but with reboot it was fine.
It seems something is soo quick via normal boot what is needed for DHT, some registration, charging ?

I have found the problem. :smiley:
The DHT model was not specified, after power off it was recognized as DHT11, after reboot DHT22
A have added the modell: DHT22 line and everything fine :slight_smile:

Yes, I solved my issue some time back with the same solution… see below…

sensor:
  - platform: dht
    model: AM2302
    pin: GPIO14
    temperature:
      name: "Family Room Temperature"
    humidity:
      name: "Family Room Humidity"
    update_interval: 60s
  - platform: homeassistant
    id: inside_temperature
    entity_id: sensor.family_room_temperature
    internal: true

Works great. Glad you got it sorted.