DHT11 help

Hi guys and gals,
So i've built an arduino board using 3-4 sensors: DHT 11, Bmp 180, DCS04 (sound sensor), turbidity sensor and a bluetooth module. So everything is set up right, but when i get the temperature reading it always comes out to be 0 degree Celsius. Any advice on why this is and ways to fix it, will be highly appreciated. Thanks!

#include "Adafruit_BMP085.h" //Library to control the BMP085
#include <Wire.h> //Needed by BMP085 library
Adafruit_BMP085 bmp; //create a BMP085 object

#include <dht.h>

#define trigPin 10
#define echoPin 13
#define DHT11_PIN 7

dht DHT;

int AnsOne=0;

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600); //Initialize the serial interface at 9600bps
bmp.begin(); //Initialize the sensor

Serial.begin(9600); // Setup serial port for terminal
float E= 2.718281828;
float a= -4.786247207E+3;
float b= 1.685747079E+1;
float c= 1.006980128E-1;
float d= 1.379452564E-5;
float e= -1.593358617E-6;
float f= -1.212132607E-1;
float g= -5.306973488E-6;
float h= -3.748148644E-9;
float i= 8.269920197E+0;
float j= -5.037682211E-3;
float k= 1.122556021E-6;
float l= -1.385709017E-3;
float m= 6.226417911E-6;
float n= -2.248727942E-7;
float o= 9.282543659E-3;
float p= -6.799791461E-5;
float q= 2.180492636E-7;

Serial.begin(9600); //Baud rate: 9600
}

void loop() {

//Read and print out the temperature
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");
//Read and print out the pressure
Serial.print("Pressure = ");
Serial.print(bmp.readPressure());-
Serial.println(" Pa");
//Read and print out altitude
Serial.print("Altitude = ");
Serial.print(bmp.readAltitude(101862));
Serial.println(" Meters");
Serial.println();
delay(1000); //Wait 1000ms before next reading

float duration, distance;
float speed;
float velocity;

digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
speed = 331.4 + (0.606 * DHT.temperature) + (0.0124 * DHT.humidity);
distance = (duration / 2) * (speed / 10000);
velocity = ((speed / 2) ) / (1000 * 10);

if (distance >= 400 || distance <= 2){
Serial.print("Distance = ");
Serial.println("Out of range");
}
else {
Serial.print("Distance = ");
Serial.print(distance);
Serial.println(" cm");
Serial.print ("Velocity = ");
Serial.print(velocity);
Serial.println(" m");

const float T=Serial.print(bmp.readTemperature());
const float P= Serial.print(bmp.readPressure());
const float SV= Serial.print ("Velocity = ");
Serial.print( "=");

float salinity =
-1*((-4.786247207e+3)+(-1.685747079E+1)T + (1.006980128E-1)(TT)+1.379452564E-5(TTT)+(-1.593358617E-6)(TTTT)+ -1.212132607E-1P + -5.306973488E-6(PP)+ -3.748148644E-9(PPP)+ 8.269920197E+0SV + -5.037682211E-3(SVSV)+ 1.122556021E-6(SVSVSV) + -1.385709017E-3TP + 6.226417911E-6*(TT)P + -2.248727942E-7(TTT)P + 9.282543659E-3TSV + -6.799791461E-5*(TT)SV + 2.180492636E-7(TT*T)*SV);
Serial.print("salinity = ");
Serial.print(salinity);
Serial.println(" psu");

float conductivity= (-.02267243*(TTT) + 4.6636947*(TT) + 861.3027640T + 29035.1640851)/1000;
Serial.print("conductivity = ");
Serial.print(conductivity);
Serial.println(" uS/cm");

int sensorValue = analogRead(A0);// read the input on analog pin 0:
float voltage = sensorValue * (5.0 / 1024.0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
Serial.println(voltage); // print out the value you read:

delay(500);

delay(1000);
}
delay(1000);
}

Do some Serial.prints on varaiables to see where things go wrong.

.

i did it was the pressure sensor that changed it, but i've adjusted it numerous times and nothing happens

jack567azn:
i did it was the pressure sensor that changed it, but i've adjusted it numerous times and nothing happens

What does that mean?

If you suspect the BMP sensor of interfering with the DHT, have you tried to use only the DHT and BMP in a sketch?

  1. you setup your Serial 4 times, is there a reason for it?

Serial.begin(9600);

  1. which DHT class do you use?
    Where do you actual read the sensor?

  2. you declared a fair amount of floats that are not used.
    Better remove all what is not needed to have a minimal sketch for just one sensor. If that works, make a backup and continue from there.

  3. This is not legal C++
    const float T=Serial.print(bmp.readTemperature());
    const float P= Serial.print(bmp.readPressure());
    const float SV= Serial.print ("Velocity = ");
    Serial.print( "=");

should be

float T = bmp.readTemperature();
float P = bmp.readPressure() ;
float SV = velocity;

your turn :wink:

I've just done a quick test for you OP, with a DHT and BMP sensor together in one sketch: works perfectly.

Hi,
As already asked, where do you read the DHT sensor.

Did you write the code in stages.
First get the DHT sensor workingon its own, then when bugs ironed out.
Second get the BMP working on its own,then when bugs ironed out.
Third get the Soanar working on its own,then when bugs ironed out.
Fourth get the Salinity working on its own,then when bugs ironed out.
Fifth get the Turbidity working on its own,then when bugs ironed out.
Sixth get the Bluetooth working on its own,then when bugs ironed out.

Then combine them one at a time , each time only adding the next when the bugs are ironed out .

Tom... :slight_smile: