STM32+EmonLib

Hello dear friends!
I encountered a problem with the use EmonLib STM32F103C8T6 board. Three days I struggle, unsuccessfully. I write code in an environment Arduino Ide.
Indications completely wrong, not even close to similar.
Somebody reworked the library for the STM32? Please share if you have a successful experience.
/*
Я столкнулся с проблемой использования EmonLib с платой STM32F103C8T6. Три дня бьюсь, безуспешно. Код пишу в среде АРДУИНО ИДЕ.
Показания совершенно неверны, даже близко не похожи.
Кто-нибудь переделывал эту библиотеку под STM32? Поделитесь пожалуйста, если у Вас есть успешный опыт.
*/

I do not know the STM, I do not know that anybody has got emonLib working for the STM, but the area to look at first is the scale and the ADC maximum count. All this is inside readVcc( ). You may need to make changes there.

Have you seen the Success using the STM32F103 microcontroller thread?

That thread also links to a Open Energy Monitor thread on the STM32duino forum, both are written by Roger Clark, who is also the maintainer of the STM32duino files for the Arduino IDE’s STM32 support.

Yes, I read your given link, but nothing that would have helped found.
I do not understand where correction values are taken in the case study:

emon1.voltage(2, 234.26, **1.7**); // Voltage: input pin, calibration, phase_(
emon1.current (1, **111.1**); // Current: input pin, calibration.

Tell us, where do these calibration values.

1.7 is a correction for the phase errors of your a.c. adapter and the timing delay between reading voltage and current. The different speed of your STM will mean that 1.7 will be wrong, but I cannot tell you the correct value. You must set a value that gives the correct result when you follow the calibration procedure.
111.1 is the calibration for the current, calculated from knowing the ratio of the current transformer and the value of your burden resistor.
All the details are here: Learn | OpenEnergyMonitor
How many bits is the analogue to digital converter in your STM32F103C8T6 ?

You beat me to it Paul!! :slight_smile:

Simon

Thank you for such a prompt and helpful answers!
This chip has a 12bit ADC.
At least, with your help I got a clear indication from the sensors. Already you can programmatically smooth electromagnetic noise and have the approximate results.:+1: