Compare commits
No commits in common. "c4edb43af6082d9867d078a638cc17d99480d27e" and "1df37cb910bbf84ede0ff62395c8aa6a2caf35d2" have entirely different histories.
c4edb43af6
...
1df37cb910
@ -20,10 +20,6 @@ DHT dht(DHT_PIN, DHT_TYPE);
|
|||||||
|
|
||||||
int sensorValue;
|
int sensorValue;
|
||||||
long last_sample = 0;
|
long last_sample = 0;
|
||||||
float hmid = 0; // humidity
|
|
||||||
float temp = 0; // temperature
|
|
||||||
float heat = 0; // heat index
|
|
||||||
float airq = 0; // air quality / gas
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(SERIAL_BAUDRATE);
|
Serial.begin(SERIAL_BAUDRATE);
|
||||||
@ -31,12 +27,6 @@ void setup() {
|
|||||||
pinMode(LED_BUILTIN, OUTPUT);
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
digitalWrite(LED_BUILTIN, LOW);
|
digitalWrite(LED_BUILTIN, LOW);
|
||||||
dht.begin();
|
dht.begin();
|
||||||
Wire.begin(8); // join i2c bus with address #8
|
|
||||||
Wire.onRequest(requestEvent); // register event
|
|
||||||
}
|
|
||||||
|
|
||||||
void requestEvent() {
|
|
||||||
Wire.write("he1234");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
@ -48,25 +38,25 @@ void loop() {
|
|||||||
last_sample = now;
|
last_sample = now;
|
||||||
if (OPERATION_BLINK_EN) {digitalWrite(LED_BUILTIN, HIGH);}
|
if (OPERATION_BLINK_EN) {digitalWrite(LED_BUILTIN, HIGH);}
|
||||||
|
|
||||||
hmid = dht.readHumidity();
|
float h = dht.readHumidity();
|
||||||
temp = dht.readTemperature();
|
float t = dht.readTemperature();
|
||||||
|
|
||||||
if (isnan(hmid) || isnan(temp)) {
|
if (isnan(h) || isnan(t)) {
|
||||||
Serial.println(F("Failed to read from DHT sensor!"));
|
Serial.println(F("Failed to read from DHT sensor!"));
|
||||||
} else {
|
} else {
|
||||||
heat = dht.computeHeatIndex(temp, hmid, false);
|
float hi = dht.computeHeatIndex(t, h, false);
|
||||||
Serial.print(F("Humidity: "));
|
Serial.print(F("Humidity: "));
|
||||||
Serial.print(hmid);
|
Serial.print(h);
|
||||||
Serial.print(F("% Temperature: "));
|
Serial.print(F("% Temperature: "));
|
||||||
Serial.print(temp);
|
Serial.print(t);
|
||||||
Serial.print(F("°C Heat index: "));
|
Serial.print(F("°C Heat index: "));
|
||||||
Serial.print(heat);
|
Serial.print(hi);
|
||||||
Serial.print(F("°C "));
|
Serial.println(F("°C "));
|
||||||
}
|
}
|
||||||
|
|
||||||
airq = analogRead(MQ135_PIN);
|
sensorValue = analogRead(MQ135_PIN);
|
||||||
Serial.print("AirQuality: ");
|
Serial.print("AirQuality=");
|
||||||
Serial.print(airq);
|
Serial.print(sensorValue, DEC);
|
||||||
Serial.println(" PPM");
|
Serial.println(" PPM");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user