Classic Monitoring with a raspberry pi

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

Previous topic - Next topic

welmore

Greeting.  I have been working with Binkino on a web based Classic monitoring project.
It works with a raspberry pi that reads the Classics and provided a web based display.
This project assumes two Classics with a Wizbang jr attached to Classic #1.
You will need a raspberrypi loaded with Apache and PHP.
The attached zip file has all the files you will need.
Unzip the file into a folder named "Solar" in your host root folder.  Mine is "/var/www".
In the Solar folder, create a folder named "Data".
Open the permissions on the Data folder.
In "Logging.php" edit;
$Solar1="192.168.0.121" for your Classic #1 IP address. 
$Solar2="192.168.0.122" for your Classic #2 IP address.

On the pi, open a browser and start "IP address of your pi /Solar/Logging.php".
If youget error messages and the data is mostly zeros, you are not connecting to the Classics.
Keep this running.
It will create a "current.txt" file in the Data folder.  This file is the most recent data from the Classics and is used by the monitoring pages.
If this file is not created, check your permissions.
On the same pi or any computer on the same network, open another browser and start "IP address of your pi /Solar/Solar_Monitoring.php" or "IP address of your pi /Solar/Solar_Monitoring_Gauges.php".  You should see the display.

Some data will not be valid until "Logging.php" has been running past midnight.
"Logging.php" also creates a "Solar_log.dat" file.  This file is update every midnight with the prior days highs, lows and end of day data.  It is saved in CSV format.
"Logging.php" also creates files named "year month day .txt" .  These files save all teh data read from the Classics. .  It is saved in CSV format.
I plan on providing a review page that will use these files.

I tried to comment out the files I wrote to aid you if you want to tweek them.  I attached a file "registers used" which has information about the variables used.
Binkino also created a  nice display also.  It uses the same Logging.php and current.txt files.

If  you have questions, comment please reply to this post, or email me at wade_elmore@comcast.net.
Have fun.

binkino

#1
Thats great ;)

So here are my files with date 26 OCT 2017

Here you find the Monitoring files, with my changes.
Place the files from the zip in the same folder like the installed files.
With my files, you need a sub-directory "js" (gauge.min.js) so the js file don't has to be loaded from external source
and "lc" with all the graphics for the "LCARS" pages -  here are 2 more zip in attachment of this post.
For the gauges and the old LCARS version, you need the sub-folder "pic" with the content of the pic.zip file.

The files are showing the state of today - so they are not perfect and finished yet.
But they can be a good start for everyone, who is interested in it.

I tried to clean up all this crazy spaghetti looking code, but also not perfect and if you have recommendations, please let me know. I did it on the way I can do it and trying and looking for code and maths that works.

And keep in mind, the temperatures are in °C Celsius, not Fahrenheit (exp. the original page from Wade) and the namings are in german. If there are questions, please also ask.

IMPORTANT: the Lcars Graphics, like I use the one in the right side for coming use, I have copied from the web and changede the graphics a bit. So if you publish the page, keep this in mind, so you don't run in trouble.

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

binkino

#2
I recommend:
For new beginners, please use the source page from Wade, write down the Classic-Numbers you need to know, when you want to display a value. Helped me so much. So you don't have to search thru other files ...
-> see attached photo
With this note you have a excellent quick view, which data# for which value you need to set in the code.
Also you can look thru the php files, and see how single displayed values are displayed.
In the first versions, we used a pure PHP form, then switched over to use the header for the code information and scripts, following html code with php code inserts. This also makes it possible, to edit the pages in an WYSIWYG editor (like Frontpage 2000/2003) and do fine tuning later in source text code.

For all those who want to setup a PI from scratch for this purpose, I will do a "how to" ... based on my PI.
Also with examples of code, links to all used things.
(But give me some days to do this, possible end of next week. Or I make a video ... we will see... If weather is good, I first have to finish some work on my cars)
Then, you should be able to transfer this also to other PIs. We find solutions for other PIs as well, they mostly work here too.
There are differences; but at the end it is all Linux /based and only small diffs we don't really have to think about.

For my system, I use a BananaPI M1 (2core) and yesterday I have received the BananaPI M2 (4core). On this M2 I will show the way to the goal.
I have tried the cheaper OrangePI but I am running against walls with it; a nightmare! So don't waste your time and money.
(finding a working image is an adventure. OSes are not running stable. CPU has also 1Ghz, but while the BananaPI idles about 10% the OrangePI is on 40% and very quick on 100% and freezes for seconds and/or crashes. But it is your decision.)

