[riot-notifications] [RIOT-OS/RIOT] drivers/dht: Bugfixes (#11876)

Sebastian Meiling notifications at github.com
Tue Jul 23 22:22:44 CEST 2019


smlng commented on this pull request.



> +
+        /* validate the checksum */
+        sum = (raw_temp >> 8) + (raw_temp & 0xff) + (raw_hum >> 8) + (raw_hum & 0xff);
+        if ((sum != csum) || (csum == 0)) {
+            DEBUG("error: checksum invalid\n");
+            return DHT_NOCSUM;
+        }
+
+        /* parse the RAW values */
+        DEBUG("RAW values: temp: %7i hum: %7i\n", (int)raw_temp, (int)raw_hum);
+        switch (dev->params.type) {
+            case DHT11:
+                dev->last_val.temperature = (int16_t)((raw_temp >> 8) * 10);
+                dev->last_val.humidity = (int16_t)((raw_hum >> 8) * 10);
+                break;
+            case DHT22:

yeah sorry, just saw it wasn't there before. ignore then

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11876#discussion_r306515219
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190723/8e089de6/attachment-0001.htm>


More information about the notifications mailing list