|
|
@ -90,23 +90,33 @@ void ICACHE_FLASH_ATTR sendValues() { |
|
|
|
float p10, p2_5; |
|
|
|
int sds_error = sds.read(&p2_5, &p10); |
|
|
|
if(!sds_error) { |
|
|
|
Serial.println("SDS011 updated."); |
|
|
|
// Serial.println("SDS011 updated.");
|
|
|
|
} else { |
|
|
|
Serial.println("SDS011 no new values."); |
|
|
|
// Serial.println("SDS011 no new values.");
|
|
|
|
} |
|
|
|
|
|
|
|
// sds.sleep();
|
|
|
|
|
|
|
|
unsigned long cpm = 0; |
|
|
|
float radiationValue = -1; |
|
|
|
if (millis() - geiger_previousMillis > logging_period_ms) { |
|
|
|
cpm = geiger_counts * 60000 / (millis() - geiger_previousMillis); |
|
|
|
geiger_previousMillis = millis(); |
|
|
|
geiger_counts = 0; |
|
|
|
Serial.println(cpm); |
|
|
|
radiationValue = cpm * CONV_FACTOR; |
|
|
|
// Serial.println(cpm);
|
|
|
|
} else { |
|
|
|
Serial.println("Geiger Counter: no new value"); |
|
|
|
// Serial.println("Geiger Counter: no new value");
|
|
|
|
} |
|
|
|
|
|
|
|
Serial.printf("Temperature : %6.2f°C (DHT22)\n", temperature); |
|
|
|
Serial.printf("Humidity : %6.2f% (DHT22)\n", humidity); |
|
|
|
Serial.printf("Temperature : %6.2f°C (BMP180)\n", temp2); |
|
|
|
Serial.printf("Pressure : %6.2fhPa (BMP180)\n", pressure); |
|
|
|
if (!sds_error) Serial.printf("Particles 10 : %6.2fµg/m³ (SDS011)\n", p10); |
|
|
|
if (!sds_error) Serial.printf("Particles 2.5: %6.2fµg/m³ (SDS011)\n", p2_5); |
|
|
|
if (cpm > 0) Serial.printf("Radiation : %6.2fµSv/h (J305)\n", radiationValue); |
|
|
|
|
|
|
|
DynamicJsonBuffer jsonBuffer; |
|
|
|
JsonArray& array = jsonBuffer.createArray(); |
|
|
|
|
|
|
@ -134,7 +144,6 @@ void ICACHE_FLASH_ATTR sendValues() { |
|
|
|
} |
|
|
|
|
|
|
|
if (cpm > 0) { |
|
|
|
float radiationValue = cpm * CONV_FACTOR; |
|
|
|
JsonObject& cpmObject = array.createNestedObject(); |
|
|
|
cpmObject["sensor"] = SENSOR6_ID; |
|
|
|
cpmObject["value"] = radiationValue; |
|
|
@ -152,7 +161,6 @@ void ICACHE_FLASH_ATTR sendValues() { |
|
|
|
char buffer[500]; |
|
|
|
array.printTo(buffer, sizeof(buffer)); |
|
|
|
|
|
|
|
|
|
|
|
HTTPClient httpclient; |
|
|
|
char url[100]; |
|
|
|
sprintf(url, "http://%s/boxes/%s/data", server, SENSEBOX_ID); |
|
|
@ -165,6 +173,7 @@ void ICACHE_FLASH_ATTR sendValues() { |
|
|
|
if (httpCode > 0) { |
|
|
|
if (httpCode == HTTP_CODE_CREATED) { |
|
|
|
httpclient.writeToStream(&Serial); |
|
|
|
Serial.println(); |
|
|
|
} else { |
|
|
|
Serial.printf("[HTTP] POST... failed, error: %s\n", httpclient.errorToString(httpCode).c_str()); |
|
|
|
} |
|
|
|