first commit

This commit is contained in:
2021-05-11 20:43:42 +03:00
commit 9f3ffaba30
381 changed files with 69596 additions and 0 deletions

52
src/sht31.h Normal file
View File

@@ -0,0 +1,52 @@
#include <Adafruit_SHT31.h>
Adafruit_SHT31 sht31 = Adafruit_SHT31();
void setup_sht() {
if (! sht31.begin(0x44)) { // Set to 0x45 for alternate i2c addr
Serial.println("Couldn't find SHT31");
}
sht31.heater(1);
Serial.print("Heater Enabled State: ");
if (sht31.isHeaterEnabled())
Serial.println("ENABLED");
else
Serial.println("DISABLED");
}
void loop_sht(JsonObject &root) {
JsonObject sht = root.createNestedObject("sht31");
float t = sht31.readTemperature();
float h = sht31.readHumidity();
sht["temperature"] = t;
sht["humidity"] = h;
/*
if (! isnan(t)) { // check if 'is not a number'
Serial.print("Temp *C = "); Serial.print(t); Serial.print("\t\t");
} else {
Serial.println("Failed to read temperature");
}
if (! isnan(h)) { // check if 'is not a number'
Serial.print("Hum. % = "); Serial.println(h);
} else {
Serial.println("Failed to read humidity");
}
// Toggle heater enabled state every 30 seconds
// An ~3.0 degC temperature increase can be noted when heater is enabled
/*
if (++loopCnt == 30) {
enableHeater = !enableHeater;
sht31.heater(enableHeater);
Serial.print("Heater Enabled State: ");
if (sht31.isHeaterEnabled())
Serial.println("ENABLED");
else
Serial.println("DISABLED");
loopCnt = 0;
}
*/
}