#include <OneWire.h>
#include <DallasTemperature.h>
#include "DHTesp.h"
// Temp & Humidity Bedroom
const int BedroomPin = 4; // DHT_PIN is on pin *
DHTesp Bedroom; // dhtSensor name will be rules are found DHTesp
// Temp & Humidity Living room
const int Livingroom1 = 5;
DHTesp Livingroom;
// Temp & Humidity Under the floor
const int Ufloor1 = 6;
DHTesp Ufloor;
// Temp & Humidity Pass Throw
const int PassThrow1 = 7;
DHTesp PassThrow;
//Outside temp
// Data wire is plugged into digital pin 2 on the Arduino
#define Outside_Temp 2
// Setup a oneWire instance to communicate with any OneWire device
OneWire oneWire(Outside_Temp);
// Pass oneWire reference to DallasTemperature library
DallasTemperature Outside_sensors(&oneWire);
void setup() {
Serial.begin(115200);
Bedroom.setup(BedroomPin, DHTesp::DHT22);
//dhtSensor.setup will cobind location DHT_PIN with rules DHTesp and will find DHT22 as a sencer
Livingroom.setup(Livingroom1, DHTesp::DHT22);
Ufloor.setup(Ufloor1, DHTesp::DHT22);
Outside_sensors.begin(); // Start up the DS18B20 sensor library
}
void loop() {
// Send the command to get temperatures
Outside_sensors.requestTemperatures();
//print the temperature in Celsius
Serial.print("Temperature: ");
Serial.print(Outside_sensors.getTempCByIndex(0));
Serial.print((char)176);//shows degrees character
Serial.print("C | ");
//print the temperature in Fahrenheit
Serial.print((Outside_sensors.getTempCByIndex(0) * 9.0) / 5.0 + 32.0);
Serial.print((char)176);//shows degrees character
Serial.println("F");
TempAndHumidity Bedroomdata = Bedroom.getTempAndHumidity();
Serial.println("Temp: " + String(Bedroomdata.temperature, 2) + "°C");
Serial.println("Humidity: " + String(Bedroomdata.humidity, 1) + "%");
Serial.println("---");
Serial.println(Bedroom.getPin());
TempAndHumidity Livingroomdata = Livingroom.getTempAndHumidity();
Serial.println("Temp: " + String(Livingroomdata.temperature, 2) + "°C");
Serial.println("Humidity: " + String(Livingroomdata.humidity, 1) + "%");
Serial.println("---");
Serial.println(Livingroom.getPin());
TempAndHumidity Ufloor1data = Ufloor.getTempAndHumidity();
Serial.println("Temp: " + String(Ufloor1data.temperature, 2) + "°C");
Serial.println("Humidity: " + String(Ufloor1data.humidity, 1) + "%");
Serial.println("---");
Serial.println(Ufloor.getPin());
delay(2000); // Wait for a new reading from the sensor (DHT22 has ~0.5Hz sample rate)
}