Skip to content

Commit

Permalink
actualizando codigo ejemplo de proyecto sensor dth11
Browse files Browse the repository at this point in the history
  • Loading branch information
chepecarlos committed Sep 21, 2024
1 parent c7535ca commit d536468
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 66 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "DHT.h"
#define PinSensor 2
#define Tipo DHT11 // Tipo de sensor Opciones DHT11, DHT22, DHT21
// DHT11 - Temperatura 0 a 50 c +- 2c Humedad 20 a 90% +- 4%
// DTH22 - Temperatura -40 a 80 c +- 0.5c Humedad 0 a 100% +- 2%

DHT dht(PinSensor, Tipo);

void setup() {
Serial.begin(9600);
dht.begin();
}

void loop() {
delay(5000); // Mínimo 2000
float humedad = dht.readHumidity();
float temperatura = dht.readTemperature();
Serial.print("Humedad: ");
Serial.print(humedad);
Serial.println(" %");
Serial.print("Temperatura: ");
Serial.print(temperatura);
Serial.println(" *C");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "DHT.h"
#define PinSensor 4
#define Tipo DHT11 // Tipo de sensor Opciones DHT11, DHT22, DHT21
// DHT11 - Temperatura 0 a 50 c +- 2c Humedad 20 a 90% +- 4%
// DTH22 - Temperatura -40 a 80 c +- 0.5c Humedad 0 a 100% +- 2%

DHT dht(PinSensor, Tipo);

void setup() {
Serial.begin(115200);
dht.begin();
}

void loop() {
delay(5000); // Mínimo 2000
float humedad = dht.readHumidity();
float temperatura = dht.readTemperature();
Serial.print("Humedad: ");
Serial.print(humedad);
Serial.println(" %");
Serial.print("Temperatura: ");
Serial.print(temperatura);
Serial.println(" *C");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "DHT.h"
#define PinSensor 4
#define Tipo DHT11 // Tipo de sensor Opciones DHT11, DHT22, DHT21
// DHT11 - Temperatura 0 a 50 c +- 2c Humedad 20 a 90% +- 4%
// DTH22 - Temperatura -40 a 80 c +- 0.5c Humedad 0 a 100% +- 2%

DHT dht(PinSensor, Tipo);

void setup() {
Serial.begin(115200);
dht.begin();
}

void loop() {
delay(5000); // Mínimo 2000
float humedad = dht.readHumidity();
float temperatura = dht.readTemperature();
Serial.print("Humedad: ");
Serial.print(humedad);
Serial.println(" %");
Serial.print("Temperatura: ");
Serial.print(temperatura);
Serial.println(" *C");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>

#define PinSensor 2
#define Tipo DHT11 // Tipo de sensor Opciones DHT11, DHT22, DHT21
// DHT11 - Temperatura 0 a 50 c +- 2c Humedad 20 a 90% +- 4%
// DTH22 - Temperatura -40 a 80 c +- 0.5c Humedad 0 a 100% +- 2%

DHT_Unified dht(PinSensor, Tipo);

void setup() {
Serial.begin(9600);
dht.begin();

Serial.println(F("Informacion del sensor DHTxx "));

sensor_t sensor;
dht.temperature().getSensor(&sensor);
Serial.println("------------------------------------");
Serial.println("Sensor Temperatura");
Serial.print("Tipo Sensor: ");
Serial.println(sensor.name);
Serial.print("Vercion: ");
Serial.println(sensor.version);
Serial.print("ID : ");
Serial.println(sensor.sensor_id);
Serial.print("Valor Maximo: ");
Serial.print(sensor.max_value);
Serial.println("°C");
Serial.print("Valor Minimo: ");
Serial.print(sensor.min_value);
Serial.println("°C");
Serial.print("Resolucion: ");
Serial.print(sensor.resolution);
Serial.println("°C");
Serial.println("------------------------------------");
dht.humidity().getSensor(&sensor);
Serial.println("Sensor Humdad;");
Serial.print("Tipo Sensor: ");
Serial.println(sensor.name);
Serial.print("Vercion: ");
Serial.println(sensor.version);
Serial.print("ID : ");
Serial.println(sensor.sensor_id);
Serial.print("Valor Maximo: ");
Serial.print(sensor.max_value);
Serial.println(F("%"));
Serial.print("Valor Minimo: ");
Serial.print(sensor.min_value);
Serial.println(F("%"));
Serial.print("Resolucion: ");
Serial.print(sensor.resolution);
Serial.println(F("%"));
Serial.println(F("------------------------------------"));
}

void loop() {
delay(5000);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "DHT.h"
#define PinSensor 2
#define Tipo DHT11 // Tipo de sensor Opciones DHT11, DHT22, DHT21
// DHT11 - Temperatura 0 a 50 c +- 2c Humedad 20 a 90% +- 4%
// DTH22 - Temperatura -40 a 80 c +- 0.5c Humedad 0 a 100% +- 2%

DHT dht(PinSensor, Tipo);

void setup() {
Serial.begin(9600);
dht.begin();
}

void loop() {
delay(5000); // Mínimo 2000
float humedad = dht.readHumidity();
float temperatura = dht.readTemperature();

if (isnan(temperatura) || isnan(humedad)) {
Serial.println("Error leyendo el sensor DHT");
return;
}

float sensacionTermica = dht.computeHeatIndex(temperatura, humedad, false);

Serial.print("Humedad: ");
Serial.print(humedad);
Serial.println(" %");
Serial.print("Temperatura: ");
Serial.print(temperatura);
Serial.println(" *C");
Serial.print("Sensacion Termica: ");
Serial.print(sensacionTermica);
Serial.println(" *C");
}

0 comments on commit d536468

Please sign in to comment.