{"id":5097,"date":"2023-09-30T09:50:07","date_gmt":"2023-09-30T07:50:07","guid":{"rendered":"https:\/\/www.sigalou-domotique.fr\/?p=5097"},"modified":"2026-01-02T16:57:13","modified_gmt":"2026-01-02T14:57:13","slug":"jintegre-le-power-boost-em112-de-chez-carlo-gavazzi-dans-home-assistant-via-le-port-rd485-modbus","status":"publish","type":"post","link":"https:\/\/www.sigalou-domotique.fr\/en\/jintegre-le-power-boost-em112-de-chez-carlo-gavazzi-dans-home-assistant-via-le-port-rd485-modbus","title":{"rendered":"I integrate the Power Boost EM112 from Carlo Gavazzi into Home Assistant via RS485 (Modbus)"},"content":{"rendered":"<h3>Important information<\/h3>\r\n<blockquote>\r\n<p>Note that the integration described below can only work if the USB\/RS485 stick is the only equipment on the RS485 bus connected to the EM112. Indeed (and with the help of Eric G.) I understood that there could only be<strong>a single master equipment on the bus<\/strong>. The master is the one who questions and the slave the one who answers. EM112 is therefore a slave.<\/p>\r\n<p>My first idea was to sniff out the lines of dialogue between EM112 and my Wallbox, the Wallbox being the master, I cannot do that. For the beauty of the exercise, I tested with two masters, it works we find values but from time to time, when the two masters ask a question together, we find ourselves with an error.<\/p>\r\n<p><strong>If someone can point me towards a way of \u2018snipping\u2019 bus 485 to intercept the information that the EM112 sends to a Wallbox, for example, I am a taker because at this stage I cannot have a Wallbox and a RS485\/USB Key in parallel (two masters).<\/strong><\/p>\r\n<\/blockquote>\r\n<p><!--more--><\/p>\r\n<h3>&nbsp;Equipment used and drivers<\/h3>\r\n<p>The most expensive piece of equipment in my entire painting (\u20ac1.33 on <a href=\"https:\/\/s.click.aliexpress.com\/e\/_Dmm7Ncx\" target=\"_blank\" rel=\"noopener\">Ali<\/a> \ud83d\ude02), it works, obviously there are fake keys, I may have been lucky but this seller is serious.<\/p>\r\n<ul>\r\n<li><a href=\"https:\/\/s.click.aliexpress.com\/e\/_Dmm7Ncx\" target=\"_blank\" rel=\"noopener\">USB\/RS485 key<\/a><\/li>\r\n<\/ul>\r\n<p><a href=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5133\" src=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485.png\" alt=\"\" width=\"272\" height=\"236\"><\/a><\/p>\r\n<p>Of course, as soon as I received it, I opened it to find a reference. <strong>YYH-256<\/strong><\/p>\r\n<p><a href=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5134\" src=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-3.png\" alt=\"\" width=\"468\" height=\"140\" srcset=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-3.png 468w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-3-300x90.png 300w\" sizes=\"auto, (max-width: 468px) 100vw, 468px\" \/><\/a> <a href=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5135\" src=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-2.png\" alt=\"\" width=\"421\" height=\"300\" srcset=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-2.png 421w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-2-300x214.png 300w\" sizes=\"auto, (max-width: 421px) 100vw, 421px\" \/><\/a><\/p>\r\n<p>Searching the forums reveals that it is (probably) a fork of <strong>CH341<\/strong> The drivers of the latter are even used.<\/p>\r\n<p>It should be noted that my driver searches were useless since the key is natively recognised on the RaspberryPi4\/HAOS I use.<\/p>\r\n<p>I post here this diagram that gives the circuits used, note that quartz has disappeared, it is not an oversight at welding, it is an evolution of the key (a component won, it is a component won).<\/p>\r\n<p><a href=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/images.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5136\" src=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/images.jpg\" alt=\"\" width=\"343\" height=\"147\" srcset=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/images.jpg 343w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/images-300x129.jpg 300w\" sizes=\"auto, (max-width: 343px) 100vw, 343px\" \/><\/a><\/p>\r\n<p>&nbsp;<\/p>\r\n\r\n\r\n\r\n<h3>I connect the USB key to the RS485 port<\/h3>\r\n<p>The key has two connectors D+ and D-, just connect them to the pins B+(4) and A-(5) of the EM112<\/p>\r\n<p><a href=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5150\" src=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-8.png\" alt=\"\" width=\"333\" height=\"238\" srcset=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-8.png 333w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-8-300x214.png 300w\" sizes=\"auto, (max-width: 333px) 100vw, 333px\" \/><\/a><\/p>\r\n<h3>I connect the key to the USB port of the Raspi4<\/h3>\r\n<p>I immediately test the order\u00a0 <strong>lsusb<\/strong> on the command line and I see that when the new key is plugged in, I have one more line, it is a pretty good sign.<\/p>\r\n<p>I pass the problems of ports \/dev\/ttyUSB0 and \/dev\/ttyUSB1 which change with each start-up, I have solved and documented the solution on:<\/p>\r\n<ul>\r\n<li><a href=\"https:\/\/www.sigalou-domotique.fr\/en\/fixer-les-ports-usb-d-un-raspberry\/\" target=\"_blank\" rel=\"noopener\">Attach USB ports to a Raspberry<\/a><\/li>\r\n<\/ul>\r\n<p><a href=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2019\/09\/b7b14ba75628093cb044d04b31c57196d5303e5d.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5125\" src=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2019\/09\/b7b14ba75628093cb044d04b31c57196d5303e5d.png\" alt=\"\" width=\"1073\" height=\"71\" srcset=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2019\/09\/b7b14ba75628093cb044d04b31c57196d5303e5d.png 1073w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2019\/09\/b7b14ba75628093cb044d04b31c57196d5303e5d-600x40.png 600w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2019\/09\/b7b14ba75628093cb044d04b31c57196d5303e5d-300x20.png 300w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2019\/09\/b7b14ba75628093cb044d04b31c57196d5303e5d-1024x68.png 1024w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2019\/09\/b7b14ba75628093cb044d04b31c57196d5303e5d-768x51.png 768w\" sizes=\"auto, (max-width: 1073px) 100vw, 1073px\" \/><\/a><\/p>\r\n<p>I note that I will use the port <span class=\"enlighter-text\">\/dev\/serial\/by-id\/usb-1a86_USB2.<\/span><span class=\"enlighter-n1\">0<\/span><span class=\"enlighter-text\">-Ser_-if00-port0 to connect to this key.<\/span><\/p>\r\n<h3>I configure the Modbus integration which is natively in HA<\/h3>\r\n<p><a href=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/modbus.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5137\" src=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/modbus.png\" alt=\"\" width=\"476\" height=\"156\" srcset=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/modbus.png 476w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/modbus-300x98.png 300w\" sizes=\"auto, (max-width: 476px) 100vw, 476px\" \/><\/a><\/p>\r\n<p><a href=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5138\" src=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-4.png\" alt=\"\" width=\"315\" height=\"53\" srcset=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-4.png 315w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-4-300x50.png 300w\" sizes=\"auto, (max-width: 315px) 100vw, 315px\" \/><\/a><\/p>\r\n<p>In my configuration file, I add the modbus line: !include modbus.yaml<\/p>\r\n<p>And in modbus.yaml, I declare the key<\/p>\r\n<p><a href=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5139\" src=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-5.png\" alt=\"\" width=\"533\" height=\"246\" srcset=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-5.png 533w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-5-300x138.png 300w\" sizes=\"auto, (max-width: 533px) 100vw, 533px\" \/><\/a><\/p>\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\">- name: modbus _hub type: serial #port: \/dev\/ttyUSB1 port: \/dev\/serial\/by-id\/usb-1a86_USB2.0-Ser_-if00-port0 baudrate: 9600 bytesize: 8 method: rtu parity: N stopbits: 1 retries: 5 close_comm_on_error: false delay: 5 timeout: 2 _wait _milliseconds message: 1000<\/pre>\r\n<h3>I declare each sensor\u00a0<\/h3>\r\n<p>From there, I immerse myself in the <a href=\"https:\/\/gavazzi.se\/app\/uploads\/2020\/11\/em111_em112_m1_cp.pdf\" target=\"_blank\" rel=\"noopener\">Gavazzi Documentation<\/a> and I will look for the lines that interest me:<\/p>\r\n<p><a href=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5142\" src=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-6.png\" alt=\"\" width=\"677\" height=\"145\" srcset=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-6.png 677w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-6-600x129.png 600w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-6-300x64.png 300w\" sizes=\"auto, (max-width: 677px) 100vw, 677px\" \/><\/a><\/p>\r\n<p>To have the address of each sensor, I convert the addresses into hexa to decimal and then I declare the 4 sensors in modbus.yaml:<\/p>\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\">sensors: - name: EM112_W unit_of_measurement: W state_class: measurement device_class: energy slave: 1 address: 4 data_type: int32 input_type: input precision: 0 scale: 0.1 scan_interval: 10 lazy _error _count: 999 swap: word - name: EM112_A unit_of_measurement: A state_class: measurement device_class: current Slavic: 1 address: 2 data_type: int32 input_type: input precision: 0 scale: 0.001 scan_interval: 10 lazy _error _count: 999 swap: word - name: EM112_VA unit_of_measurement: VA state_class: measurement device_class: energy slave: 1 address: 6 data_type: int32 input_type: input precision: 0 scale: 0.1 scan_interval: 10 lazy _error _count: 999 swap: word - name: EM112_kwh unit_of_measurement: kwh state _class: total_increasing device_class: energy slave: 1 address: 16 data_type: int32 input_type: input precision: 0 scale: 0.1 scan_interval: 10 lazy _error _count: 999 swap: word<\/pre>\r\n<h3>I check the result<\/h3>\r\n<p><a href=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5145\" src=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-7.png\" alt=\"\" width=\"725\" height=\"304\" srcset=\"https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-7.png 725w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-7-600x252.png 600w, https:\/\/www.sigalou-domotique.fr\/wp-content\/uploads\/2023\/09\/rs485-7-300x126.png 300w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/a><\/p>\r\n<p>Perfect! It only remains to play to make a pretty \u2026 card<\/p>\r\n<h3>Reminder<\/h3>\r\n<p>Do not put a Wallbox in parallel production<\/p>\r\n<p><strong>If someone can point me towards a way of \u2018snipping\u2019 bus 485 to intercept the information that the EM112 sends to a Wallbox, for example, I am a taker because at this stage I cannot have a Wallbox and a RS485\/USB Key in parallel (two masters).<\/strong><\/p>\r\n<h3>Bibliography, References<\/h3>\r\n<ul>\r\n<li><a href=\"https:\/\/www.home-assistant.io\/integrations\/modbus\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.home-assistant.io\/integrations\/modbus\/<\/a><\/li>\r\n<li><a href=\"https:\/\/gavazzi.se\/app\/uploads\/2020\/11\/em111_em112_m1_cp.pdf\" target=\"_blank\" rel=\"noopener\">https:\/\/gavazzi.se\/app\/uploads\/2020\/11\/em111_em112_m1_cp.pdf<\/a><\/li>\r\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Important information Note that the integration described below can only work if the USB\/RS485 stick is the only equipment on the RS485 bus connected to the EM112. Indeed (and with the help of Eric G.) I understood that there could only be one master equipment on the bus. But the master is the one who questions [\u2026]<\/p>","protected":false},"author":1,"featured_media":5099,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[14,53,166],"tags":[81,67],"class_list":["post-5097","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-domotique","category-home-assistant","category-retex","tag-developpement","tag-wallbox"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/posts\/5097","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/comments?post=5097"}],"version-history":[{"count":0,"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/posts\/5097\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/media\/5099"}],"wp:attachment":[{"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/media?parent=5097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/categories?post=5097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sigalou-domotique.fr\/en\/wp-json\/wp\/v2\/tags?post=5097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}