C/C++ Question Problem with DHT library wrapper

inakigarm

Well-Known Member
Licensed User
Longtime User
I've tried to wrap DTH library to read Temperature and Humidity of an inexpensive DHT11 sensor

DHT11
dht11.jpg

First, I've tried to wrap the Dht class and one method (read11 and it works) but I can't configure how to obtain the humidity and temperature parameters (I've no experience on C and I suppose is a syntax problem)

I attached the original library and the wrapper; anybody can help me doing the wrapper?

Thanks
 

Attachments

  • dht.zip
    3.8 KB · Views: 531

Erel

B4X founder
Staff member
Licensed User
Longtime User
Change the signature to:
Double GetHumidity();


in the cpp file:
Double B4RDht::GetHumidity(){
return Dht.humidity;
}


Another option is to make it a property. This will happen if you change the name to getHumidity instead of GetHumidity.

BTW, you should always use Double instead of double. Otherwise there will be compiler errors when you compile to Arduino Due.
 
Top