本帖最后由 熊猫 于 2013-8-22 10:59 编辑
开场白:
物联网是一种应时代而生的产物,它集中了传统硬件稳定与互联网络高速的优点,满足当代人们对快速生活节奏的要求。
随着城市的发展,空气质量让人担忧。尤其是生在长在京都的我们,一次次的pm2.5爆表冲击着我们的心脏。时代变了,对健康的追求没变,生命的脆弱令我们更感其珍贵。
智慧社区气象站,实时掌控身边的空气状况,自己空气自己做主。
系统设计:
硬件框图:
测试结果:
序号 | 测试项目 | 测试内容与要求 | 测试结论 | 1 | 一般外观与要求 | A | 整套设备按规定程序及批准的图样和技术文件制造。 | 合格 | B | 全部电子线路、接插件、电线电缆应焊接牢靠,不得有脱焊、虚焊等现象。 | 合格 | C | 整机各部件安装应正确、牢固可靠,操作灵活,不应有迟滞、卡死、松脱、变形等缺陷。 | 合格 | D | 整机各部件均有防护设计,关键部件应有防潮、防辐射、防腐蚀设计。 | 合格 | E | 外观 | 合格 | 2 | 电源适应性 | A | 在180V-240V条件下能正常工件。 | 合格 | B | 交直流两用,能交直流自动浮充切换。 | 合格 | 3 | 抗干扰性 | 具有一定抗干扰和抗电磁辐射能力。 | 合格 | 4 | 气压 | 士0. 3hpa | 合格 | 5 | 气温 | 士0.2℃ | 合格 | 6 | 湿敏电容 | 士4%RH(< 80%RH时) | 合格 | 士8%RH(士80%RH时) | 合格 | 7 | 雨量 | 士0.4mm(≤10mm) | 合格 | 士4%(>10mm) | 合格 | 实物展示:
室外:
室内:
室内终端减少不必要模块降低成本,网线供网市电供能,更加稳定。
智能家居:
室内外监控设备共同组成智慧社区监控系统,根据差值为用户提供短信提示,用户可根据需求远程遥控家具开关。
数据曲线:
细颗粒物
气压
光照
还有温湿度降水等。因为曲线不好看就不挂了。
微信查询功能:
微博整点播报:
短信报警:
结束语:
智慧社区气象系统不仅仅是概念,我们做的是健康的态度。对暴露在严重空气污染下的社区生活说不,打造全新的智慧社区理念,健康的生活环境,为身在城市中的人们打造最后一片安居净土!
附录:
室外社区气象站
[pre lang="arduino" line="1" file="outside"]
#include <SPI.h>
#include <Wire.h>
#include <math.h>
#include <MsTimer2.h>
#include <Adafruit_BMP085.h>
#include <dht.h>
#define DHT11_PIN 6//put the sensor in the digital pin 4
Adafruit_BMP085 bmp;
int BH1750address = 0x23;//BH1750 I2C地址
byte buff[2];
int val;
int va;
int flag = 0;//定时中断标志
int hm=1;
#define POST_INTERVAL (10*1000)
int pin = 7;
unsigned long duration;
unsigned long starttime;
unsigned long sampletime_ms = 30000;
unsigned long lowpulseoccupancy = 0;
float ratio = 0;
float concentration = 0;
dht DHT;
void timer()//定时中断函数
{
flag = 1;
}
void setup()
{
// start serial port:
Serial.begin(9600);
Wire.begin();
MsTimer2::set(2000, timer); //定时器设置,每2秒触发一次timer函数操作
MsTimer2::start();
bmp.begin(); //初始化气压计
pinMode(2, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
starttime = millis();
}
void loop() {
// read the analog sensor:
//int sensorReading = analogRead(A0);
// if there's incoming data from the net connection.
// send it out the serial port. This is for debugging
// purposes only:
int chk = DHT.read22(DHT11_PIN);
int a=1;
while(a)
{
duration = pulseIn(pin, LOW);
lowpulseoccupancy = lowpulseoccupancy+duration;
if ((millis()-starttime) > sampletime_ms)
{
ratio = lowpulseoccupancy/(sampletime_ms*10.0); // Integer percentage 0=>100
concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve
//Serial.print(lowpulseoccupancy);
lowpulseoccupancy = 0;
starttime = millis();
a=0;
}
}
float temp = bmp.readTemperature(); //读取温度数据 (BMP085)
long pa = bmp.readPressure(); //读取气压数据 (BMP085)
float hpa = pa /100.0 ; //将Pa换算成hPa
val=digitalRead(2);
va=analogRead(0);
int lux=BH1750();
int con=concentration;
float h=DHT.humidity;
float tem=DHT.temperature;
int bmp=hpa;
String tempstring3="@key=37435×××××××××××21834d4d";
String tempstring1=")";
if(hm==1)
{
Serial.println(tempstring3);
hm=0;
delay(10000);
}
Serial.print("@up(01,06,");
Serial.print("bmp=");
Serial.print(bmp);
// Serial.print(",bmpt=");
// Serial.print(temp);
//Serial.print(",ra=");
// Serial.print(ratio);
Serial.print(",yudi=");
Serial.print(va);
Serial.print(",yd=");
Serial.print(val);
Serial.print(",lux=");
Serial.print(lux);
Serial.print(",t11=");
Serial.print(h);
Serial.print(",temp=");
Serial.print(tem);
// Serial.print(",con=");
// Serial.print(con);
Serial.print(")");
Serial.println("");
// delay(12000); min transtime
delay(55000);
/* Serial.print("@up(01,04,");
Serial.print("bmp=");
Serial.print("1000");
Serial.print(",yudi=");
Serial.print("1024");
Serial.print(",yd=");
Serial.print("1");
Serial.print(",lux=");
Serial.print("13.55");
Serial.print(")");
Serial.println();
delay (30000);
Serial.print("@up(01,04");
Serial.print(",t11=");
Serial.print("30");
Serial.print(",temp=");
Serial.print("29");
Serial.print(",con=");
Serial.print("1000");
Serial.print(",ra=");
Serial.print("2.00");
Serial.print(")");
Serial.println();
delay (5000);
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay (55000);
*/
/*if (lwc) {
// Serial.print("*** start data collection ");
lwc->append("bmpt", temp);
lwc->append("bmp", hpa);
lwc->append("yudi", va);
lwc->append("yd", val);
lwc->append("lux", BH1750());
lwc->append("011", DHT.humidity);
lwc->append("temp", DHT.temperature);
lwc->append("con", concentration);
lwc->append("ra", ratio);
Serial.print("*** start either net send ");
lwc->send();
Serial.print("*** stop either net send ");
delay(POST_INTERVAL);
}*/
}
double BH1750() //BH1750设备操作
{
int i=0;
double val=0;
//开始I2C读写操作
Wire.beginTransmission(BH1750address);
Wire.write(0x10);//1lx reolution 120ms//发送命令
Wire.endTransmission();
delay(200);
//读取数据
Wire.beginTransmission(BH1750address);
Wire.requestFrom(BH1750address, 2);
while(Wire.available()) //
{
buff = Wire.read(); // receive one byte
i++;
}
Wire.endTransmission();
if(2==i)
{
val=((buff[0]<<8)|buff[1])/1.2;
}
return val;
}[/code]
室内终端
[pre lang="arduino" line="1" file="inside"]
#include <dht.h>
#include <MsTimer2.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>
int pin = 7;
unsigned long duration;
unsigned long starttime;
unsigned long sampletime_ms = 30000;
unsigned long lowpulseoccupancy = 0;
float ratio = 0;
float concentration = 0;
dht DHT;
#define DHT11_PIN 6//put the sensor in the digital pin 4
#include <LeweiClient.h>
#include <SPI.h>
#include <Ethernet.h>
#define POST_INTERVAL (10*1000)
Adafruit_BMP085 bmp;
int BH1750address = 0x23;//BH1750 I2C地址
byte buff[2];
LeWeiClient *lwc;
const unsigned long postingInterval = 10*1000;
#define LW_USERKEY "374358e×××××××××××××34d4d"
#define LW_GATEWAY "02"
int flag = 0;//定时中断标志
void timer()//定时中断函数
{
flag = 1;
}
void setup()
{
Serial.begin(9600);
pinMode(pin,INPUT);
starttime = millis();
lwc = new LeWeiClient(LW_USERKEY, LW_GATEWAY);
Wire.begin();
MsTimer2::set(2000, timer); //定时器设置,每2秒触发一次timer函数操作
MsTimer2::start();
bmp.begin(); //初始化气压计
pinMode(6, INPUT);
}
void loop()
{
int chk = DHT.read22(DHT11_PIN);
int a=1;
while(a)
{
duration = pulseIn(pin, LOW);
lowpulseoccupancy = lowpulseoccupancy+duration;
if ((millis()-starttime) > sampletime_ms)
{
ratio = lowpulseoccupancy/(sampletime_ms*10.0); // Integer percentage 0=>100
concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve
//Serial.print(lowpulseoccupancy);
lowpulseoccupancy = 0;
starttime = millis();
a=0;
}
}
float temp = bmp.readTemperature(); //读取温度数据 (BMP085)
long pa = bmp.readPressure(); //读取气压数据 (BMP085)
float hpa = pa /100.0 ; //将Pa换算成hPa
if (lwc) {
// Serial.print("*** start data collection ");
lwc->append("temp", temp);
lwc->append("bmp", hpa);
lwc->append("T1", DHT.humidity);
lwc->append("T2", DHT.temperature);
lwc->append("DSM", concentration);
lwc->append("ds", ratio);
Serial.print("*** start either net send ");
lwc->send();
Serial.print("*** stop either net send ");
delay(POST_INTERVAL);
}
} [/code]
家具控制:开窗+开空调模型
[pre lang="arduino" line="1" file="room"]
#include <SPI.h>
#include <Ethernet.h>
#include <LeweiTcpClient.h>
#include <EEPROM.h>
#define LW_USERKEY "37435×××××××××××××4d4d"
#define LW_GATEWAY "03"
#define LED_PIN 3//plug led in the d3,gnd->gnd
#define kt_PIN 5
int Pin0 = 8;
int Pin1 = 9;
int Pin2 = 6;
int Pin3 = 7;
int _step = 0;
int a=0,m=0,l=1,x=0,y=0,h;
//byte mac[] = {0x74,0x69,0x69,0x2D,0x30,0x31};
//IPAddress ip(192,168,1, 15);
//IPAddress mydns(8,8,8,8);
//IPAddress gw(192,168,1,1);
//IPAddress subnet(255,255,255,0);
LeweiTcpClient *client;
void setup()
{
Serial.begin(9600);
//you can use 3 ways to init your network
//1.simplest
pinMode(Pin0, OUTPUT);
pinMode(Pin1, OUTPUT);
pinMode(Pin2, OUTPUT);
pinMode(Pin3, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(13, INPUT);
client = new LeweiTcpClient(LW_USERKEY, LW_GATEWAY);
//2.full setting for your network
//client = new LeweiTcpClient(LW_USERKEY, LW_GATEWAY,mac,ip,mydns,gw,subnet);
//test1 is the function you write below to handle your program
//"testFunction" is the function name you set on website:http://www.lewei50.com/
//on "controll command manager" menu
//we test transfer 1-5 para from website(you defined on it) to your arduino
//enjoy it
UserFunction uf1(functionIWrote,"functionNameDefinedOnWeb");
client->addUserFunction(uf1);
UserFunction uf2 (ledOn,"turnLedOn");
client->addUserFunction(uf2);
UserFunction uf3 (ledOff,"turnLedOff");
client->addUserFunction(uf3);
UserFunction uf4 (ktOn,"turnktOn");
client->addUserFunction(uf4);
UserFunction uf5 (ktOff,"turnktOff");
client->addUserFunction(uf5);
/*
enable easySetupMode will open the port 80 of this board,
you can setup your apikey and gateway number via http://your_arduino_ip/
the key and number will be burned into board's eeprom
after setting you need to restart your arduino.
after reboot,you can comment this line for fasten your board.
this library will will use apikey and gateway number in eeprom FIRST,if it exsit.
you can send empty value from the browser to wipe the data in eeprom.
*/
//client->easySetupMode(true);
pinMode(LED_PIN, OUTPUT);
}
void loop()
{
client->keepOnline();
switch(_step){
case 0:
digitalWrite(Pin0, LOW);
digitalWrite(Pin1, HIGH);
digitalWrite(Pin2, HIGH);
digitalWrite(Pin3, HIGH);
break;
case 1:
digitalWrite(Pin0, LOW);
digitalWrite(Pin1, LOW);
digitalWrite(Pin2, HIGH);
digitalWrite(Pin3, HIGH);
break;
case 2:
digitalWrite(Pin0, HIGH);
digitalWrite(Pin1, LOW);
digitalWrite(Pin2, HIGH);
digitalWrite(Pin3, HIGH);
break;
case 3:
digitalWrite(Pin0, HIGH);
digitalWrite(Pin1, LOW);
digitalWrite(Pin2, LOW);
digitalWrite(Pin3, HIGH);
break;
case 4:
digitalWrite(Pin0, HIGH);
digitalWrite(Pin1, HIGH);
digitalWrite(Pin2, LOW);
digitalWrite(Pin3, HIGH);
break;
case 5:
digitalWrite(Pin0, HIGH);
digitalWrite(Pin1, HIGH);
digitalWrite(Pin2, LOW);
digitalWrite(Pin3, LOW);
break;
case 6:
digitalWrite(Pin0, HIGH);
digitalWrite(Pin1, HIGH);
digitalWrite(Pin2, HIGH);
digitalWrite(Pin3, LOW);
break;
case 7:
digitalWrite(Pin0, LOW);
digitalWrite(Pin1, HIGH);
digitalWrite(Pin2, HIGH);
digitalWrite(Pin3, LOW);
break;
default:
digitalWrite(Pin0, LOW);
digitalWrite(Pin1, LOW);
digitalWrite(Pin2, LOW);
digitalWrite(Pin3, LOW);
break;
}
if(l==LOW)
{
y=0;
_step++;
if(_step>7){
if(x<65)
{
_step=0;
x++;
}
else
{
}
}
}
else if(m==HIGH)
{
x=0;
_step--;
if(_step<1){
if(y<65)
{
_step=7;
y++;
}
else
{
}
}
}
delay(10);
}
//function functionIWrote use 1 parameter,on the website,it point to "p1"
void functionIWrote(char * p1)
{
client->setRevCtrlMsg("true","message to server");
// client->sendSensorValue("tcp1",pi);
Serial.println(p1);
}
//function without parameter
void ledOn()
{
client->setRevCtrlMsg("true","on");
digitalWrite(LED_PIN,LOW);
l=LOW;
m=LOW;
}
void ledOff()
{
client->setRevCtrlMsg("true","off");
digitalWrite(LED_PIN,HIGH);
m=HIGH;
l=HIGH;
}
void ktOn()
{
client->setRevCtrlMsg("true","kton");
digitalWrite(kt_PIN,HIGH);
digitalWrite(4,HIGH);
}
void ktOff()
{
client->setRevCtrlMsg("true","ktoff");
digitalWrite(kt_PIN,LOW);
digitalWrite(4,LOW);
}[/code] |