RAK3172 + DHT22 sensor

Hello!

I’m working with a RAK3172 module, using Arduino API. I would like to attach to this module a DHT22 sensor to send data using P2P, but itsn’t working. I guess is the library i’m using is not compatible with the microcontroller of this module. Can you please recommend me a library or if anyone have worked before with a RAK3172 + DHT22 who can help me with any pearl of wisdom, I will be very thankful.

Thanks a lot!

Welcome to the forum @ezroch

Which library are you trying to use?
What is not working?
Do you get compilation errors, if yes, can you post them here.
Do you use one of our example codes, if yes, which one?

Hi, @beegee. Thanks for the welcome!

Regarding this, I’m using an Arduino library I use in my arduino projects (https://github.com/adafruit/DHT-sensor-library) I thought this could work but then i remembered I’m not using an Arduino, but i didn’t find any other library that could work. So if you know any library that could work with the RAK3172 would be very good.

Yes, I am using your P2P example

Well, with the errors, first i got this error:

Looking for a way to solve this problem I found this possible solution (https://github.com/adafruit/DHT-sensor-library/issues/53#issuecomment-197458608), so I added in the “DHT.h” file the following:

#define clockCyclesPerMicrosecond() ( 48L ) // 48 is Clock Cycle of RAK3172 in MHz
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )

After that, the compilation shows no error, but when I print the read value i got a “NaN”

image

I used this to read and print:

  float hum{0.0};       //Humedity
  float temp{0.0};      //Temperature

  hum = dht.readHumidity();
  temp = dht.readTemperature();
  delay(500);

  Serial.printf("---Measured values---\n");
  Serial.printf("   Humedity: %f\r\n", hum);
  Serial.printf("   Temperature: %f\r\n", temp);

I’m very thankful for your help!

Thanks for the info.

I will send the missing definitions to our R&D team, but not sure when they will implement it, it is the first time I saw this error.

For the DHT22, I do not have that sensor. I worked with DHT11 and DHT22 before and their single wire protocol is quite difficult to catch. I had to write my own library DHTesp to get them to work with Espressif ESP MCU’s.
It could be that RUI3 is not able to catch the length of the zero’s and one’s in the data stream correct.
I will forward this as well to our R&D team, but not sure if it can be fixed soon.