{"id":6316,"date":"2017-07-29T13:11:26","date_gmt":"2017-07-29T13:11:26","guid":{"rendered":"http:\/\/60chequersavenue.net\/wordpress\/?p=6316"},"modified":"2017-07-29T23:48:17","modified_gmt":"2017-07-29T23:48:17","slug":"pretty-solar-graphs","status":"publish","type":"post","link":"https:\/\/60chequersavenue.net\/wordpress\/2017\/07\/pretty-solar-graphs\/","title":{"rendered":"Pretty Solar Graphs"},"content":{"rendered":"<p>The first step on my solar progress is to get some graphs done, to get an idea of how much energy I can get from my solar panels on an average day. From this I can work out what I can conceivably run from my setup.<\/p>\n<h2>Background<\/h2>\n<p>Previously, I installed a simple <a href=\"http:\/\/60chequersavenue.net\/wordpress\/2017\/07\/a-bit-of-solar\/\">solar setup<\/a>\u00a0for testing. This is using an EPEver <a href=\"http:\/\/www.epsolarpv.com\/en\/index.php\/Product\/pro_content\/id\/654\/am_id\/136\">Tracer1210A<\/a> solar charge controller, from Tracer. It wasn&#8217;t the cheapest, but it had a lot of good reviews (watch out for cheap copied). The other benefit was the fact it had a serial output that talked modbus, or rs485. Intended for official devices, they do provide the <a href=\"http:\/\/www.solar-elektro.cz\/data\/dokumenty\/1733_modbus_protocol.pdf\">protocol<\/a> to allow third parties to read the system details.<\/p>\n<p>After doing some searching, I discovered <a href=\"https:\/\/github.com\/jaminNZx\">Jamin<\/a> on github who had done some <a href=\"https:\/\/github.com\/jaminNZx\/Tracer-RS485-Modbus-Blynk\">coding and circuit design<\/a> to get the current details from the charge controller and push the results out to a service called <a href=\"http:\/\/www.blynk.cc\/\">Blynk<\/a>.<\/p>\n<h2>My Project<\/h2>\n<h3>Overview<\/h3>\n<p>This project gave me the starting point for what I wanted to do. My idea was to do this:<\/p>\n<p>Controller -&gt; RS485 -&gt; NodeMCU -&gt; MQTT -&gt; OpenHAB -&gt; InfluxDB -&gt; Grafana<\/p>\n<p>A little bit convoluted, I could probably have pushed straight to a database for logging, and do the graphs in grafana. I decided that pushing via <a href=\"http:\/\/mqtt.org\/\">MQTT<\/a> would allow me to integrate the logging into my <a href=\"http:\/\/www.openhab.org\">OpenHAB<\/a> system, which would give me the capability to trigger home automation actions depending on the statistics from the charge controller. For example, it makes it very easy to use OpenHAB to send an email if the battery level gets low, and not only that it could turn off some of the load running off the battery as it gets to different levels.<\/p>\n<h3>Circuit<\/h3>\n<p>The circuit is pretty much a direct copy of what Jamin used, only adapted for a <a href=\"http:\/\/nodemcu.com\/index_en.html\">NodeMCU<\/a> rather than a ESP8266 Mini Dev board.<\/p>\n<div id=\"attachment_6321\" style=\"width: 310px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-6321\" class=\"wp-image-6321 size-medium\" src=\"http:\/\/60chequersavenue.net\/wordpress\/wp-content\/uploads\/2017\/07\/IMG_20170729_140112-300x225.jpg\" alt=\"Bad photo of current system.\" width=\"300\" height=\"225\" srcset=\"https:\/\/60chequersavenue.net\/wordpress\/wp-content\/uploads\/2017\/07\/IMG_20170729_140112-300x225.jpg 300w, https:\/\/60chequersavenue.net\/wordpress\/wp-content\/uploads\/2017\/07\/IMG_20170729_140112-600x450.jpg 600w, https:\/\/60chequersavenue.net\/wordpress\/wp-content\/uploads\/2017\/07\/IMG_20170729_140112-768x576.jpg 768w, https:\/\/60chequersavenue.net\/wordpress\/wp-content\/uploads\/2017\/07\/IMG_20170729_140112-1024x768.jpg 1024w, https:\/\/60chequersavenue.net\/wordpress\/wp-content\/uploads\/2017\/07\/IMG_20170729_140112-400x300.jpg 400w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><p id=\"caption-attachment-6321\" class=\"wp-caption-text\">Prototype of circuit. Ordered a 5110 LCD to add to it, and will neaten it all up then.<\/p><\/div>\n<p>I did look into powering this from the 5V on the serial output of the charge controller, but according to the documentation this can only put out about 50mA of power, which probably won&#8217;t be enough to cover the usage by the NodeMCU.<\/p>\n<h3>Code<\/h3>\n<p>The initial code can be found on my github repository here:<\/p>\n<p>https:\/\/github.com\/dpoulson\/EPSolar<\/p>\n<p>Still a work in progress, but it does the basics so far. Future improvements will allow writing of certain settings, maybe a simple webserver for point in time readings, or an LCD screen.<\/p>\n<h3>Logging<\/h3>\n<p>So the circuit will transmit the readings over wifi to my central MQTT server, running mosquitto. MQTT is just a simple messaging system when you can subscribe to, or publish to, certain queues.<\/p>\n<p>Readings from the charge controller will be published to set queues on the server, which OpenHAB will be subscribed to, with the following items file:<\/p>\n<pre>Number EPSolar_Temp \"Temperature [%.2f \u00b0C]\" { mqtt=\"&lt;[mymosquitto:EPSolar\/1\/ctemp:state:default\" }\r\n\r\nNumber EPSolar_BattVolt \"Battery Voltage [%.2f V]\" { mqtt=\"&lt;[mymosquitto:EPSolar\/1\/bvoltage:state:default\" }\r\nNumber EPSolar_BattRemain \"Battery Remaining [%.2f %]\" { mqtt=\"&lt;[mymosquitto:EPSolar\/1\/bremaining:state:default\" }\r\nNumber EPSolar_BattTemp \"Battery Temp [%.2f \u00b0C]\" { mqtt=\"&lt;[mymosquitto:EPSolar\/1\/btemp:state:default\" }\r\n\r\nNumber EPSolar_LoadPower \"Load Power [%.2f W]\" { mqtt=\"&lt;[mymosquitto:EPSolar\/1\/lpower:state:default\" }\r\nNumber EPSolar_LoadCurrent \"Load Current [%.2f A]\" { mqtt=\"&lt;[mymosquitto:EPSolar\/1\/lcurrent:state:default\" }\r\n\r\nNumber EPSolar_PVVolt \"PV Voltage [%.2f V]\" { mqtt=\"&lt;[mymosquitto:EPSolar\/1\/pvvoltage:state:default\" }\r\nNumber EPSolar_PVCurrent \"PV Current [%.2f A]\" { mqtt=\"&lt;[mymosquitto:EPSolar\/1\/pvcurrent:state:default\" }\r\nNumber EPSolar_PVPower \"PV Power [%.2f W]\" { mqtt=\"&lt;[mymosquitto:EPSolar\/1\/pvpower:state:default\" }\r\n\r\nNumber EPSolar_ChargeCurrent \"Battery Charge Current [%.2f A]\" { mqtt=\"&lt;[mymosquitto:EPSolar\/1\/battChargeCurrent:state:default\" }\r\n\r\nNumber EPSolar_PVVoltMax \"PV Voltage MAX (today) [%.2f V]\" { mqtt=\"&lt;[mymosquitto:EPSolar\/1\/stats_today_pv_volt_max:state:default\" }\r\nNumber EPSolar_PVVoltMin \"PV Voltage MIN (today) [%.2f V]\" { mqtt=\"&lt;[mymosquitto:EPSolar\/1\/stats_today_pv_volt_min:state:default\" }<\/pre>\n<p>My OpenHAB system is configured to store persistence data into an <a href=\"https:\/\/www.influxdata.com\/\">InfluxDB<\/a> server, which is a common setup amongst the OpenHAB community and is <a href=\"https:\/\/community.openhab.org\/t\/influxdb-grafana-persistence-and-graphing\/13761\">well documented<\/a>. This InfluxDB stores historic data on items in OpenHAB, which is searchable by <a href=\"https:\/\/grafana.com\/\">Grafana<\/a>. Grafana gives a nice interface to produce all the pretty solar graphs you might want.<\/p>\n<h2>Solar Graphs<\/h2>\n<div id=\"attachment_6320\" style=\"width: 594px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-6320\" class=\"wp-image-6320 size-large\" src=\"http:\/\/60chequersavenue.net\/wordpress\/wp-content\/uploads\/2017\/07\/Grafana_Solar-1024x506.png\" alt=\"Using Grafana to get some pretty solar graphs\" width=\"584\" height=\"289\" srcset=\"https:\/\/60chequersavenue.net\/wordpress\/wp-content\/uploads\/2017\/07\/Grafana_Solar-1024x506.png 1024w, https:\/\/60chequersavenue.net\/wordpress\/wp-content\/uploads\/2017\/07\/Grafana_Solar-600x296.png 600w, https:\/\/60chequersavenue.net\/wordpress\/wp-content\/uploads\/2017\/07\/Grafana_Solar-300x148.png 300w, https:\/\/60chequersavenue.net\/wordpress\/wp-content\/uploads\/2017\/07\/Grafana_Solar-768x379.png 768w, https:\/\/60chequersavenue.net\/wordpress\/wp-content\/uploads\/2017\/07\/Grafana_Solar-500x247.png 500w, https:\/\/60chequersavenue.net\/wordpress\/wp-content\/uploads\/2017\/07\/Grafana_Solar.png 1911w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><p id=\"caption-attachment-6320\" class=\"wp-caption-text\">Pretty Solar Graphs<\/p><\/div>\n<p>This makes it really easy to see just what is happening, including the charging states as it you can see the switch from bulk to float charge on the battery voltage. This should allow me to make sure the charging is correct for the Lithium Ion batteries I want to eventually connect.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The first step on my solar progress is to get some graphs done, to get an idea of how much energy I can get from my solar panels on an average day. From this I can work out what I can conceivably run from my setup. Background Previously, I installed a simple solar setup&nbsp;for testing. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[178,13,14,48],"tags":[],"class_list":["post-6316","post","type-post","status-publish","format-standard","hentry","category-arduino","category-geek","category-home-automation-2","category-solar-2"],"_links":{"self":[{"href":"https:\/\/60chequersavenue.net\/wordpress\/wp-json\/wp\/v2\/posts\/6316","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/60chequersavenue.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/60chequersavenue.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/60chequersavenue.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/60chequersavenue.net\/wordpress\/wp-json\/wp\/v2\/comments?post=6316"}],"version-history":[{"count":4,"href":"https:\/\/60chequersavenue.net\/wordpress\/wp-json\/wp\/v2\/posts\/6316\/revisions"}],"predecessor-version":[{"id":6322,"href":"https:\/\/60chequersavenue.net\/wordpress\/wp-json\/wp\/v2\/posts\/6316\/revisions\/6322"}],"wp:attachment":[{"href":"https:\/\/60chequersavenue.net\/wordpress\/wp-json\/wp\/v2\/media?parent=6316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/60chequersavenue.net\/wordpress\/wp-json\/wp\/v2\/categories?post=6316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/60chequersavenue.net\/wordpress\/wp-json\/wp\/v2\/tags?post=6316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}