2025-07-09 7:35 AM - last edited on 2025-07-09 8:16 AM by Andrew Neil
My voltage sensor output shows 0v when actually the load is 222v. Please help me with the code logic.
My current sensor ACS712 30A works well, but voltage sensor ZMPT101B is not showing correct results
2025-07-09 8:15 AM
Welcome to the forum.
You need to supply some more details - please see How to write your question to maximize your chances to find a solution for best results; in particular
@LimitsBreaker wrote:My current sensor ACS712 30A
You mean this: https://www.allegromicro.com/en/products/sense/current-sensor-ics/zero-to-fifty-amp-integrated-conductor-sensor-ics/acs712 ?
@LimitsBreaker wrote:voltage sensor ZMPT101B
This: https://kunkune.co.uk/shop/arduino-sensors/ac-voltage-sensor-module-zmpt101b-240v/ ?
Have you tested that you are actually getting the expected signal from your sensor at the STM32's ADC input pin?
That page says that the output is, "Sine Wave Output: The module outputs a sine wave signal, with the waveform median being a DC component" - have you allowed for that?
It also says, "Supply Voltage: Operates efficiently within a range of 5-30V" - but STM32s are 3V. So how gave you allowed for that?
These show why we need to see your schematic!
Some good, clear photos could also help.
2025-07-09 9:35 AM - edited 2025-07-09 9:42 AM
I am using STM32F401CCU6 (Black pill development board)
I have attached the schematic diagram below.
The current sensor i am using is ACS712 30A, the datasheet link is here - ACS712 pdf, ACS712 Description, ACS712 Datasheet, ACS712 view ::: ALLDATASHEET :::
The voltage sensor is ZMPT101B, the datasheet link is here - ZMPT101B Datasheet(PDF) - Qingxian Zeming Langxi Electronic Devices
Yeah i am getting 1.25v adc input voltage in both the pins which is caused by the voltage divider scaling down 2.50v output to 1.25v i.e adc range(0-3.3v).
ACS712 30A gives 2.50V output at 0A which is the reference voltage, on load, it shows 2A on LCD screen when i connected an electronic appliance for testing which assures current sensor is working as expected.
But, I am not able to clear my doubt over the working logic of voltage sensor, it also gives 2.50V OUT at no load,
but on load also it shows output as 0V. Could you please help me with the logic issues.
I will share the screenshots of debugging results shortly.
2025-07-09 9:53 AM
@LimitsBreaker wrote:I am not able to clear my doubt over the working logic of voltage sensor,.
You really need to do that before you can start coding anything!
The operation of the sensor has nothing to do with the STM32.
The sensor is not an ST product, so you'll need to go to the manufacturer for support with it.
@LimitsBreaker wrote:it also gives 2.50V OUT at no load,
How, exactly, are you measuring that?
Again, the datasheet states that it is an Sinewave output - so not just a steady voltage.
You'll need a oscilloscope to see what it's giving ...
2025-07-09 10:18 AM
okay I will look into the working logic of the sensor.
I used a multimeter to test its out, Sorry I forgot about the sinewave output, looks like the output swings centered at 2.5v
Feature Description
Output waveform | Sine wave centered at VCC/2 |
Yeah, now I could understand, since stm32 adc cannot read negative values, the sensor output ac sine wave is scaled and shifted to swing around 2.5 which means
For example:
230V AC input → ~1.5V peak-to-peak waveform at output
Thanks for the clarification!
Please help me with another doubt, should I use continuous conversion mode for adc input sampling, or by simply using timer interrupt. Which one should I use for simultaneous sampling of two adc inputs.