New to 123solar - trying to find

Talks about solar stuff
Post Reply
dpatellis
Posts: 4
Joined: Thu May 09, 2019 1:45 pm

New to 123solar - trying to find

Post by dpatellis » Thu May 09, 2019 2:21 pm

Hello, new to the forum.

First off, thank you for sharing a awesome program!

Been playing with 123solar now for about 3 months since bringing online a 8.5Kw and a small 1.5Kw array.
Using an old SB7000 and a newer SB4000TL grid tie inverters and RS-485 interfaces. Found Roland Breedveld's
485solar-get daemon and rewrote to be able to accept data from both of the inverters. Made it customizable
for which channel data you need to get from each inverter. Still have a kludge or two in the program like Roland
had for data not available on Sunny Boy inverters, but all and all it works great. Have 3+ months worth of data.

Recently, I've decided I wanted a small display showing me inverter power to grid and the total KwH produced so
far for the day. Since I also am into home automation and have a MQTT data broker running for my HA system, I figured
I'd add that functionally to 123solar and display to a 1602 LCD (2 line x 16 character) using an ESP8266 as the processor.

Threw together the 8266 & LCD module, added code to connect to my wifi & mqtt server and have it displaying the power for each inverter using test data.

Integrating mqtt into 123solar was a piece of cake, finding the power output to grid variable was easy... For the life of me I cannot find the variable(s) that contain the total KwH produced for each inverter for the day!

At this point I do have realtime power, but still would like the KwH for the day

Does someone have a list of variable names & use for the program?

If anyone is interested in this project, I'll stuff it up here once completed.

Thank you
Dan

jeanmarc
Posts: 1764
Joined: Thu Aug 29, 2013 7:16 am

Re: New to 123solar - trying to find

Post by jeanmarc » Thu May 09, 2019 3:56 pm

Hi,
It would be neat if you share your code and send it to Roland.

You can get the title in programs/programday.php?invtnum=1 ?
Or try pool123s for meterN but that will send the total kWH, you can check and make the difference for daily production.

In mN there's FirstX and LastX variables.

dpatellis
Posts: 4
Joined: Thu May 09, 2019 1:45 pm

Re: New to 123solar - trying to find

Post by dpatellis » Thu May 09, 2019 10:45 pm

Thanks for the reply.

Using phpMQTT library, which i load in 123solar.php:

require("phpMQTT.php");

$MQTTSERVER = "192.168.1.21"; // change if necessary
$MQTTPORT = 1883; // change if necessary
$MQTTUSER = ""; // set your username
$MQTTPWD = ""; // set your password
$MQTTID = "123Solar"; // make sure this is unique for connecting to sever - you could use uniqid()


I shoehorned the mqtt publish code into 485solar-get.php after the values from the inverter has been stuffed into the array as follows:

if ($RET == 'OK')
{
$Which=${'ADR'.$invt_num};
$Power=sprintf("%01.0f", $G1P);
$mqttHandle = new phpMQTT($MQTTSERVER, $MQTTPORT, $MQTTID);
if ($mqttHandle->connect(true, NULL, $MQTTUSER, $MQTTPWD))
{
$mqttHandle->publish("SOLARARRAY/$Which/KWHT",$KWHD[$Which], 0); //<== this doesn't work. :(
$mqttHandle->publish("SOLARARRAY/$Which/POWER",$Power, 0); //<=== this gets me the grid watts :)
$mqttHandle->close();
}
}

What I'm looking for a variable somewhere that has each inverters running KwH delivered so far for the day. I know it's somewhere because it displays on the webpage. Hmmm... Uh oh, is it possible that it's calculated when the page is displayed? I hope not.

Since the little monitor will not be storing anything internally, I need the KwH sent occasionally and not calculated.

I have a feeling that the program does not keep a running total like I thought. Dang.

Dan

jeanmarc
Posts: 1764
Joined: Thu Aug 29, 2013 7:16 am

Re: New to 123solar - trying to find

Post by jeanmarc » Fri May 10, 2019 6:52 am

123s use the total Kwh counter to make the calculation.
You should either read first and last value in the csv or (better) check the total counter like pool123s does.
Ajust it to your needs: at the end of the day save the last kWh then, make the difference.
All can be done in your logger

dpatellis
Posts: 4
Joined: Thu May 09, 2019 1:45 pm

Re: New to 123solar - trying to find

Post by dpatellis » Fri May 10, 2019 7:13 pm

I did something along those lines:
Added this function to 123solar.php:

Code: Select all

function GetStartOfDayKwH($TodayDate,$NumInverters,$SCRDIR)
{
   global $KwHBeginOfDay;

   for ($Which = 1; $Which <= $NumInverters; $Which++)
   {
      $Directory  = dirname($SCRDIR) . "/data/invt$Which";
       if (file_exists($Directory . "/csv/$TodayDate.csv"))
        {
            if ($FpHandle = fopen($Directory . "/csv/$TodayDate.csv", 'r'))
            {
                $InputCSV = fgetcsv($FpHandle, 1000, ',');	//skip header
                $InputCSV = fgetcsv($FpHandle, 1000, ',');
                $KwHBeginOfDay[$Which-1]=floatval($InputCSV[27]);
                fclose($FpHandle);
            }
        }
    }
//  print_r($KwHBeginOfDay);
}
In the startup code (after init of variables to null):

Code: Select all

        if ($memarray['status']=="123Solar starting")
            GetStartOfDayKwH($today,$NUMINV,$SCRDIR);
In the 485solar-get.php I added:

Code: Select all


if ($RET == 'OK')
{
    $Which=${'ADR'.$invt_num};
    $Power=sprintf("%01.0f", $G1P);
    $KwHToday=sprintf("%5.2f",$KWHT-$KwHBeginOfDay[$Which]);
    $mqttHandle = new phpMQTT($MQTTSERVER, $MQTTPORT, $MQTTID);
    if ($mqttHandle->connect(true, NULL, $MQTTUSER, $MQTTPWD))
    {
        $mqttHandle->publish("ARRAY/$Which/KWHT",$KwHToday, 0);
        $mqttHandle->publish("ARRAY/$Which/POWER",$Power, 0);
        $mqttHandle->close();
    }
    else
    {
        //echo "Timeout!";		//just ignore for now
    }
}

Also added code in "if Dawn" section of 123solar.php to grab 1st KWHT of the day reading from each inverter.

Works perfectly.

Here's a photo of the prototype. Just need to print a case for it and I should be good to go. Thank you for the pointers

Image

jeanmarc
Posts: 1764
Joined: Thu Aug 29, 2013 7:16 am

Re: New to 123solar - trying to find

Post by jeanmarc » Fri May 10, 2019 8:20 pm

Looks good 8-)
It's not a good idea to put the code into 123solar.php/485solar-get.php , it won't survive to the update.
Btw: it's kWh not KwH

dpatellis
Posts: 4
Joined: Thu May 09, 2019 1:45 pm

Re: New to 123solar - trying to find

Post by dpatellis » Sat May 11, 2019 2:27 pm

True on the adding the code directly into 123solar. However, I see no other way of hooking into the program at the points I need to grab the data.
I'll have to "patch" and future versions with my code. Not a real bit deal since it's only a few lines of code.


Thanks on pointing out the kWh. :)

jeanmarc
Posts: 1764
Joined: Thu Aug 29, 2013 7:16 am

Re: New to 123solar - trying to find

Post by jeanmarc » Mon May 13, 2019 6:41 am

Hi,
I will put first and last values in shm in the next release, that be cleaner ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests