Skip to main content
Home
for DLMS smart meters

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Connecting To An Energy Meter With STM32F4 and STM32CubeIde

Connecting to an energy meter with STM32F4 and STM32CubeIde

By FabianoH, 22 October, 2024
Forums
General discussion

Hi

How do I define the serial port that I will use on the STM32CubeIDE to connect to a power meter with an optical probe?

This is my code and I have two usb serial ports:

/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_USART1_UART_Init();

/* USER CODE BEGIN 2 */

GXTRACE_INT(GET_STR_FROM_EEPROM("Start application"), NULL);
BYTE_BUFFER_INIT(&frameData);
//Set frame capacity.
bb_capacity(&frameData, 128);
Client.init(true, 16, 1, DLMS_AUTHENTICATION_HIGH_GMAC, NULL, DLMS_INTERFACE_TYPE_HDLC_WITH_MODE_E);
//Un-comment this if you want to set system title, block cipher key or authentication key.

Client.SetSecurity(DLMS_SECURITY_AUTHENTICATION_ENCRYPTION);
//TODO: Change logical name of the frame counter if it's used to com_readAllObjects.
gxByteBuffer bb;
bb_init(&bb);
bb_addHexString(&bb, GET_STR_FROM_EEPROM("1234560005000001"));
Client.SetSystemTitle(&bb);
bb_clear(&bb);
bb_addHexString(&bb, GET_STR_FROM_EEPROM("00 00 63 65 6C 31 32 33 34 35 36 37 38 39 00 00"));
Client.SetAuthenticationKey(&bb);
bb_clear(&bb);
bb_addHexString(&bb, GET_STR_FROM_EEPROM("00 00 63 65 6C 31 32 33 34 35 36 37 38 39 00 00"));
Client.SetBlockCipherKey(&bb);
bb_clear(&bb);

Thanks
Fabiano

Profile picture for user Kurumi

Kurumi

7 months 2 weeks ago

Hi Fabiano, You need to…

Hi Fabiano,

You need to implement UART reading and writing. CHeck MX_USART2_UART_Init. It will describe what PINs you should use.

BR,
Mikko

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Wed, 06/04/2025 - 13:35
    gurux.dlms.c 9.0.2506.0401
  • Fri, 05/30/2025 - 08:30
    gurux.dlms.c 9.0.2505.3001
  • Tue, 05/27/2025 - 08:10
    Gurux.Serial.Android 2.0.12
  • Mon, 05/26/2025 - 08:39
    gurux.dlms.c 9.0.2505.2601
  • Tue, 05/20/2025 - 08:40
    gurux.dlms.c 9.0.2505.2001

New forum topics

  • Create gateway protocol in c
  • Error while reading event log object
  • GXDLMS Simulator – AssociationLogicalName Not Listed
  • Failed to read meter through raspberry pi 5 and probe
  • Protocol Version in AARQ Packet
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin