BLYNK TEST

Dependencies:   mbed Blynk

Revision:
3:4cd9171ba989
Parent:
2:6cd3b0947188
--- a/sensor.h	Wed Jun 15 03:08:40 2016 +0000
+++ b/sensor.h	Thu Jun 16 08:08:30 2016 +0000
@@ -1,25 +1,28 @@
-//#include <SoftwareSerial.h>
 #include "MicroduinoPinNames.h"
+#include "Config.h"
 #include "AM2321.h"
 
 extern Serial pc;
 #define INTERVAL_pm25    200
 
 //SoftwareSerial pmSerial(4,5);   //PM2.5传感器通讯软串口
+#ifdef OPEN_PM25
 Serial pmSerial(D5, D4); //tx,rx
+#endif
 AnalogIn gLight(A0);
 AnalogIn gCH4(A2);
 AM2321 am2321;
 
 float sensor_tem,sensor_hum,sensor_light,Sensor_etoh;
 
-float sensorPM25;
+float sensorPM25 = 6.6;
 
 long map(long x, long in_min, long in_max, long out_min, long out_max)
 {
     return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
 }
 
+#ifdef OPEN_PM25
 void PM25_init(void)
 {
     //pc.printf("Enter PM25_init\r\n");
@@ -71,12 +74,13 @@
     sensorPM25 = dustDensity;
     //pc.printf("sensorPM25 = %f\r\n", sensorPM25);
 }
+#endif
 
 // 读取光照传感器
 void updateLight()
 {
     //sensor_light = map(analogRead(A0), 0, 1023, 0, 255);
-    float lvf = gLight;
+    //float lvf = gLight;
     uint16_t lt = gLight.read_u16();
     //pc.printf("light = %d, lvf = %f\r\n", lt, lvf);
     sensor_light = map(lt, 0, 65535, 0, 255);// 这里和Arduino不一样,不知道为什么
@@ -85,6 +89,7 @@
 // 读取甲醛传感器
 void updateCH4()
 {
+    sensorPM25 += 1.0;
     //Sensor_etoh = map(analogRead(A2), 0, 1023, 0, 30);
     uint16_t ch4 = gCH4.read_u16();
     Sensor_etoh = map(ch4, 0, 65535, 0, 30);