From 8837368a14a79449cf02d32580cb54b268a08051 Mon Sep 17 00:00:00 2001 From: Thomas Klaehn Date: Mon, 29 Jul 2019 10:18:14 +0100 Subject: [PATCH] ADS1115: skip negative values. --- src/ads1115.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ads1115.c b/src/ads1115.c index 762be90..9b12188 100644 --- a/src/ads1115.c +++ b/src/ads1115.c @@ -94,6 +94,9 @@ int ads1115_read_conversation_result(const struct ads1115_dev *ads1115, return res; } result->raw = buffer[0] << 8 | buffer[1]; + if(result->raw & 0x8000) { + result->raw = 0; + } result->voltage = result->raw * VPS; return 0;