cancel
Showing results for 
Search instead for 
Did you mean: 

HOW TO READ UART FROM PZEM 004T

BAl K.1
Associate III

I need help with using pzem 004t in stm32f405 with uart communication. i have check this source willyvamp/STM32F103C8T6-PZEM004T-DHT11: HAL STM32 (github.com) but still dont get the data form uart. please help

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

6 REPLIES 6

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
Up vote any posts that you find helpful, it shows what's working..
BAl K.1
Associate III

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

provide that and how you're wiring this all up

we dont need to firmware by ourselves, lets talk
Javier1
Principal

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

we dont need to firmware by ourselves, lets talk

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

tick yourself as best answer then

we dont need to firmware by ourselves, lets talk