diff options
author | 2018-02-10 22:47:32 +0200 | |
---|---|---|
committer | 2018-02-10 22:47:32 +0200 | |
commit | 2f8f76c313633d12e04fc5fd9a4bccf6b856fa2d (patch) | |
tree | d6ab786504cd1789a8e53f9d5c8c95ee932e7bce /src | |
parent | 8f996f50529272f8a0096508f1a1be3cfef3f3b5 (diff) | |
download | coffeetemp-2f8f76c313633d12e04fc5fd9a4bccf6b856fa2d.tar.gz coffeetemp-2f8f76c313633d12e04fc5fd9a4bccf6b856fa2d.tar.bz2 coffeetemp-2f8f76c313633d12e04fc5fd9a4bccf6b856fa2d.zip |
tempmodule: fix reference voltage.
Diffstat (limited to 'src')
-rw-r--r-- | src/tempmodule/main.ino | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/tempmodule/main.ino b/src/tempmodule/main.ino index 9288deb..d0db8ea 100644 --- a/src/tempmodule/main.ino +++ b/src/tempmodule/main.ino @@ -194,18 +194,21 @@ static void discover_client(void) * Rt: Thermistor resistance * Ra: Voltage divider resistor * Vt: Tap voltage - * Vcc: Input Voltage (3.3V) + * Vcc: Input Voltage (3.31V) * * Rt = Ra * Vcc / Vt - Ra * * Using 64-bit arithmetic as 32-bit would overflow. - * On WeMOS D1 Mini the A0 reads 3.3V as 1023, that is our Vcc. + * On WeMOS D1 Mini the A0 reads 3.2V as 1023; our Vcc is 3.31V + * The correct value of the reference volume obtained by measuring + * resistances with a multimeter, taking the ADC reading and applying + * Ohm's law. * We shift the range by one to avoid division by zero. */ static int get_resistance(int64_t vt, int64_t ra) { ++vt; - return ra * 1024 / vt - ra; + return ra * 1080 / vt - ra; } static int get_temperature(int res) |