Created
December 20, 2017 20:21
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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