B4R Question rDHT confusion

newbie

Member
Licensed User
Longtime User
Hello,
has someone a directly functioning rDHT library ?

i have download and try all versions i have found in the forums,
but nothing works ( with different messages).
I have try the suggestions in the threads but no prosperity.
After more than one hour i am frustrated.

THANKS for any help
 

positrom2

Active Member
Licensed User
Longtime User
After more than one hour i am frustrated.
That's much too early.
I just tried some of the DHT examples here, but none worked. They all give the infameous error
fatal error: dht.h: No such file or directory
#include <dht.h>
There are a couple of posts here how to fix it, but I was not able (within 1/2 hour):(.
What works fine is Erel's example on the BMP280 for the ESP8266.
So, it might be best if you indicate on which systems you wish to work.
 
Last edited:
Upvote 0

derez

Expert
Licensed User
Longtime User
That's much too early.
I just tried some of the DHT examples here, but none worked. They all give the error

There are a couple of posts here how to fix it, but I was not able (within 1/2 hour):(.
What works fine is Erel's example on the BMP280.

Install the dht library to your Arduino IDE - go to sketch -include library - manage libraries and search for DHT, then "more info" and install.
 
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
Always same error with those DHT examples here, on UNO, ESP8266 - also with some fixes proposed so far.
On Arduino IDE no problem (compiles with UNO).
 
Upvote 0

inakigarm

Well-Known Member
Licensed User
Longtime User
I've no computer here to test it; can yo attach log code errors, B4R version and Arduino Ide version? There was some incompatibility issues with some Arduino IDE versions and B4R.
 
Upvote 0

newbie

Member
Licensed User
Longtime User
Have you installed the DHT library from Arduino IDE libraries manager?

Yes, and it works with arduino.ide well

i have try the following:
--> using rDHTv2 (found in forum)

B4R version: 1.50
Parsing code. (0.00s)
Compiling code. (0.04s)
Building project (0.03s)
Compiling & deploying Ino project (Arduino Due (Programming Port) - COM5) Error
Konfiguration wird geladen...
Pakete werden initialisiert...
Boards werden vorbereitet...
Überprüfungs- und Hochladevorgang...
In file included from sketch\B4RDefines.h:25:0,
from sketch\AsyncStreams.cpp:1:
sketch\rDht.h:10:4: error: 'dht' does not name a type
dht Dht;
^
exit status 1
Fehler beim Kompilieren für das Board Arduino Due (Programming Port).


--> rDHTv2 with deleted line "<dependsOn>&lt;dht.h&gt;</dependsOn>"
the same Message as before

--> now i have try my well working arduino code via InLine-Code

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'Public variables can be accessed from all modules.
   Public DHT1Temp As Float
   Public DHT1Hum As Float
   Public DHT1State As String
End Sub

Sub ReadDHT1Data
   RunNative("ReadDHT1",Null)   
End Sub

#If C
#include "DHT.h"

#define DHT1Pin 22 //change here the IO-Pin
#define DHT2Pin 24

dht DHT

void ReadDHT1(B4R::Object* o) {
   int chk = dht.read11(DHT1Pin);
     
   switch (chk){
  case DHTLIB_OK:
     b4r_dht1state = "OK";
     b4r_dht1hum  = dht.humidity;
       b4r_dht1temp = dht.temperature;
       break;
  case DHTLIB_ERROR_CHECKSUM:
     b4r_dht1state = "Checksum error";
     b4r_dht1hum = 0;
     b4r_dht1hum = 0;
     break;
  case DHTLIB_ERROR_TIMEOUT:
     b4r_dht1state = "Time out error";
     b4r_dht1hum = 0;
     b4r_dht1hum = 0;
     break;
  default:
     b4r_dht1state = "Unknown error";
     b4r_dht1hum = 0;
     b4r_dht1hum = 0;
     break;
  }
}
#End If

here i get the following message:

B4R version: 1.50
Parsing code. (0.00s)
Compiling code. (0.02s)
Building project (0.02s)
Compiling & deploying Ino project (Arduino Due (Programming Port) - COM5) Error
Konfiguration wird geladen...
Pakete werden initialisiert...
Boards werden vorbereitet...
Überprüfungs- und Hochladevorgang...
b4r_dht.cpp:16: error: expected initializer before 'void'
void ReadDHT1(B4R::Object* o) {
^
exit status 1
expected initializer before 'void'
 
Upvote 0

newbie

Member
Licensed User
Longtime User
You need to add a semicolon after dht DHT.

It should also be #include <DHT.h>

Okay, that was a stupid mistake.
But there are still other errors that i dont understand:

i have the inline-code reduced
B4X:
#If C
#include "DHT.h"

#define DHT1Pin 22 //change here the IO-Pin
#define DHT2Pin 24

dht DHT;

void ReadDHT1(B4R::Object* o) {
   int chk = dht.read11(DHT1Pin);
   
   b4r_dht::_dht1hum  = dht.humidity;
   b4r_dht::_dht1temp = dht.temperature;
}
#End If

and get this errors:

B4R version: 1.50
Parsing code. (0.00s)
Compiling code. (0.04s)
Building project (0.02s)
Compiling & deploying Ino project (Arduino Due (Programming Port) - COM5) Error
Konfiguration wird geladen...
Pakete werden initialisiert...
Boards werden vorbereitet...
Überprüfungs- und Hochladevorgang...
sketch\b4r_dht.cpp: In function 'void ReadDHT1(B4R::Object*)':
b4r_dht.cpp:17: error: expected primary-expression before '.' token
int chk = dht.read11(DHT1Pin);
^
b4r_dht.cpp:19: error: expected primary-expression before '.' token
b4r_dht::_dht1hum = dht.humidity;
^
b4r_dht.cpp:20: error: expected primary-expression before '.' token
b4r_dht::_dht1temp = dht.temperature;
^
sketch\b4r_dht.cpp: In static member function 'static void b4r_dht::_process_globals()':
b4r_dht.cpp:26: error: unable to find numeric literal operator 'operator"" f'
b4r_dht::_dht1temp = 0f;
^
b4r_dht.cpp:28: error: unable to find numeric literal operator 'operator"" f'
b4r_dht::_dht1hum = 0f;
^
exit status 1
expected primary-expression before '.' token
 
Upvote 0

newbie

Member
Licensed User
Longtime User
The variable name is DHT not dht.

OK
and what means this ??
sketch\b4r_dht.cpp: In static member function 'static void b4r_dht::_process_globals()':
b4r_dht.cpp:26: error: unable to find numeric literal operator 'operator"" f'
b4r_dht::_dht1temp = 0f;
^
b4r_dht.cpp:28: error: unable to find numeric literal operator 'operator"" f'
b4r_dht::_dht1hum = 0f;
^
exit status 1
unable to find numeric literal operator 'operator"" f'
 
Upvote 0

newbie

Member
Licensed User
Longtime User
Have you tried this library: https://www.b4x.com/android/forum/threads/wemos-d1-r2-dht22.68615/#post-435204 ?

Change the variables type to Double instead of Float.

Hi Erel,

thanks, the InLine-Code now works well,:):):)

