compilation error with DHT11

Hi Guys.
I have a problem with dht library by Adafruit, version 1.1.1 and 1.1.0.

I try with many libs, and I have the same problem ever.

I using a Arduino DUE, with Arduino 1.65 IDE.
I await your comments.

C:\Users\charly\Documents\Arduino\libraries\DHT_sensor_library\DHT.cpp: In constructor 'DHT::DHT(uint8_t, uint8_t, uint8_t)':
C:\Users\charly\Documents\Arduino\libraries\DHT_sensor_library\DHT.cpp:14:9: error: invalid conversion from 'Pio*' to 'uint8_t {aka unsigned char}' [-fpermissive]
_port = digitalPinToPort(pin);
^
Error de compilación

Sketch:

// include the library code:
#include <LiquidCrystal.h>
#include <DHT.h>

//-------{PINES}-----------

const int tempSensor = 35;

#define DHTPIN 7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
int h = dht.readHumidity();// Lee la humedad
int t= dht.readTemperature();//Lee la temperatura
}

Regards

Are you sure that library is also for the Due ?

Try this version - Arduino/libraries/DHTstable at master · RobTillaart/Arduino · GitHub

thaks Rob, now works fine!

Best regards.

Good to hear it still works on the DUE :slight_smile:

Hi robtillaart
can you tell me if your lib works with DHT22, or where I can get one that works with DUE?

Adafruit lib still not working with DUE.

Thanks
Best Regards.

THe DHTstable should work with the DUE, it is confirmed in the past.

However as the handshake is time critical, having a lot of interrupts in a program can crash every handshake as it becomes difficult to get the timing right.

Thanks for your response.
I probe the library, and works fine.
The test file in your repository, has many errors in a structure code.

C:\Users\charly\AppData\Local\Temp\build7656527569339374557.tmp\prebaLDR.ino.cpp -o C:\Users\charly\AppData\Local\Temp\build7656527569339374557.tmp\prebaLDR.ino.cpp.o 
prebaLDR.ino.ino:32:3: error: '<anonymous struct> stat' redeclared as different kind of symbol
In file included from c:\users\charly\appdata\roaming\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\stdlib.h:11:0,
                 from C:\Users\charly\AppData\Roaming\Arduino15\packages\arduino\hardware\sam\1.6.4\cores\arduino/Arduino.h:24,
                 from C:\Users\charly\Documents\Arduino\libraries\DHTstable/dht.h:18,
                 from prebaLDR.ino.ino:16:
c:\users\charly\appdata\roaming\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\sys\stat.h:150:5: error: previous declaration of 'int stat(const char*, stat*)'
 int _EXFUN(stat,( const char *__restrict __path, struct stat *__restrict __sbuf ));
     ^
prebaLDR.ino.ino: In function 'void loop()':
prebaLDR.ino.ino:53:10: error: request for member 'total' in 'stat', which is of non-class type 'int(const char*, stat*)'
prebaLDR.ino.ino:57:14: error: request for member 'ok' in 'stat', which is of non-class type 'int(const char*, stat*)'
prebaLDR.ino.ino:61:14: error: request for member 'crc_error' in 'stat', which is of non-class type 'int(const char*, stat*)'
prebaLDR.ino.ino:65:14: error: request for member 'time_out' in 'stat', which is of non-class type 'int(const char*, stat*)'
prebaLDR.ino.ino:69:14: error: request for member 'unknown' in 'stat', which is of non-class type 'int(const char*, stat*)'
prebaLDR.ino.ino:82:14: error: request for member 'total' in 'stat', which is of non-class type 'int(const char*, stat*)'
'<anonymous struct> stat' redeclared as different kind of symbol

The lib works fine with both sensors DHT11 and DHT22, so I need to use both sensors on same sketch.
How can I do that?
may, I need to create two DHT objets, but how can I do that?

thanks a lot for your time.

rename the stat object in the example to DHTstat, should fix it.

you can use one DHT object to read different pins as shown in the dht_test.ino example sketch.
You need to keep track if you read a 22 or an 11 type.

give it a try,