Only getting whole number temp readings from my DHT 11 sensor

hi all,

I have a sensor for my lounge giving me temp and humidity readings though I am only getting whole number readings… is this something I can change?

here is my yaml file for the sensor.

esphome:
  name: lounge_sensor
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: !secret ssid
  password: !secret password
  manual_ip:
    static_ip: 192.168.0.45
    gateway: 192.168.0.1
    subnet: 255.255.255.0
    dns1: 192.168.0.1
    dns2: 192.168.0.1
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Lounge Sensor Fallback Hotspot"
    password: "Cerberus"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

# Enable Web server.
web_server:
  port: 80

# Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: homeassistant_time

i2c:
  sda: 4  # (Optional, Pin): The pin for the data line of the I²C bus. Defaults to GPIO4 for ESP8266.
  scl: 5  # (Optional, Pin): The pin for the clock line of the I²C bus. Defaults to GPIO5 for ESP8266.
  scan: True # (Optional, boolean): If ESPHome should do a search of the I²C address space on startup. Defaults to True.
  id: bus_a

sensor:
  - platform: wifi_signal
    name: "Lounge Sensor WiFi signal"
    update_interval: 120s

  - platform: uptime
    name: "Lounge Sensor uptime do not use"
    id: lounge_sensor_uptime_do_not_use
    internal: true
    update_interval: 15s

  - platform: tsl2561
    name: "Lounge Ambient Light"
    icon: mdi:lightbulb-on-outline
    address: 0x39
    update_interval: 60s
 
  - platform: dht
    pin: D3
    model: DHT11
    temperature:
      name: "Lounge Temperature"
    humidity:
      name: "Lounge Humidity"
    update_interval: 3s
   
    
text_sensor:
  - platform: version
    name: "Lounge Sensor ESPHome version"
    
  - platform: template
    name: "Lounge Sensor Uptime"
    lambda: |-
      uint32_t dur = id(lounge_sensor_uptime_do_not_use).state;
      int dys = 0;
      int hrs = 0;
      int mnts = 0;
      if (dur > 86399) {
        dys = trunc(dur / 86400);
        dur = dur - (dys * 86400);
      }
      if (dur > 3599) {
        hrs = trunc(dur / 3600);
        dur = dur - (hrs * 3600);
      }
      if (dur > 59) {
        mnts = trunc(dur / 60);
        dur = dur - (mnts * 60);
      }
      char buffer[17];
      sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
      return {buffer};
    icon: mdi:clock-start
    update_interval: 15s

switch:
  - platform: restart
    name: Lounge Sensor Restart

can I do anything in the yaml to sort this? or do I need a new board or sensor?

thank you for your help and time

Add accuracy_decimals: 1 to your dht config.

  - platform: dht
    pin: D3
    model: DHT11
    temperature:
      name: "Lounge Temperature"
      accuracy_decimals: 1
    humidity:
      name: "Lounge Humidity"
      accuracy_decimals: 1
    update_interval: 3s
1 Like

A dht 11 does only do while numbers doesn’t it? Useful for those with Fahrenheit. I think a dht22 is what we need when using centigrade (or partial degrees)

  • Good for 0-50°C temperature readings ±2°C accuracy
1 Like

thank you for your suggestion, i just tried it and unfortunately it made no difference but knowing that option exists may help me in the future, thank you

thank you for your reply,

i think you may be correct, when I bought the sensors they were supposed to be DHT22 but it was DHT11 that turned up, unfortunately due to life getting in the way it was nearly 2 months between me getting them and getting to set them up and find out so returning them is not an option. Oh well… guess I’m buying some DHT22 sensors and checking them this time…

anyone want to buy some DHT11 sensors LOL