Acualizaciones del codigo para el DHT11 y la fotocelda
This commit is contained in:
parent
4ce0244bd7
commit
d97cb1f9b0
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 97c1a18cfd6f125cad9e1483a302f8c9e928f3ce
|
|
@ -0,0 +1,38 @@
|
||||||
|
#include <DHT.h>
|
||||||
|
#include <DHT_U.h>
|
||||||
|
|
||||||
|
DHT SenHumTemp (1, DHT11);
|
||||||
|
float tempc, hume;
|
||||||
|
int temp_limite = 29;
|
||||||
|
int ventiladores = 3;
|
||||||
|
bool ventiladores_activados = false;
|
||||||
|
unsigned long start_time = 0;
|
||||||
|
|
||||||
|
void leerDatos(){
|
||||||
|
tempc = SenHumTemp.readTemperature();
|
||||||
|
hume = SenHumTemp.readHumidity();
|
||||||
|
Serial.println("Temperatura: " + String(tempc)+ "Humedad: " + String (hume));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
SenHumTemp.begin();
|
||||||
|
pinMode (ventiladores, OUTPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if(millis() - start_time >= 2000){
|
||||||
|
leerDatos();
|
||||||
|
start_time = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempc >= temp_limite){
|
||||||
|
digitalWrite (ventiladores, HIGH);
|
||||||
|
ventiladores_activados = true;
|
||||||
|
Serial.println ("Los ventiladores se han activado");
|
||||||
|
}else {
|
||||||
|
digitalWrite (ventiladores, LOW);
|
||||||
|
ventiladores_activados = false;
|
||||||
|
Serial.println ("Los ventiladores se han desactivado");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
#include <DHT.h>
|
||||||
|
#include <DHT_U.h>
|
||||||
|
|
||||||
|
DHT SenHumTemp (1, DHT11);
|
||||||
|
float tempc, hume;
|
||||||
|
int temp_limite = 29;
|
||||||
|
int ventiladores = 3;
|
||||||
|
bool ventiladores_activados = false;
|
||||||
|
unsigned long start_time = 0;
|
||||||
|
|
||||||
|
void leerDatos(){
|
||||||
|
tempc = SenHumTemp.readTemperature();
|
||||||
|
hume = SenHumTemp.readHumidity();
|
||||||
|
Serial.println("Temperatura: " + String(tempc)+ "Humedad: " + String (hume));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
SenHumTemp.begin();
|
||||||
|
pinMode (ventiladores, OUTPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if(millis() - start_time >= 2000){
|
||||||
|
leerDatos();
|
||||||
|
start_time = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempc >= temp_limite){
|
||||||
|
digitalWrite (ventiladores, HIGH);
|
||||||
|
ventiladores_activados = true;
|
||||||
|
Serial.println ("Los ventiladores se han activado");
|
||||||
|
}else {
|
||||||
|
digitalWrite (ventiladores, LOW);
|
||||||
|
ventiladores_activados = false;
|
||||||
|
Serial.println ("Los ventiladores se han desactivado");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue