From c56186da8c6cc6be6fd88704e218989e6002b576 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 16 Sep 2019 18:33:05 -0500 Subject: [PATCH] nRF: Change analog reference voltage Datasheet reading explains one reason why readings might have been 10% low. --- ports/nrf/common-hal/analogio/AnalogIn.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/analogio/AnalogIn.c b/ports/nrf/common-hal/analogio/AnalogIn.c index f20802ac98..4fcc65b582 100644 --- a/ports/nrf/common-hal/analogio/AnalogIn.c +++ b/ports/nrf/common-hal/analogio/AnalogIn.c @@ -108,5 +108,9 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) { } float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) { - return 3.3f; + // With internal reference, single ended input (grounded negative + // input), and a gain of 1/6 the input range will be: + // Input range = (0.6 V)/(1/6) = 3.6 V + // The AIN0-AIN7 inputs cannot exceed VDD, or be lower than VSS. (36.8) + return 3.6f; }