Classic Monitoring with a raspberry pi

Started by welmore, October 26, 2017, 12:44:45 AM

Previous topic - Next topic

welmore

Here is an updated "Logging.php" file.

   There are some new comments added.
   The issues with the "Solar_Log.dat" file is fixed.  The old version caused multiple entries each day.
   New code to update and display the "history.txt" file was added.

At the bottom of "Solar_Monitoring_Gauges_plus.php" is the code to ready and display the history information.

<?php
//Display history
$HistoryLog = fopen ($dir."history.txt","r");
for ($a = 0; $a <= 6; $a++){
   $History[$a] = fgetcsv($HistoryLog);
}
fclose($HistoryLog);
echo('<br><table><tr><td ALIGN=Center>Date<td ALIGN=Center>S1 Peak<td ALIGN=Center>S1 kWhr<td ALIGN=Center>S2 Peak<td ALIGN=Center>S2 kWhr');
for ($a = 0; $a <= 6; $a++){
   echo('<TR>');
   $HDay=$History[$a];
   echo('<td ALIGN=Center>'.substr($HDay[0],4,2).'/'.substr($HDay[0],6,2));
        echo('<td ALIGN=Center>'.$HDay[1]);
        echo('<td ALIGN=Center>'.number_format($HDay[2],$decimals=1));
        echo('<td ALIGN=Center>'.$HDay[3]);
        echo('<td ALIGN=Center>'.number_format($HDay[4],$decimals=1));
}
echo('</table>');



?>

Feel free to rearrange as you wish.

The "history.txt" file needs to be in your "Data/" folder there the "current.txt" file is.

The existing history data is from my system.  It will rotate out in 7 days.

Each day, around midnight, the "Logging.php" program will update the "history.txt" file, add a daily record to "Solar_log.dat" and reset the daily highs and lows saved in Dlog_Data
  • .

    Contact me with questions, comments, or suggestions.

    Have a great day

    Others interested, I will supply all required files and instructions on request.

binkino

Thanks Wade, that makes it so complete and perfect now,
have added the code to one of my gauges page and to my Lcars page and now waiting for it collects some days data and then I will see, how I can finetune it on my Lcars page.
(see link below)
If someone want to have the code for one of my pages too, let me know in comment / post here
PV-OUTPUT: http://pvoutput.org/list.jsp?id=38617
Classic Lite 200 + Classic 200 + Easun ISolar-SMX-II-5.6KW + 12x240Wp + 12x255Wp + 2x10kWh LFP
http://a68k.de/Solar/Monitor_LC2.php

Jose Miranda

Hi guys. Is this code being maintained somewhere? Where can I get the latest code?
Jose

Classic 150, Schneider SW4048, Combox, Raspberry Pi 4.

ClassicCrazy

Quote from: Jose Miranda on May 13, 2019, 09:26:09 AM
Hi guys. Is this code being maintained somewhere? Where can I get the latest code?

If using a Pi I would move on to using Node -Red - seems a more powerful tool to use and easier too.
There is a post on Node-Red on forums here.

Larry
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

Steve_S

I'm just catching up on the forum here and saw this and I am very intrigued indeed.   

While I don't mind the software for my C-200 and it's useable, it's just a tad "lacking" shall we say.  Now I don't have a Raspberry but have been pondering getting into them over the last couple of years as I've realized they can be used for many things.  I'd like to be able to setup a Pi that could gather the stats from my C200 and if possible from my new Samlex EVO-4024 Inverter which I could then access from my PC.  Although, I'm not sure of the Samlex capabilities the spec's state the following:
QuoteRJ-45 Jacks for Communication Ports “COMM 1” and “COMM 2” - for rS-485 networking and MODbUS Serial Communication Protocol (for future use)   RJ-45 Jacks for Communication Ports “COM 3” and “COM 4” - for “CANbus” Serial Communication Protocol (for future use)

