Está en la página 1de 5

INSTITUTO TECNOLÓGICO DE TUXTLA GUTIÉRREZ

INGENIERÍA ELÉCTRICA
GRUPO E7B

CONTROL DE MAQUINAS
Reportar capturas de pantalla, código en arduino y   simular con wokwi.

CORTEZ VAZQUEZ ERICK


YAEL CASTELLANOS PEREZ
JOSÉ MANUEL JIMÉNEZ CABRERA
MILLA ZUÑIGA DANIEL ALBERTO
GERARDO LECIE ESPINOZA

ASESOR
DR. RAFAEL MOTA GRAJALES

24 DE NOVIEMBRE DEL 2021


CODIGO
#include <DHT.h>
#include <DHT_U.h>
const float GAMMA = 0.7;
const float RL10 = 50;

// Incluimos librería
#include <DHT.h>
 
// Definimos el pin digital donde se conecta el sensor
#define DHTPIN 2
#define LDR_PIN 2
// Dependiendo del tipo de sensor
#define DHTTYPE DHT22

 //Medidor de intensidad luminosa


// Convert the analog value into lux value:

// Inicializamos el sensor DHT11


DHT dht(DHTPIN, DHTTYPE);
 
void setup() {
  // Inicializamos comunicación serie
  Serial.begin(9600);
 pinMode(LDR_PIN, INPUT);
  // Comenzamos el sensor DHT
  dht.begin();

}
 
void loop() {
    // Esperamos 5 segundos entre medidas
  delay(2000);
 int analogValue = analogRead(A0);
  float voltage = analogValue / 1. * 5;
  float resistance = 2000 * voltage / (1 - voltage / 5);
  float lux = pow(RL10 * 1e3 * pow(10, GAMMA) / resistance, (1 / GAMMA));
// Lazo principal
// Lazo principal
  Serial.print(analogRead(A0));
  Serial.println(" luxes");
 
delay(1000);

 
  // Leemos la humedad relativa
  float h = dht.readHumidity();
  // Leemos la temperatura en grados centígrados (por defecto)
  float t = dht.readTemperature();
  // Leemos la temperatura en grados Fahreheit
  float f = dht.readTemperature(true);
 
  // Comprobamos si ha habido algún error en la lectura
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Error obteniendo los datos del sensor DHT11");
    return;
  }
 
  // Calcular el índice de calor en Fahreheit
  float hif = dht.computeHeatIndex(f, h);
  // Calcular el índice de calor en grados centígrados
  float hic = dht.computeHeatIndex(t, h, false);
 
  Serial.print("Humedad: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperatura: ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print(f);
  Serial.print(" *F\t");
  Serial.print("Índice de calor: ");
  Serial.print(hic);
  Serial.print(" *C ");
  Serial.print(hif);
  Serial.println(" *F");
 }

También podría gustarte