At this point, finally my opinion:
RasPI is the "yellow of the eg". No discussion from my side :)
But next cheaper and working Board (and has also Sata on board, that was important for me) is the BananaPI ...  and in all its flavors.
Okay, on BananaPI you don't have the best support (see topic: screen resolutions ... 1024x768 and 1280x720 with bad tricks only) but it is much much better, then for OrangePI.



Edit: I have been playing around with the BANANA PI M2 BERRY and it runs well, BUT it don't recognize my monitor while booting and in the loaded OS. Only, if I unplug the HDMI and plug it in again. That is no way for me.
So I am back on my BANANA PI M1 and will see, what else is on the marked.
On the M1 it also runs well. The CPU power with 1Ghz and 1GB of ram is limited, but it runs 100% stable 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

ClassicCrazy

Thanks Wade and Bikino . I am planning to trying these out in the future when I get some time.

Bikino - have you tested the power requirements of the various boards you have tried ? I just checked my older Raspberry Pi B that has wifi dongle and weather station dongle plugged in and is running the Weewx weather program and it takes about 2.7 watts .

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

binkino

#4
yes I can measure this. will post it later when I am back home (~ 5hrs)



in the web I found a German page about the Banana PI as a NAS (like I used it before)
https://nas-selber-bauen.de/energieverbrauch-des-banana-pi-nas/

Booting (min.)                3.7 watts
Booting (max.)                4.3 watts
Idle (cheap PSU)             3.7 watts
Idle (Anker PSU)             3.4 watts
Idle (sleeping HDD / cheap PSU)    2.8 watts
Idle (sleeping HDD / Anker PSU)    2.6 watts
Max. computing power          5.2 watts
Max. data transfer (SD-card)       4.8 watts
Max. data transfer (HDD)          5.8 watts
Max. computing power + data transfer (HDD)    6.2 watts

I hope my translation makes sense :D

--------------------------------------------------------------------------

I was hoping, I can start all 3 PIs with one image, so I have the same OS and programs and load on all of them, didn't work.
Need more time, but I can tell ...
The Orange PI takes 0.085 A when no card and OS not loaded, when OS loaded and is starting all the things, it goes up to 0.62 A (3.1 watts)
The Banana PI M2 takes 0.06 A when no card and OS not loaded.

Have now downloaded an image, installed and wrote a "how to" (this will follow tomorrow after some hours of sleep and re-read it haha)


The M2 takes 0.3 to 0.4 Ampere while booting and when running, between 0.25 and 0.42 Amps
At 5 volts this is in watts: 1.25 to 2.6 Watts.
If you add some more hardware, this will increase the power hunger.
I think, they all are close similar in power consumption.


Thanks to 2 more cores on this PI, the browser starts much faster and only goes up to 75% while starting, then down to < 10 % only. Sometimes 17% when it is getting datas.

Only thing I miss on the M2 is the missing connections for a battery ... works like a UPS ...
(have not seen the connections on the PCB for now ...)

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

welmore

I discovered a bug. 

The Classics reset some of the registers at midnight, according to their clocks. 

The 'Logging.php' program keeps high and low data for each day.  'Logging.php' resets the data when the date changes, according to the pi's clock.

If the pi's clock is ahead of the Classics clock, the prior days Classic registers gets saved to the new day.

I have a fix.  I changed 'Logging.php' so it reads the time  and date from the Classics, not the pi.  I have it resetting the high and low data and starting the new daily log when Classic #1 changes dates and both Classics time is 00:00. 

Note: Even with the follow me cable and Classic #2 told to get its time from Classic #1, there can be slight differences in the time.

I am testing the patch over night and will post it when it passes.

This fix to 'Logging.php' does not require any changes to the monitoring programs.

estragon

I'm looking at using a Rpi3 to monitor, mainly unattended over the winter.  In past years, I've had problems with snow covering panels, and even the Classics self-consumption has been a problem, so the Rpi consumption, even at ~5w or a bit under, could be just adding to the problem. 

