Swapped DHT11 with DHT22, and now there are occasional bad readings

Hi,

Can somebody please help me figure out why changing from a DHT11 to a DHT22 introduces random spikes at 25°C?

I removed the DHT11 which had a built-in 10k bias resistor for the data line, and then installed a DHT22 sensor and added the 10k pullup myself.
Both sensors used the same pin on the ESP8266.
I also changed the DHT platform in my YAML config from model: DHT11 to model: DHT22.
The DHT22 is powered with 3V3 (which is also what I connected the 10k bias resistor on the data pin to).

EDIT: I’ve found a lot of different datasheets for the DHT22, but this seems to be the only one with the original manufacturer’s name (Aosong) listed so I think this is the official datasheet. But it’s hosted by Seeed Studio so I don’t know if it’s the latest revision.
DHT22 (Aosong) Datasheet

In case my code is relevant, please see below.

################################################################################
# Define variables
################################################################################

substitutions:
  # Device Properties
  devicename: dev-air-quality
  friendly_name: Dev-Air-Quality
  device_topic: AirQuality
  device_sleephelper: input_boolean.esphome_disable_deep_sleep
  device_sleephelper_topic: admin/esphome_disable_deep_sleep
  
  # Logger Properties
  # This is used for the ESP_LOGx syntax, but not logger.log.
  log_tag: yaml
  
  # Sleep Properties
  sleep_time: 2min #54s #2min #10s #2min #1min #5min #10s
  # For API mode, run time needs to be roughly 10s. 5s failed because there wasn't enough time to read the binary sensor and prevent deeps sleep. The minimum run time is probably betwen 5s and 10s.
  run_time: 1s #2s #1s
  # The sensor will report data on boot, and then again for each sensor on their independent update_interval parameters until put to sleep again.
  # Set update interval to a longer time than run_time to ensure only 1 data update per wake.
  # I suspect that the update interval still has to be shorter than sleep time though. Otherwise the device seens to wake up and not publish
  global_update_interval: $sleep_time


  # Pinout
  # Wake        D0  # GPIO16  - Wake (deep sleep) - high at boot.
  pin_i2c_scl:  D1  # GPIO5
  pin_i2c_sda:  D2  # GPIO4
  # Reserved    D3  # GPIO0   - biased high - connected to flash button 
  # Reserved    D4  # GPIO2   - biased high - connected to on-board LED
  pin_rx:       D5  # GPIO14
  pin_tx:       D6  # GPIO12
  pin_dht:      D7  # GPIO13
  #             D8  # GPIO15  - biased low
  #             RX  # GPIO3
  #             TX  # GPIO1   - debug output at boot
  #             A0  # ADC0

globals:
  - id: shutdown_reason
    type: std::string
    restore_value: no
    initial_value: '"normal deep sleep"'


################################################################################
# Define Device
################################################################################

esphome:
  name: $devicename
  
  on_boot:
    then:
      - logger.log:
          format: "Booted"
          level: ERROR

  on_loop:

  on_shutdown:
    - logger.log:
        format: "Normal Deep Sleep"
        level: ERROR

esp8266:
  board: d1_mini

# Enable logging
logger:
  level: DEBUG #WARN
  # Publish logs to MQTT
  on_message:
    level: WARN
    then:
      - mqtt.publish:
          topic: $device_topic/logger
          payload: !lambda |-
            return "Level: " + to_string(level) + " ||| Tag: " + tag + " ||| Message: " + message;
  
# Enable Over-The-Air flashing
ota:
  #safe_mode: True
  password: !secret ota_password
  on_end:
    - logger.log:
        format: "OTA Update"
        level: ERROR


################################################################################
# Power
################################################################################

deep_sleep:
  id: deep_sleep_control
  sleep_duration: $sleep_time
  run_duration: $run_time


################################################################################
# Wireless Access
################################################################################

