首页 >> 汽车报警系统,还是“孩子”那些事儿
汽车报警系统,还是“孩子”那些事儿
来源:  时间:2015-11-06
分享到:


如果你收到这样的短信,千万不要感到莫名其妙,你要做的是赶紧回到你的车上,打开车门。


据不完全统计,每年平均有38个儿童在汽车中窒息而死,原因是被父母锁在车内,里面二氧化碳浓度过高,儿童氧气不够呼吸困难,最后导致悲剧的发生。


这一款汽车警报系统被设计用来向忘记了车里还有孩子的父母发出警报。系统的基本原理是监测车内的CO2水平,用CO2水平来体现车内环境小编认为是非常有效的。该系统开启后,将会通过用户设置的N个间隔持续检测,如果二氧化碳的水平不断上升,甚至超过了设定的阀值,这表明可能有人被困在了车里,届时系统就会向车主发送警告短信,从而提醒他/她是不是忘记了车里的孩子或是宠物。短信内容还会包括车的位置和车内温度。
1
产品清单

1.Intel Edison开发板,arduino屏蔽板;
2.MQ135 气体传感器;
3.SIM900 模块;
4.DS18B20数字温度传感器;
5.1个4.7k 传感器,1个1k的;
6.测试用LED;
7.公母Duport接口。
2
软件,安装Edison IDE
在正式开始之前,你必须先将你的Edison连上,安装上IDE,跟着说明书来做。在这儿我就不多说了。
3
概览

做的不好的地方欢迎评论吐槽哦~第一次做
4
连接、校准、测试MQ135传感器


VCC接口接5V电源;
Gnd接地;
AO接板子上的A0;
这一步有点抓狂,你从CO2传感器上得到的值应该是在399附近;
将传感器与电路连起来,保持通电状态12-24小时,然后放到通风的地方,最好是放在温度在20-35摄氏度,读出检测到的数,读出的校准值作为浮动零点=气体传感器的示数,得到这个R零点,等待大约30-60分钟,直到数值趋于稳定。注意,这是个ADC测量,因此你可能不想花太多时间在读数和处理平均值上。一旦你设定了R零点,把它设定到MQ135里,再次注意,不同的传感器R零点不同。
代码
我在LED上设置当数值达到阀值时,RED(红色)点亮。
下面是代码:
/// The load resistance on the board
#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));
}
5
连接热传感器


连接器:将DS18B20平坦的一面对向你自己,最左边的是地,中间是信号引脚(引脚13),最右边是+5或+3.3V,4.7k的电阻分别接+5V和信号引脚。

6
Sim900模块


建议将SIM900使用单独的电源上电,连接如下:

+5V与VCC连接;
GND与电源的GND连接;
下一个GND与板上GND连接;
TXD与引脚8连接;

RXD与引脚7连接。


如果你的SIM900已正确连接到网络上,你应该看到它每3秒闪烁一次,如果闪得太快,这意味着它仍然在寻找网络,注意,它一开始是如何快速闪烁的,随后它的闪烁将会变慢。
7
可选:红灯测试
当你要发送短信时,你可以自主选择哪个灯和信号灯相连,我选择了1k的电阻。
将电阻的一根引脚和引脚12连接;
将LED长引脚(正极)和电阻的另一极相连;
将LED短引脚(负极)和GDN(地)相连。

8
代码

该代码可在CodeBender.cc找到。
9
最终结果


这个想法的目的是提醒你可能忘记了你在车里熟睡的婴儿,毕竟刚为人父母的年轻人,生活了20多年的习惯忽然要改变,忽然要接受生活中多出一个需要去照顾得生命,是需要适应的,这个项目是不是很贴心呢?