Other uses for the Pi could be to manage my heat recovery / air exchanger ventilator (fan speeds related to temps) and such.  I know that's beyond the scope of this topic but I'm hoping you would be able to recommend a good Pi bundle (there are so darned many, it's nuts!) that could / would best accommodate me.

Thanks
Steve

ClassicCrazy

You probably want the latest and greatest Raspberry Pi 3 B + model.
If you want to wait a bit there is supposed to be a Raspberry Pi 4 coming out but I don't know details.
As to where to purchase - depends on if you want to get the complete kit with power supply, a case, the sd card, etc or just the board which is abut $35 . Get the kit if you don't have all that other stuff laying around and the case is a good idea.
Lots of places to look for what you get for the money - Amazon, Adafruit, Ebay, Ali Express. Make sure you don't get an old Raspberry Pi 3 model - it has to be 3 B+
https://www.adafruit.com/category/105
Also a good quality SD card makes a big difference


For what you want to do Node Red is the way to go so if you can figure that out you have it made . Lots of tutorials on Node Red - I like Andreas Spiess on Youtube .
here is his latest video but look back at the others
https://youtu.be/z1y6j8-V7J0

Larry

system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

Steve_S

#21
Thanks for the speedy response Classic Crazy.

RE-Edit:

I just purchased the CanaKit Raspberry Pi 3 B+ (B Plus) Starter Kit (32 GB EVO+ Edition, Premium Black Case)
https://www.canakit.com/raspberry-pi/pi-3-model-b-plus-kits

According to Tom's Hardware (which is usually pretty darn on the ball) the Pi 4 won't be out till 2020...
REF https://www.tomshardware.com/news/raspberry-pi-4-everything-we-know,38539.html

Looking forward to getting the package next Friday, hopefully it rains so I can play with it ;-)

ClassicCrazy

Quote from: Steve_S on May 26, 2019, 04:27:46 PM
Thanks for the speedy response Classic Crazy.

RE-Edit:

I just purchased the CanaKit Raspberry Pi 3 B+ (B Plus) Starter Kit (32 GB EVO+ Edition, Premium Black Case)
https://www.canakit.com/raspberry-pi/pi-3-model-b-plus-kits

According to Tom's Hardware (which is usually pretty darn on the ball) the Pi 4 won't be out till 2020...
REF https://www.tomshardware.com/news/raspberry-pi-4-everything-we-know,38539.html

Looking forward to getting the package next Friday, hopefully it rains so I can play with it ;-)
Keep us posted on your project - check out section on here about hooking Classic up for Node Red.

Larry
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

Steve_S

The CanaKit Raspberry Pi 3B+ arrived with all it's goodies.  Amazing little piece of kit I must say, went together in < 5 minutes and was up & running in 10 !  Heck it even drives my LG 47" LED TV (which is what I use for a screen).  Love that I can use a wireless Logitech Keyboard & Mouse without hassle, that's a big saver.

Andreas Spiess on YouTube is amazing, he's my kinda guy for sure... Thank Goodness I have YouTube-DL & the YoutubeDLfronEnd for windows  REF:  https://cresstone.com/apps/youtubeDLFrontEnd/ so I downloaded all his relevant video's (far faster than viewing online and with a Satellite Internet Service, much better to DL and watch at my leisure.  One key issue raised by Andreas is speed & performance with the DB's storing all the logged data to an SD card and that can be worked around.  One Option is to use a USB connected SSD or high performance drives with much more capacity and greater reliability AND you can actually boot from them too with the native OS.

I've been delving into Node Red which certainly looks to be the right tool BUT I'm going farther with this and going to use Grafana & InfluxDB and possibly another bit of software.

You made reference to a possible Pi 4 version coming out.  Well I've been doing more research and asking questions and the Tom's review is correct and it will be a while BUT !  Yep, there is a BUT in there...   Have you looked at Orange Pi ? 

Now they have faster models using a slightly different ARM processor, all Raspberry stuff works on them, fully compatible.  They also have models with a variety of features & functions as well and the pricing is equally as attractive to boot.  One BIG HUGE BONUS is that several models come with 2GB on board plus more and they have some more flexibility for attached devices.   

Check this out:
Orange Pi Plus 2E  @  http://www.orangepi.org/orangepiplus2e/
Orange Pi 3 @ http://www.orangepi.org/Orange%20Pi%203/   (note it has a Quad Core 1.8 Ghz CPU and up to 2GB Ram).

I believe I will be posting in the other thread related to Node-Red and more as that will be more relative to where I am going with this.  Hopefully, I'll be able to connect my Classic & my Samlex Inverter to my software AND if there are some good souls out there with other Inverter/Chargers and Solar Related devices like controllers, they'll share the Modbus info so I can setup a DB with various models of gear...  Time will tell and I'm not in a Rush to do this, it's hobby thing so Bad Weather Days  & "Winter" or when I'm bored (doesn't happen that often).