wifi:
  id: wifi_client
  power_save_mode: LIGHT #There are other options. Just checking if this helps with self heating.
  fast_connect: true # Skip wifi scan to save time.
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  
  # Set a static IP address.
  manual_ip:
    static_ip: 192.168.86.200
    gateway: 192.168.86.1
    subnet: 255.255.255.0
  # If changing the name or the IP address of the device, this provides the old address so that ESPHome knows which device to overwrite.
  use_address: "192.168.86.200"


################################################################################
# Home Assistant Connection
################################################################################

# Enable MQTT
mqtt:
  id: mqtt_client
  broker: !secret mqtt_broker
  port: !secret mqtt_port
  username: !secret mqtt_user
  password: !secret mqtt_password
  discovery: true
  discovery_retain: true
  # Set empty birth and will messages to avoid showing unavailable during sleep
  birth_message:
  will_message:
  topic_prefix: $device_topic
  on_message:
    - topic: $device_sleephelper_topic
      qos: 0                                          #1
      payload: 'on'
      then:
        - logger.log:
            format: 'MQTT Admin: disable deep sleep'
            level: ERROR
        - deep_sleep.prevent: deep_sleep_control
    - topic: $device_sleephelper_topic
      qos: 0                                          #1
      payload: 'off'
      then:
        - logger.log:
            format: 'MQTT Admin: entering deep sleep'
            level: ERROR
        - deep_sleep.enter: deep_sleep_control


################################################################################
# Communication Protocols
################################################################################

i2c:
  sda: $pin_i2c_sda
  scl: $pin_i2c_scl
  id: bus_i2c
  scan: False       # Save time by skipping the I2C scan on startup since all addresses are known. Defaults to True
  frequency: 50kHz  # Defaults to 50kHz, SCD30 can't handle more than 100kHz.


################################################################################
# Functionality
################################################################################

# Air Quality, Temperature and Humidity.
sensor:
  # DHT11 Temperature and Humidity Sensor
  - platform: dht
    model: DHT22 #DHT11
    pin: $pin_dht
    temperature:
      name: "$friendly_name Temperature"
      id: temperature
    humidity:
      name: "$friendly_name Humidity"
      id: humidity
    update_interval: $global_update_interval
    
  # CO2, Temperature and Humidity
  - platform: scd30
    i2c_id: bus_i2c
    address: 0x61
    automatic_self_calibration: true
    update_interval: $global_update_interval
    co2:
      name: "$friendly_name CO2"
      id: co2
      accuracy_decimals: 1
    temperature:
      name: "$friendly_name Temperature SCD"
      id: temperature_scd
      accuracy_decimals: 2
      filters:
        - offset: 0
    humidity:
      name: "$friendly_name Humidity SCD"
      id: humidity_scd
      accuracy_decimals: 1
    #temperature_offset: 1.5 °C
    
  # TVOC, Estimated CO2
  - platform: sgp30
    i2c_id: bus_i2c
    address: 0x58
    store_baseline: yes
    update_interval: $global_update_interval
    eco2:
      name: "$friendly_name eCO2"
      id: eco2
      accuracy_decimals: 1
    tvoc:
      name: "$friendly_name TVOC"
      id: tvoc
      accuracy_decimals: 1

Use a 4K7 bias resistor.

How long are the leads to your DHT22?

Thanks Tom,

The datasheet says to use a 5.1k resistor, but since I don’t have one lying around, I’ve swapped the 10k for a 4.7k. This doesn’t appear to have fixed the issue though. I have doubts about whether or not a 5.1k bias will fix the issue now that 10k and 4.7k show the same problem, but I can try to find a 5.1k as a sanity check.

The wire I’ve used is about 80mm of 22AWG solid core wire (it’s in a breadboard). The datasheet says that at 3V3 with a 5.1k bias, I can’t exceed 100cm due to voltage drop. I’m nowhere near this but it doesn’t mention anything about noise. Although, I can’t see my setup being noisy.

I’ve found a lot of different datasheets for the DHT22, but this seems to be the only one with the original manufacturer’s name (Aosong) listed so I think this is the official datasheet. But it’s hosted by Seeed Studio so I don’t know if it’s the latest revision.
DHT22 (Aosong) Datasheet