STM32F103RB ADC (pics included) strange values for temperature sensor (LM35)
The mbed AnalogIn read_u16 function scales the ADC value into the full range of a 16 bit value [0 .. 0xffff] so you are mis-scaling the value in your code. Assuming your shown values were using the 3V3 analog reference then 486 * 3300 / 0xffff == 24 which seems to be a factor of 10 out. There seem tohave been some bugs in the Nucleo port of the ADC functions if you look at some of the comments attached to the web page.

EDIT

In your followup you have used the AnalogIn.read() method as a check but this value is a floating point number scaled between 0 and 1.0. To turn this ADC scaled value back into a voltage you have to multiply by the reference voltage in volts.

Here is an example mbed program that I used to read an light-dependent resistor. Provided the voltage is not too low the result returned by the ADC matches closely with my multimeter. Once it gets below 100mV the ADC gets less accurate. I was using a Nucleo-F030 for this so a similar board:

#include &lt;mbed.h&gt;

AnalogIn ldr(PA_0);
Serial serial(SERIAL_TX, SERIAL_RX);

int
main()
{
    serial.baud(115200);
    while (true)
    {
        float adc = ldr.read();
        unsigned short adc_val = ldr.read_u16();
        serial.printf("adc: %f V 16bit: %hu value: %d mV\r\n",
            adc*3.3, adc_val, ((3300 * adc_val) / 0xffff));
        wait_us(1000000);
    }
}


With this I get the following output (where the multimeter reads 1.19V):

adc: 1.167692 16bit: 23173 value: 1166 mV
adc: 1.232161 16bit: 24405 value: 1228 mV
adc: 1.173333 16bit: 23141 value: 1165 mV
adc: 1.231355 16bit: 24405 value: 1228 mV


Schematic of LDR test circuit using Nucleo-F030R8 board.







simulate this circuit &ndash; Schematic created using CircuitLab