{"id":5338,"date":"2025-05-26T10:20:12","date_gmt":"2025-05-26T09:20:12","guid":{"rendered":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/?page_id=5338"},"modified":"2025-05-26T10:20:13","modified_gmt":"2025-05-26T09:20:13","slug":"modbus-rtu-meter-integration","status":"publish","type":"page","link":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/?page_id=5338","title":{"rendered":"Modbus RTU Meter Integration"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>Mostly I use M-Bus (Meter-Bus) for interfacing with metering devices but some of the meters I have acquired use Modbus rather than Meter-Bus as the interfacing protocol.<\/p>\n\n\n\n<p>The term &#8220;Modbus&#8221; refers to a range of interfacing standards and protocols, which can lead to some confusion &#8211; in addition to the similarity of the term Modbus to M-Bus.<\/p>\n\n\n\n<p>Modbus is a client-server <em>application-layer<\/em> protocol and can run on top of different physical network technologies. Very often this is RS-485 but it could also be RS-232 or RS-422 and some devices use TCP\/IP to encapsulate Modbus data frames, with Ethernet as the transport layer for TCP\/IP.<\/p>\n\n\n\n<p>When using Modbus over a serial line, there are two alternative ways of encoding the data:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Modbus RTU, which uses a compact binary representation of data fields<\/li>\n\n\n\n<li>Modbus ASCII, which encodes the data as ASCII characters<\/li>\n<\/ul>\n\n\n\n<p>Generally speaking, the term &#8220;Modbus&#8221; is used as shorthand for Modbus RTU over RS-485.<\/p>\n\n\n\n<p>Reading data from a device like an electricity meter which uses Modbus RTU over RS-485 requires:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A computer which can act as the &#8216;client&#8217; to initiate a Modbus query transaction &#8211; something like a Raspberry Pi<\/li>\n\n\n\n<li>Some hardware to help this computer communicate using RS-485 &#8211; something like a USB-to-RS-485 adaptor<\/li>\n\n\n\n<li>Cabling to connect this adaptor to the &#8216;server&#8217; (i.e. the electricity meter)<\/li>\n\n\n\n<li>Software which can send and receive the Modbus protocol<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">RS-485 Cabling<\/h2>\n\n\n\n<p>In normal (half-duplex) RS-485 there are two wires which carry the signal. Often these are labelled &#8216;A&#8217; and &#8216;B&#8217; but sometimes different notation is used:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>D- is a synonym for A<\/li>\n\n\n\n<li>D+ is a synonym for B<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Modbus Software<\/h2>\n\n\n\n<p>For handling the Modbus protocol within Python code, the <a href=\"https:\/\/pymodbus.readthedocs.io\/en\/stable\/index.html\">PyModbus<\/a> library is typically the best option.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Mostly I use M-Bus (Meter-Bus) for interfacing with metering devices but some of the meters I have acquired use Modbus rather than Meter-Bus as the interfacing protocol. The term &#8220;Modbus&#8221; refers to a range of interfacing standards and protocols, &hellip; <a href=\"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/?page_id=5338\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":5856,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5338","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/5338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5338"}],"version-history":[{"count":3,"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/5338\/revisions"}],"predecessor-version":[{"id":5341,"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/5338\/revisions\/5341"}],"up":[{"embeddable":true,"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/5856"}],"wp:attachment":[{"href":"https:\/\/www.marshflattsfarm.org.uk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}