Unable to set_reference_voltage on AnalogIn on xdot (or in Mbed)

I am attempting to implement an analog input port to read the battery voltage. My design requires that I set the reference voltage (to something other than Vdd).

The code to do this should look like

#include "mbed.h"
AnalogIn VCC_monitor(GPIO0); // input to read VCC state via a resistor divider network

int main () {
VCC_monitor.set_reference_voltage(3.1);  // set the reference here (but this function is not in the library) // <-- this line will not compile

// do something to read the voltage etc. e.g.

float volts = VCC_monitor.read();  // a line like this works ok


I am using the mbed online compiler, I believe I am running mbed o/s 6.2.0 (target is a Multitech xdot)

It does not compile because set_voltage_reference does not exist.

When I look at analogIn.h I can see that AnalogIn::set_reference_voltage() does not exist in the library.


When I look at 5.x versions of mbed o/s it looks like the class in those versions did not have set_voltage_reference(). So how was the reference voltage set previously?

Please advise any suggestions as to how to locate the required function. I have been through the reference documentation and searched to no avail.

I think I found an answer of sorts here. It’s all still a bit vague (gee some clear documentation would save me so many hours of wasted time…) but it looks like on the Multitech mDot platform the reference voltage is fixed at 3 Volts and the max input voltage is 3V not 3.3V (looks like that nugget of information has caught a few others unawares as well) and it seems to be implied that in cannot be programmatically set (hence the absence of said function to set the reference voltage). I can only presume it is the same for the xDot.