Skip to main content
Visitor II
February 26, 2021
Question

How to implement MODBUS protocol communication using UART in STM32L151RCT6 MCU

  • February 26, 2021
  • 4 replies
  • 11932 views

Hi,

I am using the STM32L151RCT6 in STM32cube IDE, i need to create MODBUS protocol communication between MCU and other board as slave..

Please suggest me any related link for implement this..

it will be helpful for me...

    This topic has been closed for replies.

    4 replies

    Visitor II
    February 26, 2021

    A pretty good implementation of the modbas protocol can be found here: https://github.com/Jacajack/liblightmodbus

    Here's the documentation for it: https://jacajack.github.io/liblightmodbus/

    MBhir.11Author
    Visitor II
    March 31, 2021

    Hi,

    I need to configure the RTU MODBUS Slave with RS485 communication in my application.

    I referred the below link for implementation :

    https://github.com/srikanth977/ModbusRTUSlave_RS232

    I got example codes and tried to implement one example .

    But in this examples he is passing the 16 bit unsigned integer from slave, i need to pass 32 bit integer and float also.

    How it is possible to pass the 32 bit integer and float values from the MODBUS slave??

    please help me to resolve this....

    Visitor II
    March 31, 2021

    In my opinion, the only possible solution is to divide the 32 bit integer value into two 16 bit ones and store them in separate registers of slave device, keeping in mind where the low and high word is. When reading by the master, both 16 bit words should be combined into one 32 bit value.

    The same approach should be applied to float values.

    MBhir.11Author
    Visitor II
    March 31, 2021

    OK thanks for reply.

    I will try and tell you about that.

    One more thing i have requirement of upgrading firmware through MODBUS..

    It is like Slave device firmware i need to upgrade through MODBUS.

    Is there any related link ??

    please suggest me any links or examples on this..

    Explorer
    March 31, 2021

    Modbus has no device update capability.

    This requirement is uneasonable.

    Visitor II
    March 31, 2021

    Unfortunately, I don't know of any solution to this problem.

    MBhir.11Author
    Visitor II
    March 31, 2021

    Ok fine .

    Can you suggest me how to achieve?

    function code 06(Write single) and function code 16(Write Multiple) .

    From this i may achieve my requirement..

    Visitor II
    March 31, 2021

    These features are available in the implementation I indicated earlier.

    Visitor II
    January 27, 2024

    basically my sensor is 7  in 1 soil sensor to read the sensor data i am using the rs485 so at first i used to arduino it was worked so i need some support for interfacing the sensor for the stm32 b-l475e-iot01a ,where the sensor working on the modbus portocol