You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.2 KiB
75 lines
1.2 KiB
void htu21()
|
|
{
|
|
voltage = analogRead(35) / 4096.0 * 6.566 * (vref / 1000.0);
|
|
volt =voltage*100;
|
|
float temphtu = htu.readTemperature()*10;
|
|
float rel_hum = htu.readHumidity()*10;
|
|
Serial.println("sensor OK!");
|
|
Serial.println(temphtu);
|
|
Serial.println(rel_hum);
|
|
if( temphtu>=0)
|
|
{zntemp=1;
|
|
}
|
|
else
|
|
{zntemp=0;
|
|
}
|
|
|
|
|
|
temp=abs(temphtu);
|
|
|
|
if(zntemp==1)//+
|
|
{
|
|
if(znmax == 1)//+
|
|
{if(temp>tempmax)
|
|
{tempmax=temp;
|
|
znmax=zntemp;
|
|
tax =tHour*1000+tMin;}
|
|
}
|
|
else//-
|
|
{tempmax=temp;
|
|
znmax=zntemp;
|
|
tax =tHour*1000+tMin;
|
|
}
|
|
|
|
if(znmin == 1)//+
|
|
{if(temp<tempmin){
|
|
tempmin=temp;
|
|
znmin=zntemp;
|
|
tin =tHour*1000+tMin;}
|
|
}
|
|
else//-
|
|
{tempmin=tempmin;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(zntemp==0)//-
|
|
{
|
|
if(znmax == 1)//+
|
|
{tempmax=tempmax;
|
|
|
|
}
|
|
else//-
|
|
{if(temp<tempmax){tempmax=temp;
|
|
znmax=zntemp;
|
|
tax =tHour*1000+tMin;}
|
|
}
|
|
|
|
if(znmin == 1)//+
|
|
{tempmin=temp;
|
|
znmin=zntemp;
|
|
tin =tHour*1000+tMin;
|
|
}
|
|
else//-
|
|
{
|
|
if(temp>tempmin){tempmin=temp;
|
|
znmin=zntemp;
|
|
tin =tHour*1000+tMin;}
|
|
}
|
|
|
|
}
|
|
hum=rel_hum;
|
|
}
|
|
|