Ciao tutti,
ho comprato tempo fa su amazon il DHT11 della sunfounder link.
All'inizio tutto funzionava ma adesso si presenta l'errore "timeout error".
Ho letto alcune discussioni dove si diceva che probabilmente fosse rotto link è così?
Esiste la possibilità di verificare questo evento?
Inserisco il codice che ho utilizzato fino ad ora.
/*
FILE: Humidity.30MAG16
TAG: DHT11, time out error
PURPOSE: Humidity test sketch for Arduino
PROBES: DHT11
VERSION:
DISPLAY: NC
COMFORT: HR 45%, T 23°C
AUTHOR: Antonio Cannavale
DHT11 connected to a Arduino as follow:
GND -> GND
VCC -> +5V
SIG -> Digital pin
*/
#include <dht11.h> // Include DHT11 library:
dht11 DHT; // Store an instance of the DHT11 sensor:
#define DHT11_PIN 2 // Define input at digital pin:
boolean DEBUG = true; // Set to true to print status messages to the serial:
// The setup function runs once when you press reset or power the board:
void setup() { // Start setup:
// We start the serial library to output our messages:
if (DEBUG) {
Serial.begin(9600);
} // End if (DEBUG):
while (!Serial) {
; // Wait for serial port to connect. Needed for native USB port only:
} // End while(!Serial):
Serial.println(F("\nDHT TEST PROGRAM"));
Serial.print(F("\nLIBRARY VERSION: "));
Serial.println(DHT11LIB_VERSION);
Serial.print(F("\nConnected PIN: "));
Serial.println(DHT11_PIN);
Serial.println(F("\nType,\tStatus,\tRH (%),\tT (C)"));
delay(1000); // Delay to let system boot:
} // End setup:
// The loop function runs over and over again forever:
void loop() { // Start loop:
Serial.print("DHT11, \t");
int chk = DHT.read(DHT11_PIN); // Read the value returned from sensor at digital PIN:
switch (chk) {
case DHTLIB_OK: // The sensor samples and its checksum are OK:
Serial.print(F("OK,\t"));
break;
case DHTLIB_ERROR_CHECKSUM: // The checksum test failed:
Serial.print(F("Checksum error,\t"));
break;
case DHTLIB_ERROR_TIMEOUT: // A timeout occurred, and communication has failed:
Serial.println(F("Time out error,\t"));
delay(1000); // Wait 1 minutes before accessing sensor again:
return;
default:
Serial.print(F("Unknown error,\t"));
break;
} // End switch (chk):
Serial.print(DHT.humidity, 1); // Print the humidity:
Serial.print(F(",\t"));
Serial.println(DHT.temperature, 1); // Print the temperature:
delay(1000); // Wait 1 minutes before accessing sensor again:
} // End loop:
Grazie in anticipo.