Go Down

Topic: DHT11 not working on Standalone-ATMega (Read 3961 times) previous topic - next topic


Hello everyone,

i tried to build a standalone room-thermometer/hydrometer with an LCD-Display and the DHT11-Sensor. So far everything is working but only when i connect it to my Arduino-Board.
I've tried to set it up with a standalone ATMega328 on a Breadboard and all i get is "Hum.: 0.00/ Temp.:0.00".
On the arduino it works just fine. Even if i just plug the Sensor-Cable from the ATMega into my Arduino the Serial-Monitor shows the correct temperature and humidity (or at least it shows some numbers). But neither the LCD nor the Serial-Monitor shows anything but 0.00 on the ATMega.

More Info:

  • The ATMega328 has the Arduino-Bootloader installed, the Board-Setup is "ATMega328 on breadboard (8MHz internal clock).

  • Powercomes from an external Wall-Plug with 5V/1A

  • If i disconnect the Sensor from the ATMega the LCD reads "Failed to read from DHT", which is correct

This is the Code i use. Most of it comes directly from the DHT11-example:

Code: [Select]

#include "DHT.h"
#include <LiquidCrystal.h>

#define DHTPIN 8     // what pin we're connected to

#define DHTTYPE DHT11   // DHT 11

// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

//LCD Pin1 -> GND
//LCD Pin2 -> 5V
//LCD Pin3 -> GND/Poti
//LCD Pin4 -> 12 (RS)
//LCD Pin5 -> GND (R/W)
//LCD Pin6 -> 11 (E)
//LCD Pins 7-10 -> NC (DB0-DB3)
//LCD Pins 11-14 -> 5-2 (DB4-DB7)
//LCD Pins15/16 (Backlight) -> 5V/GND+Resistor

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
//  Serial.begin(9600);
//  Serial.println("DHTxx test!");
  lcd.begin(16, 2);
  lcd.print("DHTxx test!");

void loop() {
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h)) {
    lcd.print("Failed to read from DHT");
  } else {
    lcd.print("Humidity: ");
//    Serial.println(h);
    lcd.print("Temp.: ");
//    Serial.println(t);
    lcd.print(" ");

My question: What is wrong?


Where are your decoupling capacitors?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


What capacitors? Where should they be?

For the ATMega i used this Layout: http://arduino.cc/en/Tutorial/ArduinoToBreadboard (Minimal Circuit). I didn't see any caps, so i didn't put any on it.
For the DHT i looked here: http://learn.adafruit.com/dht/overview


On the power supply to the chip, as close to the chip as possible.

You have configured the '328 to use the internal clock haven't you?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield


The power-supply has has special pins to connect to breadboard-projects(stabilized output and all). I assume that it has decoupling caps built-in. Sort of like the breadboard-power-supply from ladyada, but not clip-on.
The chip is configured, bootloaded and programmed for standalone use.
Both worked in every other circuit so far, even together. The chip still works after being hooked up to this project, so it wasn't damaged by the power-supply.
I even tried switching power from the external supply to the 5V/GND-Pins on my arduino. No luck.


Just a guess - in that case what I would try is a regular, externally clocked '328 with crystal and caps. This would demonstrate if there was a problem with talking to sensor using the internal clock speeds.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield



i have identical problem like @Pteppic1 ,

but, adding external clock does not solve my problem.


That diagram is for uploading the bootloader. What are you actually trying to do?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield


Feb 04, 2014, 10:30 pm Last Edit: Feb 04, 2014, 10:36 pm by bigkoma Reason: 1
I wanted to show how connected the clock, this picture illustrates it.

What are you actually trying to do?

"DHT11 not working on Standalone-ATMega"  - support(use)  DHT11 by ATMEGA328P


Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Go Up