Have a Marvelous Day everyone.
Steve

ClassicCrazy

Great Steve - looking forward to seeing your contributions on the Node - Red section soon.
I kind of dropped it for the summer now that I am busy with outside stuff.
I have been using a Pi Zero W on all the time that just runs Weewx program that interfaces with my weather station - it just works and is very stable and other than updating Pi stuff now and then I don't mess with it much.
I log into via SSH from my computer and if I want to get into it graphical I can use VNC server for that using my laptop - so don't need any wires going into it - all works via it's wifi link.
One note on the Node - Red - when I first used it I had serial link to the Classic but after I set up my Classics on Follow Me the serial link doesn't work any longer . So I need to now use modbus connection over IP which then limits to one application - like if you use Local Status App then that is the one - you need to disconnect to use Node Red over IP or if you used Grahams Android Classic monitoring app then that would be the only one and you could need to disconnect that . Just keep that in mind if you have problems connecting over IP only one connection at a time .

I never looked at the Orange Pi . As long as it works with same amount of support for Raspberry Pi that is okay.
I have a Pi 3 B+ here that should keep me busy for awhile in addition to the Pi Zero W - I also have another one of those to use with Motion Eye and a video camera that plugs into the pi camera slot .

Lots to do !
Larry
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

smartdave

There seem to be a few code zips in this thread.

Coming late to the party I guess...
Do I need a Full LAMP stack?  Or just Apache and php?

What are the latest version of code that have been written?  I have a classic 200

Thanks

Dave

ClassicCrazy

Quote from: smartdave on June 06, 2019, 01:17:46 AM
There seem to be a few code zips in this thread.

Coming late to the party I guess...
Do I need a Full LAMP stack?  Or just Apache and php?

What are the latest version of code that have been written?  I have a classic 200

Thanks

Dave

I would suggest  checking out  Node Red - it has more capabilities . There is another thread about that .
http://midniteftp.com/forum/index.php?topic=4081.0

Larry
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

Steve_S

Quote from: smartdave on June 06, 2019, 01:17:46 AM
There seem to be a few code zips in this thread.

Coming late to the party I guess...
Do I need a Full LAMP stack?  Or just Apache and php?

What are the latest version of code that have been written?  I have a classic 200

I'm just setting up my new Pi 3B+ for this purpose as well as monitoring a few other things.  I've taken this project a bit further as I am incorporating the following: 

Raspian OS
- Node-Red
- Node-Red Dashboard   https://flows.nodered.org/node/node-red-dashboard
- Node-Red-contrib-modbus 4.1.3  (includes Serial & TCP) https://flows.nodered.org/node/node-red-contrib-modbus
- InfluxDB Time Relational Database  https://www.influxdata.com/
- Node-Red-contrib-influxdb 0.2.2  https://flows.nodered.org/node/node-red-contrib-influxdb
- Grafana Analytics & Monitoring https://grafana.com/

I partitioned & formatted a 240GB SSD Sata Drive and set that as boot device because the DB will be storing a lot of data over time.  This makes my installation slightly different.

