-
Notifications
You must be signed in to change notification settings - Fork 1
/
MultichannelGasSensor.ino
81 lines (67 loc) · 2.22 KB
/
MultichannelGasSensor.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
This is a demo to test gas library
This code is running on Xadow-mainboard, and the I2C slave is Xadow-gas
There is a ATmega168PA on Xadow-gas, it get sensors output and feed back to master.
the data is raw ADC value, algorithm should be realized on master.
please feel free to write email to me if there is any question
Jacky Zhang, Embedded Software Engineer
17,mar,2015
*/
#include <Wire.h>
#include "MutichannelGasSensor.h"
void setup()
{
Serial.begin(115200); // start serial for output
Serial.println("power on!");
gas.begin(0x04);//the default I2C address of the slave is 0x04
gas.powerOn();
Serial.print("Firmware Version = ");
Serial.println(gas.getVersion());
}
void loop()
{
float c;
c = gas.measure_NH3();
Serial.print("The concentration of NH3 is ");
if(c>=0) Serial.print(c);
else Serial.print("invalid");
Serial.println(" ppm");
c = gas.measure_CO();
Serial.print("The concentration of CO is ");
if(c>=0) Serial.print(c);
else Serial.print("invalid");
Serial.println(" ppm");
c = gas.measure_NO2();
Serial.print("The concentration of NO2 is ");
if(c>=0) Serial.print(c);
else Serial.print("invalid");
Serial.println(" ppm");
c = gas.measure_C3H8();
Serial.print("The concentration of C3H8 is ");
if(c>=0) Serial.print(c);
else Serial.print("invalid");
Serial.println(" ppm");
c = gas.measure_C4H10();
Serial.print("The concentration of C4H10 is ");
if(c>=0) Serial.print(c);
else Serial.print("invalid");
Serial.println(" ppm");
c = gas.measure_CH4();
Serial.print("The concentration of CH4 is ");
if(c>=0) Serial.print(c);
else Serial.print("invalid");
Serial.println(" ppm");
c = gas.measure_H2();
Serial.print("The concentration of H2 is ");
if(c>=0) Serial.print(c);
else Serial.print("invalid");
Serial.println(" ppm");
c = gas.measure_C2H5OH();
Serial.print("The concentration of C2H5OH is ");
if(c>=0) Serial.print(c);
else Serial.print("invalid");
Serial.println(" ppm");
delay(1000);
Serial.println("...");
}