1.. zephyr:code-sample:: modbus-rtu-client 2 :name: Modbus RTU client 3 :relevant-api: modbus 4 5 Communicate with a Modbus RTU server. 6 7Overview 8******** 9 10This is a simple application demonstrating a Modbus RTU client implementation 11in Zephyr RTOS. 12 13Requirements 14************ 15 16This sample has been tested with the nRF52840-DK and FRDM-K64F boards, 17but it should work with any board that has a free UART interface. 18 19RTU client example is running on an evaluation board and communicates 20with another board running the :zephyr:code-sample:`modbus-rtu-server` sample. 21 22In addition to the evaluation board a RS-485 shield may be used. 23The shield converts UART TX, RX signals to RS-485. 24An Arduino header compatible shield like `joy-it RS-485 shield for Arduino`_ 25can be used. This example uses DE signal, which is controlled by pin D9 26on the JOY-IT shield. For other shields, ``de-gpios`` property must be adapted 27or removed in the application overlay file 28:zephyr_file:`samples/subsys/modbus/rtu_client/app.overlay` 29 30The A+, B- lines of the RS-485 shields should be connected together. 31 32Alternatively UART RX,TX signals of two boards can be connected crosswise. 33 34Building and Running 35******************** 36 37This sample can be found under 38:zephyr_file:`samples/subsys/modbus/rtu_client` in the Zephyr tree. 39 40The following commands build and flash RTU client sample. 41 42.. zephyr-app-commands:: 43 :zephyr-app: samples/subsys/modbus/rtu_client 44 :board: frdm_k64f 45 :goals: build flash 46 :compact: 47 48The example communicates with the RTU server and lets the LEDs light up 49one after the other. 50 51.. code-block:: console 52 53 *** Booting Zephyr OS build zephyr-v2.3.0-1993-g07e8d80ae028 *** 54 [00:00:00.005,000] <inf> mb_rtu: RTU timeout 2005 us 55 [00:00:00.050,000] <inf> mbc_sample: WR|RD holding register: 56 48 00 65 00 6c 00 6c 00 6f 00 00 00 00 00 00 00 |H.e.l.l. o....... 57 [00:00:00.062,000] <inf> mbc_sample: Coils state 0x00 58 [00:00:00.864,000] <inf> mbc_sample: Coils state 0x07 59 60 61.. _`joy-it RS-485 shield for Arduino`: https://joy-it.net/en/products/ARD-RS485 62