unsigned int Get_ADCValue_MQ2(u8 times)//得到ADC采樣內部傳感器的值 取n次,然后平均
{
u32 val = 0;
u8 count;
for(count = 0; count < times; count++)
{
val += analogRead(MQ2_IO);//獲取模擬量數值
delay(5);
}
return val/times;
}
void MQ2_PPM_Calibration(float RS)// 傳感器校準函數
{
R0 = RS / pow(CAL_PPM / 613.9f, 1 / -2.074f);
}
float MQ2_GetPPM(void)// MQ2傳感器數據處理
{
float Vrl = 5.0f * Get_ADCValue_MQ2(10) / 1024.f;
Vrl = ( (float)( (int)( (Vrl+0.005)*100 ) ) )/100;
float RS = (5.0f - Vrl) / Vrl * RL;
if(millis() < 5000) // 獲取系統執行時間,10s前都進行校準
{
R0 = RS / pow(CAL_PPM / 613.9f, 1 / -2.074f);
}
float ppm = 613.9f * pow(RS/R0, -2.074f); //根據轉化公式
return ppm;
請問標紅代碼的公式和“POW”、“613.9f”、什么意思
|