DHT11 sensor and LED voltage halved?

Hi all

Just started with Arduino. I wonder if I could get some help... I have done the flashing LED exercise on PIN 9 and it was great, simple but great.

I wanted to create a temperature alarm so when the temp reached 21 degrees the LED would flash. (Its for a another project I have in mind to monitor battery temperature)

I bought a DHT11 which is on PIN 2, got the library for it wrote the sketch and it works, I couldn't believe it, however the LED is half the brightness of the flashing LED sketch!!! Indeed when I swop between sketches the volts across the LED in the flashing sketch is 2.4 - 2.6v. On the temp alarm sketch its 1.3 - 1.4v across the LED...!

Can anyone point to why that might be. There is a good 5v across the DHT11. I'm also using the serial port to tell me what the humidity/temp is, so I cant get my head around why the sensor or using the usd port might be trashing the LED output.

Can anyone point me in the right direction?

Best wishes

Del

We need your circuit and program.

Weedpharma

Hi

Yes of course... Sorry, that would help.

I have attached the sketch and a snapshot from Fritzing of my project. Alng with the Fritzing file. Many thanks

Del

BatteryAlarm.ino (2.08 KB)

I cannot download the ino file on my iPad.

I did however note the LED does not have a series R, this may draw more current than the port is rated for.
Use 180R or more.

Weedpharma

Hi Weedpharma

Tried that with a 220 R but no difference... I don't understand :angry:

Ive just built another project and sketch using the LM35 and it is fine... Nice bright LEDs.

The only thing I can think of is the DHT sensor might be faulty but it supplies the correct temp etc and the LED flashes after 21 but its so so so dim... Odd that the LED is only getting 1.4v

Del

Can you supply the code in a code box so we can see it without having to run the IDE.

Please put your code in its own window as seen in other posts. This can be done by placing     [code] and [/code]  around the code. This makes it easier for others to read.

Weedpharma

Thanks for your time Weedpharma, new here but getting the hang of it.

Hope this helps

Del

// V1.0 Test sketch for DHT11 humidity/temperature sensor
// Written by delJ @ digitalcarnage.co.uk (with help of course)
// If the sensor sends a temp higher than AlarmTrigger then flash the red LED on pin 9
// Once the temp is less than AlarmTrigger turn LED on pin 9 off.

#include "DHT.h"      //Include the Library in the compile

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

#define DHTTYPE DHT11      // DHT 11 
//#define DHTTYPE DHT22    // DHT 22  (AM2302) THIS IS A BETTER SENSOR. MAYBE LATER...
// Connect pin 1 (on the left +) of the sensor to +5V
// Connect pin 2 (in the middle OUT) of the sensor to whatever your DHTPIN is 
// Connect pin 3 (on the right-) of the sensor to GROUND

//LOAD UP THE LIBRARY FOR THE DHT11 

DHT dht(DHTPIN, DHTTYPE);

int AlarmTigger = 20;    //Trigger temp. Over this sets alarm
int AlarmOutPutPin = 9;    //Alarm device on pin 9
int sensorPin = 0; 

void setup() { 
  Serial.begin(9600);    //Open serial port to laptop
  Serial.println("So. Whats the Humidity and Temperature in here?"); //Print text
 
  dht.begin();    //Talk to sensor
}

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();    //sensor humidiity
  float t = dht.readTemperature();    //sensor temp

  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  
  if (isnan(t) || isnan(h)) { //ooops no number from sensor.
    Serial.println("   What's up? Cant' see the sensor :(");    //print the error
  } else {    //otherwise....
    
    Serial.print("Current Humidity: "); 
    Serial.print(h);
    Serial.print(" %\t");
    Serial.print("Current Temperature: "); 
    Serial.print(t);
    Serial.println(" *C");
  
  }
  {
    if(t > AlarmTigger) //however watch the temp rise!
    {
   digitalWrite(AlarmOutPutPin, HIGH); //Turn pin 9 LED on
   delay(200);
   digitalWrite(AlarmOutPutPin, LOW); //Turn pin 9 LED off
   delay(200); 

  }
  else    //otherwise....
  {
    
    digitalWrite(AlarmOutPutPin, LOW);
    delay(1000);     
  }
 }
}

A quick look at the code has the LED on for 200mS then off for 200mS. Without going right into the code suggests a 50 % on/off time may give an average of half the voltage.

Try changing the delay to see if the brightness changes,IE, on for 10 sec and measure the voltage when it is on you will probably find it is getting full brightness.

Your problem then would be the logic of the program rather than a hardware fault.

Weedpharma

Hi

yes I tried that too, ie on all the time not flashing. The time wouldn't make the difference anyway on the intensity

The voltage over the LED is 1.4v..

Back to the drawing board I feel. Might try another sensor or taking the current one off its board. Its one of these with a couple of resistors that might be sucking power away from the LED.

Thanks for your time though

D

  1. Add serial resistor 1k to LED.
  2. Set LED pin as output, add pinMode(X, OUTPUT); to setup after dht initialization.
    ( DHT11 needs 5V supply voltage for exact RH value, and >6secs delay between readings.)

Hi Krasimir...

Thanks for your help... I'm away from my kit for the next few days, as soon as I can I'll give your suggestions a go and see how it goes and I will of course let you know..

Many thanks

Del

Hi Krasimir...

Yep... That cracked it... Great...

I already had a resistor in the chain. The only thing that is new is the pinMode instruction which confuses me a little as the output for the LED before adding pinMode was 1.5v and it flashed as it was supposed to. Any ideas.

Many thanks to you though for helping me out.

Del