{"id":1470,"date":"2021-04-18T15:00:09","date_gmt":"2021-04-18T15:00:09","guid":{"rendered":"https:\/\/open-boat-projects.org\/?page_id=1470"},"modified":"2022-01-19T16:39:07","modified_gmt":"2022-01-19T16:39:07","slug":"wifi-batteriemonitor-in-signalk-integrieren","status":"publish","type":"page","link":"https:\/\/open-boat-projects.org\/en\/wifi-batteriemonitor-in-signalk-integrieren\/","title":{"rendered":"Integrate WiFi battery monitor in SignalK"},"content":{"rendered":"<p><a href=\"https:\/\/open-boat-projects.org\/en\/wichtige-hinweise\/\" target=\"_blank\" rel=\"noopener\"><em><strong>First of all, a few important notes that you should definitely pay attention to.<\/strong><\/em><\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1496\" src=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/PZEM-017_Batteriemonitor-300x266.jpg\" alt=\"\" width=\"400\" height=\"355\" srcset=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/PZEM-017_Batteriemonitor-300x266.jpg 300w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/PZEM-017_Batteriemonitor-768x681.jpg 768w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/PZEM-017_Batteriemonitor-14x12.jpg 14w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/PZEM-017_Batteriemonitor.jpg 839w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<p><strong>Fig:<\/strong> WiFi battery monitor<\/p>\n<p>The <a href=\"https:\/\/open-boat-projects.org\/en\/wifi-batteriemonitor\/\">WiFi battery monitor<\/a> can be integrated into SignalK. The measurement data can then be displayed in the instrument panel. A small detour via MQTT is necessary for integration in SignalK. Since the WiFi battery monitor can also communicate with the Tasmota software via MQTT as standard, we use this interface in conjunction with the SignalK plug-in <em><strong>signal-mqtt-gw<\/strong><\/em> by Teppo Kurki. Basically, we don&#039;t need an MQTT server on the Raspi if we want to use the SignalK plugin. If an MQTT server is running on the Raspi, the port addresses must be changed to avoid conflicts. The SignalK plug-in behaves like an MQTT server and can interpret the telegrams sent, but without error handling and special transaction protection. The following shows how the configuration must be carried out.<\/p>\n<h1>WiFi battery monitor configuration<\/h1>\n<p>Under <em><strong>Configure MQTT <\/strong><\/em>the following settings are made:<\/p>\n<ul>\n<li><strong>Host:<\/strong> IP of the Raspi is running on the SignalK<\/li>\n<li><strong>Port:<\/strong> 1883 (change if an MQTT server should run on the Rapi)<\/li>\n<li><strong>Client:<\/strong> PZEM-017 (name of the device that is displayed as source in MQTT)<\/li>\n<li><strong>Topic:<\/strong> service<\/li>\n<li><strong>Full Topic:<\/strong> battmonitor \/ service<\/li>\n<\/ul>\n<p>Username and password remain unchanged and are not used.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1481 size-full\" src=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Configure_MQTT.png\" alt=\"\" width=\"383\" height=\"733\" srcset=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Configure_MQTT.png 383w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Configure_MQTT-157x300.png 157w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Configure_MQTT-6x12.png 6w\" sizes=\"auto, (max-width: 383px) 100vw, 383px\" \/><\/p>\n<p><strong>Fig:<\/strong> Configure MQTT<\/p>\n<p>Then is still under <em><strong>Configure Other<\/strong><\/em> to check whether MQTT is activated.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1480 size-full\" src=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Configure_Other2.png\" alt=\"\" width=\"378\" height=\"813\" srcset=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Configure_Other2.png 378w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Configure_Other2-139x300.png 139w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Configure_Other2-6x12.png 6w\" sizes=\"auto, (max-width: 378px) 100vw, 378px\" \/><\/p>\n<p><strong>Fig:<\/strong> Configure Other<\/p>\n<p>Under <em><strong>Configure logging<\/strong><\/em> the update rate is set with which the telegrams are to be sent. There is also the parameter <em><strong>Telemetry Period<\/strong><\/em>. The value is given in seconds. 10 can be used as the smallest value. Data transfers faster than 10s are not possible. The measurement data are then displayed in SignalK with this update rate.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1500 size-full\" src=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Configure_Logging.png\" alt=\"\" width=\"391\" height=\"731\" srcset=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Configure_Logging.png 391w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Configure_Logging-160x300.png 160w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Configure_Logging-6x12.png 6w\" sizes=\"auto, (max-width: 391px) 100vw, 391px\" \/><\/p>\n<p><strong>Fig:<\/strong> Configure logging<\/p>\n<p>As a last step, we have to add two special rules to the Tasmota firmware that processes the data telegrams so that they can be used by the SignalK plug-in\u00a0 <em><strong>signal-mqtt-gw<\/strong><\/em> can be processed. Rules are Tasmota firmware extensions with which the behavior of Tasmota can be influenced. If you want to know more about how it works, you can do this here <a href=\"https:\/\/tasmota.github.io\/docs\/Rules\/\" target=\"_blank\" rel=\"noopener\">read in detail<\/a>. The SignalK plug-in for MQTT always expects individual data pairs per telegram with an identifier and a measured value. The identifier corresponds to the data path in SignalK. The data paths should not be chosen arbitrarily and should adhere to the specifications for data paths. Details can be found in the <a href=\"http:\/\/signalk.org\/specification\/1.5.0\/doc\/signalk.pdf\" target=\"_blank\" rel=\"noopener\">SignalK documentation<\/a> in the appendix under appendix A and B. Both rules split the original MQTT telegram into 8 individual MQTT partial telegrams as can also be seen in the logging.<\/p>\n<p><span style=\"font-size: 10pt;\"><code>18:07:37 MQT: battmonitor \/ service \/ SENSOR = {&quot;Time&quot;: &quot;2021-04-18T18: 07: 37&quot;, &quot;ENERGY&quot;: {&quot;TotalStartTime&quot;: &quot;2021-04-09T17: 21:15&quot; , &quot;Total&quot;: 0.122, &quot;Yesterday&quot;: 0.011, &quot;Today&quot;: 0.111, &quot;Period&quot;: 0, &quot;Power&quot;: 6, &quot;Voltage&quot;: 13.03, &quot;Current&quot;: 0.470}, &quot;DS18B20-1&quot;: {&quot;Id&quot;: &quot;3C01D6075272&quot;, &quot;Temperature&quot;: 23.0}, &quot;DS18B20-2&quot;: {&quot;Id&quot;: &quot;3C01D607E5E3&quot;, &quot;Temperature&quot;: 23.3}, &quot;TempUnit&quot;: &quot;C&quot;}<\/code><\/span><\/p>\n<p>Rule1 takes care of the forwarding of the temperature values<\/p>\n<p><span style=\"font-size: 10pt;\"><code>Rule1<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON DS18B20#Temperature DO Var1 %value% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON DS18B20#Temperature DO Add1 273.15 ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON DS18B20-1#Temperature DO Var2 %value% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON DS18B20-1#Temperature DO Add2 273.15 ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON DS18B20-2#Temperature DO Var3 %value% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON DS18B20-2#Temperature DO Add3 273.15 ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON DS18B20-3#Temperature DO Var4 %value% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON DS18B20-3#Temperature DO Add4 273.15 ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON tele-DS18B20 DO publish vessels \/ self \/ environment \/ inside \/ DS18B20_1 \/ temperature %Var1% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON tele-DS18B20-1 DO publish vessels \/ self \/ environment \/ inside \/ DS18B20_1 \/ temperature %Var2% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON tele-DS18B20-2 DO publish vessels \/ self \/ environment \/ inside \/ DS18B20_2 \/ temperature %Var3% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON tele-DS18B20-3 DO publish vessels \/ self \/ environment \/ inside \/ DS18B20_3 \/ temperature %Var4% ENDON<\/code><\/span><\/p>\n<p>The temperature values are read in and converted into Kelvin, since SignalK always expects measured values in SI units.<\/p>\n<div>Rule2 processes the electrical measured values.<\/div>\n<div><\/div>\n<div><span style=\"font-size: 10pt;\"><code>Rule2<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON ENERGY#Power DO Var5 %value% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON ENERGY#Voltage DO Var6 %value% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON ENERGY#Current DO Var7 %value% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON ENERGY#Total DO Var8 %value% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON ENERGY#Yesterday DO Var9 %value% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON ENERGY#Today DO Var10 %value% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON tele-ENERGY DO publish vessels \/ self \/ electrical \/ batteries \/ service \/ power %Var5% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON tele-ENERGY DO publish vessels \/ self \/ electrical \/ batteries \/ service \/ voltage %Var6% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON tele-ENERGY DO publish vessels \/ self \/ electrical \/ batteries \/ service \/ current %Var7% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON tele-ENERGY DO publish vessels \/ self \/ electrical \/ batteries \/ service \/ energytotal %Var8% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON tele-ENERGY DO publish vessels \/ self \/ electrical \/ batteries \/ service \/ energyyesterday %Var9% ENDON<\/code><\/span><br \/>\n<span style=\"font-size: 10pt;\"><code>ON tele-ENERGY DO publish vessels \/ self \/ electrical \/ batteries \/ service \/ energytoday %Var10% ENDON<\/code><\/span><\/div>\n<div><\/div>\n<div>The two rules are entered individually as a complete text string in the console and confirmed with Enter. Then we still have to set the rules with the commands <em><strong>Rule1 ON<\/strong><\/em>\u00a0 and <em><strong>Rule2 ON<\/strong><\/em> activate. The breakdown and the individual telegrams should then be visible in the console.<\/div>\n<div><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1479 size-full\" src=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Console.png\" alt=\"\" width=\"516\" height=\"635\" srcset=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Console.png 516w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Console-244x300.png 244w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Console-10x12.png 10w\" sizes=\"auto, (max-width: 516px) 100vw, 516px\" \/><\/div>\n<div><strong>Fig:<\/strong> Console with individual telegrams for the measured values<\/div>\n<div><\/div>\n<div>Here are some more important commands for rules:<\/div>\n<ul>\n<li><strong><em>RuleX 0<\/em><\/strong> - deactivates a rule<\/li>\n<li><em><strong>RuleX &quot;<\/strong><\/em> - deletes a rule<\/li>\n<li><em><strong>RuleX ON -<\/strong><\/em> activates a rule<\/li>\n<\/ul>\n<h1>Configuration in SignalK<\/h1>\n<p>On the Raspberry Pi you should first check whether an MQTT server like <em><strong>mosquitto<\/strong><\/em> running. The easiest way to do this is in a console with the command <em><strong>Top<\/strong> <\/em>do. It shows a list of all running processes on the Raspi. If the MQTT server is running without being used, then you should use the command <em><strong>sudo apt-get remove mosquitto<\/strong><\/em> deinstall. If it is required, a port other than 1883 must be used in the configuration.<\/p>\n<p>In SignalK the plugin <em><strong>signal-mqtt-gw<\/strong><\/em> under <strong>Appstore -&gt; Available<\/strong> Installed. Under <strong>Server -&gt; Plugin Config<\/strong> the following settings are then made.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1502 size-full\" src=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Plugin_Config.png\" alt=\"\" width=\"526\" height=\"966\" srcset=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Plugin_Config.png 526w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Plugin_Config-163x300.png 163w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Plugin_Config-7x12.png 7w\" sizes=\"auto, (max-width: 526px) 100vw, 526px\" \/><\/p>\n<p><strong>Fig:<\/strong> Plugin Config in SignalK<\/p>\n<p>If everything is configured correctly, SignalK must be restarted. Then the data is in the <strong>Data browser<\/strong> to see.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1503 size-large\" src=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Data_Browser_SignalK-1024x617.png\" alt=\"\" width=\"952\" height=\"574\" srcset=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Data_Browser_SignalK-1024x617.png 1024w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Data_Browser_SignalK-300x181.png 300w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Data_Browser_SignalK-768x463.png 768w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Data_Browser_SignalK-16x10.png 16w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Data_Browser_SignalK.png 1277w\" sizes=\"auto, (max-width: 952px) 100vw, 952px\" \/><\/p>\n<p><strong>Fig:<\/strong> SignalK Data Browser<\/p>\n<p>Depending on the number of connected 1Wire temperature sensors (DS18B20), temperature values are then displayed. If the InfluxDB database and the Grafana database front end are also installed, extensive graphic data evaluations can be carried out.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1518 size-full\" src=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/InstrumentPanael_SignalK-1.png\" alt=\"\" width=\"1007\" height=\"619\" srcset=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/InstrumentPanael_SignalK-1.png 1007w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/InstrumentPanael_SignalK-1-300x184.png 300w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/InstrumentPanael_SignalK-1-768x472.png 768w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/InstrumentPanael_SignalK-1-16x10.png 16w\" sizes=\"auto, (max-width: 1007px) 100vw, 1007px\" \/><\/p>\n<p><strong>Fig:<\/strong> Measurement data in the SignalK instrument panel<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1515 size-large\" src=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Grafana-1003x1024.png\" alt=\"\" width=\"952\" height=\"972\" srcset=\"https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Grafana-1003x1024.png 1003w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Grafana-294x300.png 294w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Grafana-768x784.png 768w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Grafana-12x12.png 12w, https:\/\/open-boat-projects.org\/wp-content\/uploads\/2021\/04\/Grafana.png 1007w\" sizes=\"auto, (max-width: 952px) 100vw, 952px\" \/><\/p>\n<p><strong>Fig:<\/strong> Measurement data visualized with Grafana<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>First, a few important tips that you should definitely observe. Fig: WiFi battery monitor The WiFi battery monitor can be integrated into SignalK. The measurement data can then be displayed in the instrument panel. A small detour via MQTT is required for integration into SignalK. Since the WiFi battery monitor can also communicate with the Tasmota software via MQTT by default, we use this\u2026 <a href=\"https:\/\/open-boat-projects.org\/en\/wifi-batteriemonitor-in-signalk-integrieren\/\" class=\"more-link\">Read more <span class=\"screen-reader-text\">Integrate WiFi battery monitor in SignalK<\/span><\/a><\/p>","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[39],"tags":[],"class_list":["post-1470","page","type-page","status-publish","hentry","category-opensource"],"_links":{"self":[{"href":"https:\/\/open-boat-projects.org\/en\/wp-json\/wp\/v2\/pages\/1470","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/open-boat-projects.org\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/open-boat-projects.org\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/open-boat-projects.org\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/open-boat-projects.org\/en\/wp-json\/wp\/v2\/comments?post=1470"}],"version-history":[{"count":33,"href":"https:\/\/open-boat-projects.org\/en\/wp-json\/wp\/v2\/pages\/1470\/revisions"}],"predecessor-version":[{"id":2644,"href":"https:\/\/open-boat-projects.org\/en\/wp-json\/wp\/v2\/pages\/1470\/revisions\/2644"}],"wp:attachment":[{"href":"https:\/\/open-boat-projects.org\/en\/wp-json\/wp\/v2\/media?parent=1470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/open-boat-projects.org\/en\/wp-json\/wp\/v2\/categories?post=1470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/open-boat-projects.org\/en\/wp-json\/wp\/v2\/tags?post=1470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}