#include "DHT.h"
#define DHTPIN A0 // Digital pin connected to the DHT sensor
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
int TemperaturaBaja = 8;
int TemperaturaOk = 9;
int TemperaturaAlta = 10;
int HumedadBaja = 11;
int HumedadOk = 12;
int HumedadAlta = 103;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
// Configuración LEDs temperatura
pinMode(TemperaturaBaja, OUTPUT);
// pinMode(????, OUTPUT);
// pinMode(?????, OUTPUT);
// Configuración LEDs humedad
pinMode(HumedadBaja, OUTPUT);
// pinMode(????, OUTPUT);
// pinMode(??, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float humedad = dht.readHumidity();
// Read temperature as Celsius (the default)
float tempCelsius = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float TempFahrenheit = dht.readTemperature(true);
humedad = random(0,100);
tempCelsius = random(100,5000)/100.00;
TempFahrenheit = (tempCelsius * 9/5) + 32;
// Check if any reads failed and exit early (to try again).
if (isnan(humedad) || isnan(tempCelsius) || isnan(TempFahrenheit)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(TempFahrenheit, humedad);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(tempCelsius, humedad, false);
Serial.print("Humidity: "); Serial.print(humedad);
Serial.println("");
}