Skip to main content
This topic has been closed for replies.
Best answer by BAl K.1

thank you for your response sir, i solved it by using manual function in this reference (363) PZEM-004T + STM32/Cortex измерение �?нергии + в�?�?кое - YouTube

6 replies

Tesla DeLorean
Guru
December 14, 2022

Your code is going to be different, using a different board and different pins.

Perhaps provide that and how you're wiring this all up so some conclusion about why it is not working can be drawn.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
BAl K.1
BAl K.1Author
Associate III
December 14, 2022

thankyou for your quickc response.

yes i do, i change the uart handle and some other but still dont work. it makes me confused what is the problems

Javier1
Principal
December 14, 2022

provide that and how you're wiring this all up

hit me up in https://www.linkedin.com/in/javiermuñoz/
Javier1
Principal
December 14, 2022

are you trying to programm a stm32f405 with code compiled for stm32f103?

Edit: i read the datasheet and it doesnt say anything about what Uart configurations are needed.

But looking at the github progect you shared , they are using huart2 to interface this sensor.

And these are the uart configurations you need:

static void MX_USART2_UART_Init(void)
{
 
 /* USER CODE BEGIN USART2_Init 0 */
 
 /* USER CODE END USART2_Init 0 */
 
 /* USER CODE BEGIN USART2_Init 1 */
 
 /* USER CODE END USART2_Init 1 */
 huart2.Instance = USART2;
 huart2.Init.BaudRate = 9600;
 huart2.Init.WordLength = UART_WORDLENGTH_8B;
 huart2.Init.StopBits = UART_STOPBITS_1;
 huart2.Init.Parity = UART_PARITY_NONE;
 huart2.Init.Mode = UART_MODE_TX_RX;
 huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
 huart2.Init.OverSampling = UART_OVERSAMPLING_16;
 if (HAL_UART_Init(&huart2) != HAL_OK)
 {
 Error_Handler();
 }
 /* USER CODE BEGIN USART2_Init 2 */
 
 /* USER CODE END USART2_Init 2 */
 
}

just take any tutorial and staert from there

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=video&cd=&cad=rja&uact=8&ved=2ahUKEwiDqMDo1vj7AhVFTaQEHcPMAzQQtwJ6BAgJEAI&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dl5msGz2tZP0&usg=AOvVaw0T0AcJVZ4WIco1h8sbOXQr

hit me up in https://www.linkedin.com/in/javiermuñoz/
BAl K.1
BAl K.1AuthorBest answer
Associate III
December 16, 2022

thank you for your response sir, i solved it by using manual function in this reference (363) PZEM-004T + STM32/Cortex измерение �?нергии + в�?�?кое - YouTube

Javier1
Principal
December 16, 2022

tick yourself as best answer then

hit me up in https://www.linkedin.com/in/javiermuñoz/