Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
robbrad authored Nov 20, 2017
1 parent 2c1f476 commit 525eebb
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions air_sensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ unsigned long sampletime_ms = 2000;//sampe 30s ;
unsigned long lowpulseoccupancy = 0;
float ratio = 0;
float concentration = 0;
String data = "";
//String data = "";

void setup() {
Serial.begin(9600);
Expand Down Expand Up @@ -138,7 +138,8 @@ void loop() {
{
ratio = lowpulseoccupancy / (sampletime_ms * 10.0); // Integer percentage 0=>100

d = 1.1 * pow(ratio, 3) - 3.8 * pow(ratio, 2) + 520 * ratio + 0.62; // using spec sheet curve
d = ((1.1*ratio - 3.8)*ratio + 520)*ratio + 0.62;
//d = 1.1 * pow(ratio, 3) - 3.8 * pow(ratio, 2) + 520 * ratio + 0.62; // using spec sheet curve
//Serial.print("concentration = ");

lowpulseoccupancy = 0;
Expand All @@ -150,7 +151,9 @@ void loop() {
int sensorValue = analogRead(A0);
double Rs = (1023.0 / sensorValue) - 1;

double ppm = pow(10.0, ((log10(Rs / R0) - 0.0827) / (-0.4807)));
//double ppm = pow(10.0, ((log10(Rs / R0) - 0.0827) / (-0.4807)));
double ppm = 2500.33 * pow(Rs, -2.0803);

//Serial.print("HCHO ppm = ");

//MultiChannel Gas
Expand All @@ -169,34 +172,34 @@ void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();

data = String("dust=") + d + "&rs=" + Rs + "&hcho=" + ppm + "&nh3=" + NH3 + "&co=" + CO + "&no2=" + NO2 + "&c3h8=" + C3H8 + "&c4h10=" + C4H10 + "&ch4=" + CH4 + "&h2=" + H2 + "&c2h5oh=" + C2H5OH + "&temp=" + t + "&hum=" + h + "&HATemp=" + HATemp2 + "&HAPres=" + HAPres2 + "&HAAlt=" + HAAlt2;
//data = String("dust=") + d + "&rs=" + Rs + "&hcho=" + ppm + "&nh3=" + NH3 + "&co=" + CO + "&no2=" + NO2 + "&c3h8=" + C3H8 + "&c4h10=" + C4H10 + "&ch4=" + CH4 + "&h2=" + H2 + "&c2h5oh=" + C2H5OH + "&temp=" + t + "&hum=" + h + "&HATemp=" + HATemp2 + "&HAPres=" + HAPres2 + "&HAAlt=" + HAAlt2;

//Serial.println(data);


if (client.connect(server, 80)) {
Serial.println(F("connected"));
//Serial.println(F("connected"));
client.println(F("POST /air_add.php HTTP/1.1"));
client.println(F("Host: 192.168.0.30"));
client.println(F("User-Agent: Arduino/1.0"));
client.println(F("Connection: close"));
client.println(F("Content-Type: application/x-www-form-urlencoded;"));
client.print(F("Content-Length: "));
client.println(data.length());
client.println(500);
client.println();
client.println(data);
client.println(String("dust=") + d + "&rs=" + Rs + "&hcho=" + ppm + "&nh3=" + NH3 + "&co=" + CO + "&no2=" + NO2 + "&c3h8=" + C3H8 + "&c4h10=" + C4H10 + "&ch4=" + CH4 + "&h2=" + H2 + "&c2h5oh=" + C2H5OH + "&temp=" + t + "&hum=" + h + "&HATemp=" + HATemp2 + "&HAPres=" + HAPres2 + "&HAAlt=" + HAAlt2);
}
else
{
Serial.println(F("could not connect"));
}

Serial.println(data);
// Serial.println(data);

if (client.connected()) {
client.stop();
}


delay(300000);
}
}

0 comments on commit 525eebb

Please sign in to comment.