To address the Rpi power consumption, I've added a "SleepyPi2" from SpellFoundry.com in the UK.  It's basically an Arduino with a real time clock that can turn the Rpi on and off (proper shutdown) according to time of day, time elapsed, etc.  It will also have to control power to hub, router, WAN router, and cellphone booster.  The idea is to wake up once a day, read stuff from the Classics, report status, maybe wait for a bit in case I want to log on remotely, turn stuff off, and go back to sleep.  If I really wanted to save power, I could get it to just read battery voltages and go back to sleep if everything's okay, but I think I'll work on getting it to do daily reporting for now.

I just got the gear, but so far it looks like it should do the job. 
Off-grid. 
Main daytime system ~4kw panels into 2xMNClassic150 370ah 48v bank 2xOutback 3548 inverter 120v + 240v autotransformer
Night system ~1kw panels into 1xMNClassic150 700ah 12v bank morningstar 300w inverter

Westbranch

looks like they run on 5v and sip their amps....

Other Raspberry Pi models
Pi Model   Pi State   Power Consumption
model 3 B   HDMI off, LEDs off, onboard WiFi   250 mA (1.2W)
model 2 B   HDMI off, LEDs off   200 mA (1.0W)
model 2 B   HDMI off, LEDs off, USB WiFi   240 mA (1.2W)
Zero   HDMI off, LED off   80 mA (0.4W)

KID FW1811 560W >C&D 24V 900Ah AGM
CL150 29032 FW V.2126-NW2097-GP2133 175A E-Panel WBjr, 3Px4s 140W > 24V 900Ah AGM,
2 Cisco WRT54GL i/c DD-WRT Rtr, NetGr DS104Hub
Cotek ST1500 Inv  want a 24V  ROSIE Inverter
OmniCharge3024  Eu1/2/3000iGens
West Chilcotin 1680+W to come

ClassicCrazy

I am tempted to get a Pi Zero W ( the new  model ) and see if it would run my Weewx weather program - I looked it up and it sounded like someone simply took SD card out of a regular Pi and put it in the Pi Zero W and it ran okay .  Ha - nothing works that easy ! They only cost $10 but you can only buy one at a time now so shipping probably jacks the price up - that is why I was hoping the supply would increase so I could get more than one .

If it works then I could get on the Midnite monitor project sometime.
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

binkino

JUST 4 FUN  ;)

I just have played with a version for my phone in "portrait" mode:
http://a68k.de:81/Solar/Monitor_G1.php

Will be depending of the screen resolution... - I still have made it for my MOTO G5  (has 1920 x 1080 / 441 PPI)
Will test it later with my older phones and my 7" ASUS (they have lower resolutions)
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

ClassicCrazy

Quote from: binkino on January 15, 2018, 03:24:03 PM
JUST 4 FUN  ;)

I just have played with a version for my phone in "portrait" mode:
http://a68k.de:81/Solar/Monitor_G1.php

Will be depending of the screen resolution... - I still have made it for my MOTO G5  (has 1920 x 1080 / 441 PPI)
Will test it later with my older phones and my 7" ASUS (they have lower resolutions)

Is this sort of like Grahams Classic Android app  with the android connecting to Classic via modbus ? Or is this somehow using the Raspberry Pi ?

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

binkino

no this is still the PI
just another version
looks also good onb my older Moto G2 and my Asus 7" in portrait mode, have nothing to change
also tried a horicontal version, not finished yet, http://a68k.de:81/Solar/Monitor_G2.php
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

binkino

#12
now it is running well, i have another idea to add,
how can i display the generated energy of x-days in a list?
we have the data of the generated energy 'today'
but after 24:00h it is zero, and i like to see the value of the last day also, and if possible from some days before.
possible i could copy the data to a time (i.e. 23:55h) to a new value (like "$energylastday")
(if $time = 23:55:00 then  value 10 + 37 = $valuelastday, or so)
may bs i can shift the values day by day...

or do we have access to the saved log files in the data folder?
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

welmore

Can be done.  How may days back would you like?  How do you suggest I display it? 

I'm thinking seven day summary as list with date, peak watts for each charger for the day and  kWhr for each charger for the day and total combined kWhr.  List will be below gauges.  You will have to scroll down to see it.

I will start working on this.

I am also working on
     1  Automatic vent covers for the battery area.  Covers will open and fans start when there is charge current to the battery, and close and fans stop when there is a drain on the batteries.

     2 Switching from a desk top monitor to a 7"LCD screen on the logging pi.  Will rearrange my gauges screen to fit on the LCD.  Will also add tabs to other screens.  This pi will also control lawn sprinklers and other items around my house.


binkino

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