DHT-sensor-library icon indicating copy to clipboard operation
DHT-sensor-library copied to clipboard

Improvement: Add a public getRawData() function

Open leowatts opened this issue 4 years ago • 1 comments

I am currently doing a project with an ESP32 where I need to store and transmit data over the internet from a DHT22, it would be nice to be able to use the 4-byte raw data from the sensor, as that is a smaller size that unnecessarily storing the floats. I propose a public function that simply allows a programmer to read the raw data of the sensor. Something like:

const byte* getRawData() const { return data; }

The programmer would be responsible for calling read() prior to this (or I suppose it could be integrated into the function and a nullptr returned if it fails).

leowatts avatar Feb 08 '21 11:02 leowatts

I had a similar complaint a few years ago when I was using this library. I was storing the read values in integer format anyway so I needed to convert the floats back to integers. On Arduino boards with no FPU and limited program memory, this may needlessly increase program size, along with decreasing performance and overall being “less elegant”.

Adrian-Samoticha avatar Nov 18 '22 13:11 Adrian-Samoticha