2024-09-16 03:17 AM
The is voltage sensing in live expression I'm using STM32F103C8T6 board popularly known as blue pill im using a voltage divider the supply is given from the power supply and the ADC pin i use is B1 from the power supply when i give less than 2V the output in the live expression is accurate but when i give more than 2V and less than 3.3V it is not correct and for example if i give 3.3V in the live expression the output shows is 5.1345V how to resolve this problem any ideas gentlemen's
2024-09-16 03:27 AM
Note that the chances of a Blue Pill containing a genuine STM32 are vanishingly small.
It's quite possible that a fake STM32 could have weird ADC behaviour.
The first thing to determine is whether the issue is just with the IDE and its live expression display, or in your code.
So what happens if you send your result out through a UART to a terminal?
If you see the same error doing that, then the problem is in your code.
Have you looked at the raw values from the ADC?
2024-09-16 04:30 AM
Yes i have gone through the raw value of the ADC it correct
here is my program is there any correction
2024-09-16 03:38 PM
Are you sure the 8.56 is the correct factor? What is your voltage divider R1 and R2? What is the max input voltage to the divider?
try
voltage =(float)readValue * (3.3/4096) * 8.56; // assuming Vref = 3.3V