السلام عليكم ورحمه الله
بعد عدد كبير ووقت كثير من التجارب العمليه وضبط اكواد برمجيه ... توصلت الي هذه النتيجه ..
والحمد لله نجحت في الحصول علي قرأه حراره ورطوبه مظبوطه بنسبه 100% ( + ) ( - ) 1% توجد نسبه خطأ 1% في القرأه الحقيقيه ...
احب ان اشكر اخي الفاضل مهندس "" محمد إلياس "" واخي الفاضل مهندس "" ماجد عباس " علي كل المعلومات القيمه ...
لكي يخرج هذا المشروع الي النور ...
بارك الله فيكم جميعااا وكل عام وانتم بخير
كود المشروع للفائده ..
كود:
//PIC16F877A DHT11 digital humidity and
// temperature sensor MikroC code
//Written by: ABDALLA HYGSZY //
//Crystal used : 12MHz
//Use at your own risk
// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections
unsigned char Check, T_byte1, T_byte2,
RH_byte1, RH_byte2, Ch ;
unsigned Temp, RH, Sum ;
void StartSignal(){
TRISD.F0 = 0; //Configure RD0 as output
PORTD.F0 = 0; //RD0 sends 0 to the sensor
delay_ms(18);
PORTD.F0 = 1; //RD0 sends 1 to the sensor
delay_us(30);
TRISD.F0 = 1; //Configure RD0 as input
}
//////////////////////////////
void CheckResponse(){
Check = 0;
delay_us(40);
if (PORTD.F0 == 0){
delay_us(80);
if (PORTD.F0 == 1) Check = 1; delay_us(40);}
}
//////////////////////////////
char ReadData(){
char i, j;
for(j = 0; j < 8; j++){
while(!PORTD.F0); //Wait until PORTD.F0 goes HIGH
delay_us(30);
if(PORTD.F0 == 0)
i&= ~(1<<(7 - j)); //Clear bit (7-b)
else {i|= (1 << (7 - j)); //Set bit (7-b)
while(PORTD.F0);} //Wait until PORTD.F0 goes LOW
}
return i;
}
//////////////////////////////
void main() {
TRISD.F1 = 0;
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF); // cursor off
Lcd_Cmd(_LCD_CLEAR); // clear LCD
while(1){
StartSignal();
CheckResponse();
if(Check == 1){
RH_byte1 = ReadData();
RH_byte2 = ReadData();
T_byte1 = ReadData();
T_byte2 = ReadData();
Sum = ReadData();
if(Sum == ((RH_byte1+RH_byte2+T_byte1+T_byte2) & 0XFF)){
Lcd_Cmd(_LCD_CLEAR);
Temp = T_byte1;
RH = RH_byte1;
Lcd_Out(1, 6, "Temp: C");
Lcd_Out(2, 2, "Humidity: %");
LCD_Chr(1, 12, 48 + ((Temp / 10) % 10));
LCD_Chr(1, 13, 48 + (Temp % 10));
LCD_Chr(2, 12, 48 + ((RH / 10) % 10));
LCD_Chr(2, 13, 48 + (RH % 10));
}
else{ Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF); // cursor off
Lcd_Cmd(_LCD_CLEAR); // clear LCD
Lcd_Out(1, 1, "Check sum error");}
}
else {
//Lcd_Out(1, 3, "No response");
// Lcd_Out(2, 1, "from the sensor");
}
delay_ms(1000);
}
}
صوره المحكاه
.....................