After installing everything with a Fresh Rasparian, node-red and the rest, I ran Peter Scargills "the script" and ensured that everything I wanted was selected  and let it update everything (this takes a while).  There were a few errors during that update so after a reboot, I restarted and reran it and all came out 100%.   The Script is GENIUS and strongly suggested.  Here it is:  https://tech.scargill.net/the-script/

There is no need for Apache / Lamp to act as a webserver as Node Red (dev & dashboard), Grafana communicate directly.  InfluxDB is a command-line interface.  IF you wanted to do this without Node-Red there is Modbus for Java & Python that would accommodate using regular webpages as in the other thread but that is IMO a more complicated approach.

This Tutorial / Overview got me started on this particular path.  Have a peek and look at some of his other videos which tie  many things together.  https://www.youtube.com/watch?v=JdV4x925au0&t=3s    Also, there is other YouTube vid's that cover Solar & Node-Red and more... 

I may actually do up an article on setting up a Pi for this purpose including how to setup an SSD or other HDD as the boot device as there is some out of date info that can lead down a wrong path.  Of course that will likely take some time as it's mid busy season now that summer is attempting to start !  (well it seems that way at this moment).

BTW:  I have been playing with the flows posted in here...  some good potential in all of this and room to really expand on.  I will be posting flows as I work my stuff out.

A note to ponder on:  I'm using a combo of Node-Red Dashboard because not only can that be used to present the data in Real Time (system status etc) but it also has facility send setting changes (with extreme caution) to the Modbus device (using the Modbus lib I posted).  The Grafana and InfluxDB is for the longer term view of performance & generation and allowing to generate a nice view that results from eh data collected.   Ultimately, I would like to have my Classic-200, the Samlex 4024 Inverter/Charger and my Weather Station all  plugged into the Pi and collecting data. 

Hope that Helps,  Good Luck.
Steve

ClassicCrazy

That is fantastic Steve . You should start a new topic and copy your last post there . Then if you could share the flow I could try it out sometime since that is easy ( you did most of the work !) .
Thanks for sharing !
Do you think I should ask the moderators to make a new Node Red forum or just keep it on here ? I was putting my Node Red stuff on General opensource since it can be used with Windows and not just Raspberry Pi , although some of the things you are using like Grafana - maybe that only works with Linux ? 

Larry
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

Steve_S

This is a Raspberry Pi Forum so Node-Red falls under that IMO.   BUT that being said, Node-Red IS cross Platform and works on Windows too but I don't know about everything else, I do believe that InfluxDB is also Multi Platform but Grafana ?

I will likely start my own thread series as I like to document a things as I go along.   I'm doing "upgrades" again this evening as I got a new Big Case, Fan (don't like CPU @ 61C) and an RTC clock so it keeps time for itself.

Because of my setup here... having a separate PowerHouse 60 feet from Cabin and having my solar rack even farther away I have to organise a few things up...  I want to be able to run this 7/24 BUT I do not want to have the satellite (I'm remote Sat is my internet etc) which is a power pig, so it will likely be located in the powerhouse & attached to my battery bank through the 12V circuit I have running off it...  I'll just have to find an "adapter" that will step that down to 5V-3A and another for the Router which I think is 4.5V

So far I have my flow talking to the Classic but that needs serious lovin to clean it up and once I have that the way I want, then I'll dashboard it with Node-red.  I really don't see too many issues with the Classic itself and sure am hoping the folks @ MidNite are considering all of this with their new Inverter/Chargers (B17 ?) too. 

My biggest issue at this time, is with Samlex Inc !  Their Inverter has Modbus but they've never released the information on it and are not forthcoming with that.  They are discussing it at Corporate now because I presented a case scenario which would increase their profile in the RE Sector.  Ironically, they have RJ45 connectors but I do not believe they are Ethernet but rather some form of Serial so I'll have to get an engineering type to look at that... maybe I'll have to use an RS485 port or something... ugh....