Pages: [1]   Go Down
Author Topic: DHT11 not working on Standalone-ATMega  (Read 1584 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.smiley-mad.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:
#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

DHT dht(DHTPIN, DHTTYPE);
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!");
  dht.begin();
}

void loop() {
  lcd.setCursor(0,0);
  // 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: ");
    lcd.print(h);
//    Serial.println(h);
    lcd.setCursor(0,1);
    lcd.print("Temp.: ");
    lcd.print(t);
//    Serial.println(t);
    lcd.print(" ");
    lcd.print((char)223);
    lcd.print("C");
  }
}

My question: What is wrong?


* DHT11_LCD.png (190.96 KB, 1197x1158 - viewed 90 times.)
Logged

0
Offline Offline
Shannon Member
****
Karma: 217
Posts: 12583
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where are your decoupling capacitors?
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Leeds, England
Offline Offline
God Member
*****
Karma: 16
Posts: 719
Quick, chuck it in the bin before the boss finds out...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Leeds, England
Offline Offline
God Member
*****
Karma: 16
Posts: 719
Quick, chuck it in the bin before the boss finds out...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

i have identical problem like @Pteppic1 ,

but, adding external clock does not solve my problem.

Logged

Leeds, England
Offline Offline
God Member
*****
Karma: 16
Posts: 719
Quick, chuck it in the bin before the boss finds out...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That diagram is for uploading the bootloader. What are you actually trying to do?
Logged

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wanted to show how connected the clock, this picture illustrates it.

Quote
What are you actually trying to do?

"DHT11 not working on Standalone-ATMega"  - support(use)  DHT11 by ATMEGA328P
« Last Edit: February 04, 2014, 04:36:57 pm by bigkoma » Logged

Leeds, England
Offline Offline
God Member
*****
Karma: 16
Posts: 719
Quick, chuck it in the bin before the boss finds out...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, what code are you using?
Logged

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Pages: [1]   Go Up
Jump to: