Skip to content

Instantly share code, notes, and snippets.

@esmarr58
Created December 20, 2017 20:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save esmarr58/4d3d55486eb697527ef4a5e293b1ae9f to your computer and use it in GitHub Desktop.
#include <DHT11.h> //cargamos la librería DHT
int pin=2; //Seleccionamos el pin en el que se //conectará el sensor
DHT11 dht11(pin); //Se selecciona el DHT11 (hay //otros DHT)
void setup() {
Serial.begin(9600); //Se inicia la comunicación serial
}
void loop() {
float temp, hum;
int err;
if((err=dht11.read(hum, temp))==0)
{
Serial.print("Temperatura: ");
Serial.print(temp);
Serial.print(" Humedad: ");
Serial.print(hum);
Serial.println();
}
else
{
Serial.println();
Serial.print("Error Num :");
Serial.print(err);
Serial.println();
}
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment