-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
332 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//I. Heng and R. Yap | ||
char line[80]; | ||
int small = 0; | ||
int large = 0; | ||
int i =0; | ||
|
||
void setup() { | ||
|
||
// set the data rate for the SoftwareSerial port | ||
Serial1.begin(9600); | ||
Serial2.begin(115200); | ||
|
||
//set up Arduino's Serial | ||
Serial.begin(9600); | ||
Serial.println("Ready"); | ||
} | ||
void loop() { | ||
|
||
// listen for new serial coming in: | ||
char someChar = Serial1.read(); | ||
|
||
if( someChar != -1){ | ||
//Serial.print(someChar); | ||
if (someChar == '\n') | ||
{ | ||
line[i++]=0; | ||
sscanf(line,"%d,%d",&small,&large); | ||
i=0; | ||
Serial.print(small); | ||
Serial.print(" : 0.5 Micron "); | ||
Serial.print(large); | ||
Serial.println(" : 2.5 Micron"); | ||
|
||
Serial2.print(small); | ||
Serial2.print(";CityTech56789;DC1700a;Small Particle;SP;0.5 Micron;Micron;0;1000;2000;3000;4000"); | ||
Serial2.print("\n"); | ||
|
||
Serial2.print(large); | ||
Serial2.print(";CityTech56789;DC1700b;Large Particle;LP;2.5 Micron;Micron;0;1000;2000;3000;4000"); | ||
Serial2.print("\n"); | ||
} | ||
else | ||
line[i++] = someChar; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
Each sensor reading should be written as one line to the serial output. Lines should end | ||
with '\n' and should have the following format: | ||
<Measurement value>;<Sensor package name>;<Sensor name>;<Type of measurement>;<Short type of measurement>;<Unit name>;<Unit symbol/abbreviation>;<T1>;<T2>;<T3>;<T4>;<T5> | ||
The Sensor name should be different for each sensor. | ||
T1..T5 are integer thresholds which guide how values should be displayed - | ||
- lower than T1 - extremely low / won't be displayed | ||
- between T1 and T2 - low / green | ||
- between T2 and T3 - medium / yellow | ||
- between T3 and T4 - high / orange | ||
- between T4 and T5 - very high / red | ||
- higher than T5 - extremely high / won't be displayed | ||
*/ | ||
|
||
#include <SoftwareSerial.h> //Header for software serial communication | ||
SoftwareSerial mySerial(2, 3); //Assign 2 as Rx and 3 as Tx | ||
|
||
float maxv, CO, NO2; | ||
int humi, kelv, cel, fah, circ = 5, heat = 6; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); //Serial communication for Arduino Serial Monitor | ||
mySerial.begin(115200); //Serial communcation for Aircasting Application | ||
pinMode(circ, OUTPUT); | ||
pinMode(heat, OUTPUT); | ||
} | ||
|
||
void GetTemp() | ||
{ | ||
float val2 = analogRead(A2); | ||
kelv = val2 * 0.48875855; | ||
cel = kelv - 273.15; | ||
fah = (kelv * 1.8) - 459.67; | ||
} | ||
|
||
void loop() | ||
{ | ||
//call up the calculation functions | ||
GetHumi(); | ||
GetTemp(); | ||
GetCO(); | ||
GetNO2(); | ||
|
||
//Display of humidity | ||
mySerial.print(humi); | ||
mySerial.print(";InsertSensorPackageName;HIH4030;Humidity;RH;percent;%;0;25;50;75;100"); | ||
mySerial.print("\n"); | ||
Serial.print("Humidity: "); | ||
Serial.print(humi); | ||
Serial.print("% "); | ||
|
||
//Display of CO gas sensor | ||
mySerial.print(CO); | ||
mySerial.print(";InsertSensorPackageName;TGS2442;CO Gas;CO;response indicator;RI;0;25;50;75;100"); | ||
mySerial.print("\n"); | ||
Serial.print("CO Gas: "); | ||
Serial.print(CO); | ||
Serial.print("% "); | ||
|
||
//Display of temperature in K, C, and F | ||
/* | ||
mySerial.print(kelv); | ||
mySerial.print(";InsertSensorPackageName;LM335A;Temperature;K;kelvin;K;255;270;283;297;310"); | ||
mySerial.print("\n"); | ||
mySerial.print(cel); | ||
mySerial.print(";InsertSensorPackageName;LM335A;Temperature;C;degrees Celsius;C;-20;-5;10;25;40"); | ||
mySerial.print("\n"); | ||
*/ | ||
mySerial.print(fah); | ||
mySerial.print(";InsertSensorPackageName;LM335A;Temperature;F;degrees Fahrenheit;F;0;30;60;90;120"); | ||
mySerial.print("\n"); | ||
|
||
Serial.print("Temperature: "); | ||
Serial.print(kelv); | ||
Serial.print("K "); | ||
Serial.print(cel); | ||
Serial.print("C "); | ||
Serial.print(fah); | ||
Serial.print("F "); | ||
|
||
mySerial.print(NO2); | ||
mySerial.print(";InsertSensorPackageName;MiCS-2710;N02 Gas;NO2;response indicator;RI;0;25;50;75;100"); | ||
mySerial.print("\n"); | ||
Serial.print("NO2 Gas: "); | ||
Serial.print(NO2); | ||
Serial.println("%"); | ||
} | ||
|
||
void GetCO() | ||
{ | ||
digitalWrite(circ, LOW); | ||
analogWrite(heat, 245); | ||
delay(14); | ||
analogWrite(heat, 0); | ||
delay(981); | ||
digitalWrite(circ, HIGH); | ||
delay(3); | ||
float val1 = analogRead(A1); | ||
CO = map(val1, 0 , 1023, 0, 100); | ||
} | ||
|
||
void GetHumi() | ||
{ | ||
float val0 = analogRead(A0); | ||
float maxv = (3.27-(0.006706*cel)); | ||
humi = ((((val0/1023)*5)-0.8)/maxv)*100; | ||
} | ||
|
||
void GetNO2() | ||
{ | ||
float val3 = analogRead(A3); | ||
NO2 = map(val3, 1023, 0, 0, 100); | ||
} | ||
|
||
float map(float x, float in_min, float in_max, float out_min, float out_max) | ||
{ | ||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//I. Heng and R. Yap | ||
#include <SoftwareSerial.h> | ||
unsigned long duration; | ||
unsigned long starttime; | ||
unsigned long sampletime_ms = 1000; | ||
unsigned long lowpulseoccupancy = 0; | ||
double ratio = 0; | ||
double concentration = 0; | ||
|
||
SoftwareSerial mySerial(2, 3); | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
mySerial.begin(115200); | ||
pinMode(8,INPUT); | ||
starttime = millis(); | ||
} | ||
|
||
void loop() { | ||
duration = pulseIn(8, LOW); | ||
lowpulseoccupancy = lowpulseoccupancy+duration; | ||
//Serial.print(starttime); | ||
//Serial.print(" "); | ||
//Serial.println(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)/100; // using spec sheet curve | ||
Serial.print(lowpulseoccupancy); | ||
Serial.print(","); | ||
Serial.print(ratio); | ||
Serial.print(","); | ||
Serial.println(concentration); | ||
mySerial.print(concentration); | ||
mySerial.print(";InsertSensorPackageName;PPD42NS;Particulate Matter;PM;hundred particles > 1 um per 0.01 cubic feet;hppcf;0;100;200;300;400"); | ||
mySerial.print("\n"); | ||
lowpulseoccupancy = 0; | ||
starttime = millis(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* | ||
Each sensor reading should be written as one line to the serial output. Lines should end | ||
with '\n' and should have the following format: | ||
<Measurement value>;<Sensor package name>;<Sensor name>;<Type of measurement>;<Short type of measurement>;<Unit name>;<Unit symbol/abbreviation>;<T1>;<T2>;<T3>;<T4>;<T5> | ||
The Sensor name should be different for each sensor. | ||
T1..T5 are integer thresholds which guide how values should be displayed - | ||
- lower than T1 - extremely low / won't be displayed | ||
- between T1 and T2 - low / green | ||
- between T2 and T3 - medium / yellow | ||
- between T3 and T4 - high / orange | ||
- between T4 and T5 - very high / red | ||
- higher than T5 - extremely high / won't be displayed | ||
*/ | ||
|
||
#include <SoftwareSerial.h> //Header for software serial communication | ||
SoftwareSerial mySerial(2, 3); //Assign 2 as Rx and 3 as Tx | ||
|
||
float maxv, CO, NO2; | ||
int humi, kelv, cel, fah, circ = 5, heat = 6; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); //Serial communication for Arduino Serial Monitor | ||
mySerial.begin(115200); //Serial communcation for Aircasting Application | ||
pinMode(circ, OUTPUT); | ||
pinMode(heat, OUTPUT); | ||
} | ||
|
||
void GetTemp() | ||
{ | ||
float val2 = analogRead(A2); | ||
val2 = (val2 * 5.0)/1023; | ||
val2 = (val2 - 0.5)*100; | ||
cel = val2; | ||
kelv = val2 + 273.15; | ||
fah = ((val2 * 9)/5.0) + 32; | ||
} | ||
|
||
void loop() | ||
{ | ||
//call up the calculation functions | ||
GetHumi(); | ||
GetTemp(); | ||
GetCO(); | ||
GetNO2(); | ||
|
||
//Display of humidity | ||
mySerial.print(humi); | ||
mySerial.print(";InsertSensorPackageName;HIH4030;Humidity;RH;percent;%;0;25;50;75;100"); | ||
mySerial.print("\n"); | ||
Serial.print("Humidity: "); | ||
Serial.print(humi); | ||
Serial.print("% "); | ||
|
||
//Display of CO gas sensor | ||
mySerial.print(CO); | ||
mySerial.print(";InsertSensorPackageName;TGS2442;CO Gas;CO;response indicator;RI;0;25;50;75;100"); | ||
mySerial.print("\n"); | ||
Serial.print("CO Gas: "); | ||
Serial.print(CO); | ||
Serial.print("% "); | ||
|
||
//Display of temperature in K, C, and F | ||
/* | ||
mySerial.print(kelv); | ||
mySerial.print(";InsertSensorPackageName;TMP36;Temperature;K;kelvin;K;273;300;400;500;600"); | ||
mySerial.print("\n"); | ||
mySerial.print(cel); | ||
mySerial.print(";InsertSensorPackageName;TMP36;Temperature;C;degrees Celsius;C;0;10;15;20;25"); | ||
mySerial.print("\n"); | ||
*/ | ||
mySerial.print(fah); | ||
mySerial.print(";InsertSensorPackageName;TMP36;Temperature;F;degrees Fahrenheit;F;0;30;60;90;120"); | ||
mySerial.print("\n"); | ||
|
||
Serial.print("Temperature: "); | ||
// Serial.print(kelv); | ||
// Serial.print("K "); | ||
// Serial.print(cel); | ||
// Serial.print("C "); | ||
Serial.print(fah); | ||
Serial.print("F "); | ||
|
||
mySerial.print(NO2); | ||
mySerial.print(";InsertSensorPackageName;MiCS-2710;N02 Gas;NO2;response indicator;RI;0;25;50;75;100"); | ||
mySerial.print("\n"); | ||
Serial.print("NO2 Gas: "); | ||
Serial.print(NO2); | ||
Serial.println("%"); | ||
} | ||
|
||
void GetCO() | ||
{ | ||
digitalWrite(circ, LOW); | ||
analogWrite(heat, 245); | ||
delay(14); | ||
analogWrite(heat, 0); | ||
delay(981); | ||
digitalWrite(circ, HIGH); | ||
delay(3); | ||
float val1 = analogRead(A1); | ||
CO = map(val1, 0 , 1023, 0, 100); | ||
} | ||
|
||
void GetHumi() | ||
{ | ||
float val0 = analogRead(A0); | ||
float maxv = (3.27-(0.006706*cel)); | ||
humi = ((((val0/1023)*5)-0.8)/maxv)*100; | ||
} | ||
|
||
void GetNO2() | ||
{ | ||
float val3 = analogRead(A3); | ||
NO2 = map(val3, 1023, 0, 0, 100); | ||
} | ||
|
||
float map(float x, float in_min, float in_max, float out_min, float out_max) | ||
{ | ||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.