Libreria per DHT sensor

Provo ad utilizzare un sensore DHT di Arceli con Arduino UNO R4 WiFi e IDE 2.3.4.
Ho provato ad utilizzare varie librerie dell'IDE ma ottengoo errore " no such file or directory" o errori come i seguenti

/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:11:1: error: 'dht' does not name a type; did you mean 'id_t'?
dht DHT; // create dht object
^~~
id_t
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino: In function 'void loop()':
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:21:13: error: 'dht' was not declared in this scope
int chk = dht.read11(dhtPin);
^~~
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:24:10: error: 'DHTLIB_OK' was not declared in this scope
case DHTLIB_OK: // When read data successfully, print temperature and humidity data
^~~~~~~~~
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:24:10: note: suggested alternative: 'STDLIB_H'
case DHTLIB_OK: // When read data successfully, print temperature and humidity data
^~~~~~~~~
STDLIB_H
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:26:23: error: expected primary-expression before '.' token
Serial.print(DHT.humidity);
^
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:28:23: error: expected primary-expression before '.' token
Serial.print(DHT.temperature);
^
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:31:10: error: 'DHTLIB_ERROR_CHECKSUM' was not declared in this scope
case DHTLIB_ERROR_CHECKSUM: // Checksum error
^~~~~~~~~~~~~~~~~~~~~
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:34:10: error: 'DHTLIB_ERROR_TIMEOUT' was not declared in this scope
case DHTLIB_ERROR_TIMEOUT: // Time out error
^~~~~~~~~~~~~~~~~~~~
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:34:10: note: suggested alternative: 'FSP_ERR_TIMEOUT'
case DHTLIB_ERROR_TIMEOUT: // Time out error
^~~~~~~~~~~~~~~~~~~~
FSP_ERR_TIMEOUT

exit status 1

Compilation error: 'dht' does not name a type; did you mean 'id_t'?

Quale libreria devo installare? Graze in anticipo per qualsiasi suggerimento-

you can check the libraries that the community have tested here

Ti segnalo che, nella sezione in lingua Inglese, si può scrivere solo in Inglese ... quindi, per favore, la prossima volta presta più attenzione in quale sezione metti i tuoi post; questa volta esso è stato spostato, da un moderatore della sezione di lingua Inglese, nella sezione di lingua Italiana ... la prossima volta potrebbe venire direttamente eliminato.

Grazie.

Ho Utilizzato DHT Sensor by Arduino 1.4.6 e ricevo questi messaggi:

/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:11:1: error: 'dht' does not name a type; did you mean 'id_t'?
 dht DHT;          // create dht object
 ^~~
 id_t
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino: In function 'void loop()':
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:21:13: error: 'dht' was not declared in this scope
   int chk = dht.read11(dhtPin);
             ^~~
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:24:10: error: 'DHTLIB_OK' was not declared in this scope
     case DHTLIB_OK: // When read data successfully, print temperature and humidity data
          ^~~~~~~~~
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:24:10: note: suggested alternative: '_STDLIB_H_'
     case DHTLIB_OK: // When read data successfully, print temperature and humidity data
          ^~~~~~~~~
          _STDLIB_H_
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:26:23: error: expected primary-expression before '.' token
       Serial.print(DHT.humidity);
                       ^
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:28:23: error: expected primary-expression before '.' token
       Serial.print(DHT.temperature);
                       ^
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:31:10: error: 'DHTLIB_ERROR_CHECKSUM' was not declared in this scope
     case DHTLIB_ERROR_CHECKSUM: // Checksum error
          ^~~~~~~~~~~~~~~~~~~~~
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:34:10: error: 'DHTLIB_ERROR_TIMEOUT' was not declared in this scope
     case DHTLIB_ERROR_TIMEOUT:  // Time out error
          ^~~~~~~~~~~~~~~~~~~~
/home/giorgio/ArduinoSketches/Sketch_DHT11/Sketch_DHT11.ino:34:10: note: suggested alternative: 'FSP_ERR_TIMEOUT'
     case DHTLIB_ERROR_TIMEOUT:  // Time out error
          ^~~~~~~~~~~~~~~~~~~~
          FSP_ERR_TIMEOUT

exit status 1

Compilation error: 'dht' does not name a type; did you mean 'id_t'?

Questo è lo sketch:

/*
  Sketch 22.1.1
  Temperature & Humidity Sensor

  modified 2016/8/17
  by http://www.freenove.com
*/

#include <DHT.h>

dht DHT;          // create dht object
int dhtPin = 3;  // the number of the DHT11 sensor pin

void setup() {
  Serial.begin(9600); // Initialize the serial port and set the baud rate to 9600
  Serial.println("UNO is ready!");  // Print the string "UNO is ready!"
}

void loop() {
  // read DHT11 and judge the state according to the return value
  int chk = dht.read11(dhtPin);
  switch (chk)
  {
    case DHTLIB_OK: // When read data successfully, print temperature and humidity data
      Serial.print("Humidity: ");
      Serial.print(DHT.humidity);
      Serial.print("%, Temperature: ");
      Serial.print(DHT.temperature);
      Serial.println("C");
      break;
    case DHTLIB_ERROR_CHECKSUM: // Checksum error                                                                                                                                                                                                                                                                                                     
      Serial.println("Checksum error");
      break;
    case DHTLIB_ERROR_TIMEOUT:  // Time out error
      Serial.println("Time out error");
      break;
    default:                    // Unknown error
      Serial.println("Unknown error");
      break;
  }
  delay(4000);
}

Buongiorno e benvenuto nella sezione Italiana del forum,

cortesemente, come prima cosa, leggi attentamente il REGOLAMENTO di detta sezione, (... e, per evitare future possibili discussioni/incomprensioni, prestando molta attenzione al punto 15), dopo di che, come da suddetto regolamento (punto 16.7), fai la tua presentazione NELL'APPOSITA DISCUSSIONE (... quello che vedi in blu è un link, fai click su di esso per raggiungere la discussione) spiegando bene quali esperienze hai in elettronica e programmazione, affinché noi possiamo conoscere la tua esperienza ed esprimerci con termini adeguati.

Detto questo, come richiesto al punto 7 del succitato regolamento, per favore edita il tuo primo post qui sopra (quindi NON scrivendo un nuovo post, ma utilizzando il bottone a forma di piccola matita :pencil2: che si trova in basso del tuo post), seleziona la parte di codice e premi l'icona "<CODE/>" nella barra degli strumenti per contrassegnarla come codice. Inoltre, così com'è, non è molto leggibile ... assicurati di averlo correttamente indentato nell'IDE prima di inserirlo (questo lo si fa premendo ctrlT su un PC o cmd T su un Mac, sempre all'interno del IDE).

Grazie
Alex

P.S.: Ti ricordo che, purtroppo, fino a quando non sarà fatta la presentazione nell’apposita discussione, nel rispetto del succitato regolamento nessuno ti risponderà (eventuali risposte o tuoi ulteriori post, verrebbero temporaneamente nascosti), quindi ti consiglio di farla al più presto. :wink:

P.P.S.: Evitate di utilizzare la traduzione automatica fatta dal browser ... vi impedisce di capire la lingua della sezione dove andate a scrivere ...

@gionapoli:

Stai usando la libreria di Adafruit? Quella che richiede la Adafruit Unified Sensor Lib?

Se SI, guarda cosa hai scritto tu:

dht DHT;          // create dht object

e cosa trovi invece negli esempi della libreria :roll_eyes:

Guglielmo

OK. Letto, provato e verificato che funziona!
Mille grazie
Giorgio

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.