首頁 >> 汽車報警系統,還是“孩子”那些事兒
汽車報警系統,還是“孩子”那些事兒
來源: 時間:2015-11-06
如果你收到這樣的短信,千萬不要感到莫名其妙,你要做的是趕緊回到你的車上,打開車門。
據不完全統計,每年平均有38個兒童在汽車中窒息而死,原因是被父母鎖在車內,里面二氧化碳濃度過高,兒童氧氣不夠呼吸困難,最后導致悲劇的發生。
#define RLOAD 10.0
/// Calibration resistance at atmospheric CO2 level
#define RZERO 1212.78
/// Parameters for calculating ppm of CO2 from sensor resistance
#define PARA 116.6020682
#define PARB 2.769034857
/// Parameters to model temperature and humidity dependence
#define CORA 0.00035
#define CORB 0.02718
#define CORC 1.39538
#define CORD 0.0018
/// Atmospheric CO2 level for calibration purposes
#define ATMOCO2 400
/// Calibration resistance at atmospheric CO2 level
#define MQ135PIN 0
int redPin = 12; // Red LED connected to digital pin 12
float airthreshold[3] =
{
400, 400, 800
};
void setup()
{
// start the LEDs
pinMode(redPin, OUTPUT); // sets the digital pin as output
//Set up the serial terminal
Serial.begin(9600);
}
void loop()
{
float rzero = getRZero();
float ppm = getPPM();
Serial.print(" CO2: ");
Serial.print(ppm);
Serial.println(" ppm ");
if(ppm > 600)
{
digitalWrite(redPin, HIGH); // sets the Red LED on
}
else
{
digitalWrite(redPin, LOW); // sets the Red LED on
}
Serial.print(" rzero: ");
Serial.println(rzero);
delay(1000);
}
////////////MQ Code///////////////
/**************************************************************************/
/*!
@file MQ135.cpp
@author G.Krocker (Mad Frog Labs)
@license GNU GPLv3
First version of an Arduino Library for the MQ135 gas sensor
TODO: Review the correction factor calculation. This currently relies on
the datasheet but the information there seems to be wrong.
@section HISTORY
v1.0 - First release
*/
/**************************************************************************/
/*!
@brief Get the correction factor to correct for temperature and humidity
@param[in] t The ambient air temperature
@param[in] h The relative humidity
@return The calculated correction factor
*/
/**************************************************************************/
float getCorrectionFactor(float t, float h) {
return CORA * t * t - CORB * t + CORC - (h-33.)*CORD;
}
/**************************************************************************/
/*!
@brief Get the resistance of the sensor, ie. the measurement value
@return The sensor resistance in kOhm
*/
/**************************************************************************/
float getResistance() {
int val = analogRead(MQ135PIN);
return ((1023./(float)val) * 5. - 1.)*RLOAD;
}
/**************************************************************************/
/*!
@brief Get the resistance of the sensor, ie. the measurement value corrected
for temp/hum
@param[in] t The ambient air temperature
@param[in] h The relative humidity
@return The corrected sensor resistance kOhm
*/
/**************************************************************************/
float getCorrectedResistance(float t, float h) {
return getResistance()/getCorrectionFactor(t, h);
}
/**************************************************************************/
/*!
@brief Get the ppm of CO2 sensed (assuming only CO2 in the air)
@return The ppm of CO2 in the air
*/
/**************************************************************************/
float getPPM() {
return PARA * pow((getResistance()/RZERO), -PARB);
}
/**************************************************************************/
/*!
@brief Get the ppm of CO2 sensed (assuming only CO2 in the air), corrected
for temp/hum
@param[in] t The ambient air temperature
@param[in] h The relative humidity
@return The ppm of CO2 in the air
*/
/**************************************************************************/
float getCorrectedPPM(float t, float h) {
return PARA * pow((getCorrectedResistance(t, h)/RZERO), -PARB);
}
/**************************************************************************/
/*!
@brief Get the resistance RZero of the sensor for calibration purposes
@return The sensor resistance RZero in kOhm
*/
/**************************************************************************/
float getRZero() {
return getResistance() * pow((ATMOCO2/PARA), (1./PARB));
}
/**************************************************************************/
/*!
@brief Get the corrected resistance RZero of the sensor for calibration
purposes
@param[in] t The ambient air temperature
@param[in] h The relative humidity
@return The corrected sensor resistance RZero in kOhm
*/
/**************************************************************************/
float getCorrectedRZero(float t, float h) {
return getCorrectedResistance(t, h) * pow((ATMOCO2/PARA), (1./PARB));
}
連接器:將DS18B20平坦的一面對向你自己,最左邊的是地,中間是信號引腳(引腳13),最右邊是+5或+3.3V,4.7k的電阻分別接+5V和信號引腳。
建議將SIM900使用單獨的電源上電,連接如下:
RXD與引腳7連接。
這個想法的目的是提醒你可能忘記了你在車里熟睡的嬰兒,畢竟剛為人父母的年輕人,生活了20多年的習慣忽然要改變,忽然要接受生活中多出一個需要去照顧得生命,是需要適應的,這個項目是不是很貼心呢?
推薦文章