:(the rDHT you have linked give me the following Error:

C:\Users\Gerd\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.9\variants\arduino_due_x/variant.h:63:65: error: invalid conversion from 'Pio*' to 'uint8_t {aka unsigned char}' [-fpermissive]
#define digitalPinToPort(P) ( g_APinDescription[P].pPort )
^
sketch\dht.cpp:121:20: note: in expansion of macro 'digitalPinToPort'
uint8_t port = digitalPinToPort(pin);
^
C:\Users\Gerd\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.9\variants\arduino_due_x/variant.h:67:44: error: base operand of '->' is not a pointer
#define portInputRegister(port) ( &(port->PIO_PDSR) )
^
sketch\dht.cpp:122:48: note: in expansion of macro 'portInputRegister'
volatile uint8_t *PIR = (volatile uint8_t*)portInputRegister(port);
^
exit status 1
Fehler beim Kompilieren für das Board Arduino Due (Programming Port).
 
Upvote 0

rbghongade

Active Member
Licensed User
Longtime User
Dear friends,
I too am having weird behaviour of DHT22 used with rDHT library. Interestingly it worked for quite some time, but recently it stopped working , compiles ok, but reads both temperature and humidity as zero. I am now switching over to inline c code, but wish that the B4R library be fixed.
Too much inline C code is shadowing the wonderful B4R code!
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

tested the rDHT Library v2.00 with a WeMOS D1 and DHT11via serial COM port. Project & Library attached. Arduino IDE 1.6.11 used!
Wiring
B4X:
DHT11 ---- ESP8266 WeMOS D1 Wirecolor
GND ------ GND            black
VCC ------ 5v            red
Signal --- D4 (SDA)    yellow
Output
B4X:
Humidity = 40 %  Temperature =18 Cº
Humidity = 40 %  Temperature =18 Cº
Humidity = 39 %  Temperature =19 Cº
Humidity = 39 %  Temperature =20 Cº
 

Attachments

  • b4rhowtoesp8266dht11.zip
    5.4 KB · Views: 293
Last edited:
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
Hi,

tested the rDHT Library v2.00 with a WeMOS D1 and DHT11via serial COM port. Project & Library attached. Arduino IDE 1.6.11 used!
Wiring
B4X:
DHT11 ---- ESP8266 WeMOS D1 Wirecolor
GND ------ GND            black
VCC ------ 5v            red
Signal --- D4 (SDA)    yellow
Output
B4X:
Humidity = 40 %  Temperature =18 Cº
Humidity = 40 %  Temperature =18 Cº
Humidity = 39 %  Temperature =19 Cº
Humidity = 39 %  Temperature =20 Cº

is it support for DHT22 sensors?
 
Upvote 0

newbie

Member
Licensed User
Longtime User
Hi,

tested the rDHT Library v2.00 with a WeMOS D1 and DHT11via serial COM port. Project & Library attached. Arduino IDE 1.6.11 used!
Wiring
B4X:
DHT11 ---- ESP8266 WeMOS D1 Wirecolor
GND ------ GND            black
VCC ------ 5v            red
Signal --- D4 (SDA)    yellow
Output
B4X:
Humidity = 40 %  Temperature =18 Cº
Humidity = 40 %  Temperature =18 Cº
Humidity = 39 %  Temperature =19 Cº
Humidity = 39 %  Temperature =20 Cº


Hi,

it seems there are a some incompatible things between librarie and some boards.
I have tested your attached librarie for my Due --> lot of compiler-errors.
Same Code tested with an UNO --> works.
That makes the confusion.
 
Upvote 0
Top