Skip to main content
Visitor II
November 28, 2021
Question

STM32f103c8T6 inaccurate ADC readings

  • November 28, 2021
  • 2 replies
  • 1213 views

Hello, I'm using stm32f103c8t6 board and trying to get simple voltage divider readings. I'm also using multimeter to measure voltage and well I'm getting 0.2 sometimes 0.4 V error. Is this normal? I really need precision, 0.2 or 0,4 volts are really to much for me. I'm using regular conversion on 1 channel every 10 seconds with maximum 239.5 cycles sampling time. This is the code I use (yes I try to calibrate it and that doesn't work)

HAL_ADCEx_Calibration_Start(&hadc1);

HAL_Delay(10);

HAL_ADC_Start(&hadc1);

HAL_ADC_PollForConversion(&hadc1,100);

ADC_VAL=HAL_ADC_GetValue(&hadc1);

HAL_ADC_Stop(&hadc1);

voltage=ADC_VAL*3.3/4096;

#[STM32 MCUs]​ #ADC​ #STM32F1​ 

    This topic has been closed for replies.

    2 replies

    Super User
    November 28, 2021

    Multimeters take their reading by long term averaging. Perhaps the signal you're reading is oscillating.

    DSimp.1Author
    Visitor II
    November 28, 2021

    nope, I'm trying to measure Li-ion cell's voltage through voltage divider and it should be around 2.7 volts I get 2.4-2.8 volts and sometimes 3.2 volts for no reason. Are stm32f1's ADC really so inaccurate ? Maybe the problem is that I bought this mcu on alliexpress, so maybe it's faulty or something like that?

    Explorer
    November 24, 2024

    Have the same problem.

    Caps have no effect to stabilize voltage reading so only conclusion is that AD is inaccurate.

    To make it worse, even after I average the reading by software and use a calibration factor the average float over time.

    Back to PIC?

    #Actual Voltage = 3.1V

    Vout(0) = 329
    Vout(1) = 330
    Vout(2) = 329
    Vout(3) = 329
    Vout(4) = 329
    Vout(5) = 332
    Vout(6) = 328
    Vout(7) = 328
    Vout(8) = 329
    Vout(Max) = 332
    Vout(Min) = 328
    Delta = 4
    Vout(Average) = 329.00
    Vpin = 0.266V