Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

DHT11 temp/humidity sensor with PIC16f690 in assembly problem

Status
Not open for further replies.
DHT11-wiring-with-arduino.gif

same as this circuit.
 

I will see if there is any mistake in Bhatt's code. I will look at the timing diagram of the sensor and try to find the mistake.

Is the below thing satisfied.

DHT11’s power supply is 3-5.5V DC. When power is supplied to the sensor, do not send any instruction to the sensor in within one second in order to pass the unstable status. One capacitor valued 100nF can be added between VDD and GND for power filtering.

Try to add a 2 sec delay before while(1) loop. See if that solves the problem.
 
Last edited:

Replace the ReadByte() code with this. See if this reads the 2nd byte of the Sensor.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
unsigned short ReadByte(){ 
 
unsigned short num = 0, t; 
DataDir = 1; 
 
for (i=0; i<8; i++){ 
 
while(!Data); 
Delay_us(40); 
if(Data) num |= 1<<(7-i); 
while(Data); 
} 
return num; 
}

 

Maybe there is a timing issue in the read operation. I will check the code again.

Zip and post your project files. Are you sure that 2nd bytes are transferring because if 2nd bytes are transferring then the bytes can't be 0 because cheksum is passing.
 
Last edited:

the main calculation is here:

Code:
RH_Byte1 = ReadByte();
     RH_Byte2 = ReadByte();
     T_Byte1 = ReadByte();
     T_Byte2 = ReadByte();
     CheckSum = ReadByte();
     // Check for error in Data reception
     if (CheckSum == ((RH_Byte1 + RH_Byte2 + T_Byte1 + T_Byte2) & 0xFF))
     {
         value = (float) (T_Byte1*100.0)+T_Byte2;
         //value = (value*1.80)+32.00; // Celcious To Farenhite convershion
         value = value;

         ch = (value / 1000) % 10;
         Lcd_Chr(1,8,48+ch);
         ch = (value / 100) % 10;
         Lcd_Chr_Cp(48+ch);
         Lcd_Chr_CP('.');
         ch = (value/ 10)% 10;
         Lcd_Chr_CP(48+ch);
         Lcd_Chr_Cp(223);
         Lcd_Chr_CP('C');

        Lcd_Out(1,1,"TEMP = ");
        message2[7] = RH_Byte1/10 + 48;
        message2[8] = RH_Byte1%10 + 48;
        message2[10] = RH_Byte2 + 48;

        //Lcd_Cmd(_Lcd_Clear);
        Lcd_Out(2, 1, message2);

     }

I checked it, its sending all 40bit data. But RH_Byte2 & T_Byte2 are always read as 0.

Still now, I can't find any error in program.
 

@Mithun_K_Das , I was also doing a project PIC16F877A with 8MHz external X-Ta and temp sensor is DS18B20. In simulation it only shows the temp like 31.0,32.0,33.0 . but in real (breadboard) it shows fractional value like 31.4,32.6 ect. did you try in real hardware?
 

@Mithun_K_Das , I was also doing a project PIC16F877A with 8MHz external X-Ta and temp sensor is DS18B20. In simulation it only shows the temp like 31.0,32.0,33.0 . but in real (breadboard) it shows fractional value like 31.4,32.6 ect. did you try in real hardware?




Nirob, I need to use DHT11 because of Humidity sensor. And if I can do both with one sensor, cost cab be reduced. This is why I'm trying to get the data from DHT11. Because I've already made thermal controller before so nice and effective:
DSCN0043.JPG

- - - Updated - - -

@Mithun_K_Das , I was also doing a project PIC16F877A with 8MHz external X-Ta and temp sensor is DS18B20. In simulation it only shows the temp like 31.0,32.0,33.0 . but in real (breadboard) it shows fractional value like 31.4,32.6 ect. did you try in real hardware?




Nirob, I need to use DHT11 because of Humidity sensor. And if I can do both with one sensor, cost cab be reduced. This is why I'm trying to get the data from DHT11. Because I've already made thermal controller before so nice and effective:
DSCN0043.JPG
 

Dear Mithun,

Please let me know that I want to interface DHT11 sensor with ATmega8.

So, how to understand its communication system.

But I am works on C-language.
 
Last edited:

This post is quite old, but for the sake of completness, I post something I read in the net:

"For DHT11 sensor, the decimal bytes of temperature and humidity measurements are always zero. Therefore, the first and third bytes of received data actually give the numeric values of the measured relative humidity (%) and temperature (°C). The last byte is the checksum byte which is used to make sure that the data transfer has happened without any error. If all the five bytes are transferred successfully then the checksum byte must be equal to the last 8 bits of the sum of the first four bytes".

Just for the case someone else is looking for this information now.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top