Author Topic: Automatic Solar battery charging timings based on forecast weather  (Read 3750 times)

0 Members and 1 Guest are viewing this topic.

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Automatic Solar battery charging timings based on forecast weather
« on: September 11, 2024, 11:01:40 am »
Hi all,

I have a 4kW solar & 10kWh battery system, and an Octopus Flux tariff with my energy provider.
2am to 5am the cheap rate electricity tariff kicks in which is nearly 50% off the normal rate so it makes sense to charge the 10kWh battery during that time ready for the next day.
But of course, if it's going to be sunny the next day then don't bother charging the batteries overnight and let the solar panels do it instead.
Some folks log-in to their battery inverter app manually after looking at tomorrows weather online and making a determination of what timings to put on the battery charging.......yeuccchhhh, I couldn't be bothered!

So, I have automated this with a Windows app running on my home server.
At 11:55pm the app goes off to openweathermap.org via it's API and gets the next days irridiance forecast for my lat/long and then via a ruleset works out how much to charge the batteries the coming 2am to 5am cheap rate.....if at all.
The app them goes off via the Solis API and updates the charging settings in the inverter. I don't lift a finger.

Today is day 1 of this now up and running. Tomorrows irridiance figure is 3699 and so my app has determined a half hour charge should be enough.
I'll have to monitor it over the next few weeks under different weather conditions and adjust the ruleset accordingly, but basically my system is completely hands-off now.

Here's some of the VB.NET code from my app........API keys etc removed.
If anyone else can benefit from it................

PS. It's a Solis battery inverter.

Future works:
Spare battery capacity could be exported back to the grid between 4pm and 7pm which is nearly 30% more than grid cost. Hmmmm!

Code: [Select]
Imports System.Security.Cryptography
Imports System.Text
Imports Newtonsoft.Json.Linq
Imports Newtonsoft.Json
Imports System.Net.Http
Imports System.Globalization
Imports System.Net.Http.Headers
Imports System.Text.RegularExpressions
Imports System
Imports System.Threading
Imports System.Runtime.InteropServices

Partial Class FormMain

    Private Sub ButtonChargeSet_Click(sender As Object, e As EventArgs) Handles ButtonChargeSet.Click

        If CheckBox7.Checked And CheckBox8.Checked Then
            Call OpenWeatherIrridiance()          ' Manually get irridiance figures and then send updated settings back to Solis Inverter (battery charge discharge timings)
        End If

    End Sub


    Private Sub SendToSolis()

        Try

            ' Check user entered data, abort sub with pop-up if wrong
            Dim Charge1SetOn As String = TextBoxChargeSetOn.Text
            Dim Charge1SetOff As String = TextBoxChargeSetOff.Text
            ' Define the regex pattern for XX:XX format
            Dim timePattern As String = "^\d{2}:\d{2}$"
            ' Check if the strings match the pattern
            If Not Regex.IsMatch(Charge1SetOn, timePattern) OrElse Not Regex.IsMatch(Charge1SetOff, timePattern) Then
                ' If either string does not match the pattern, exit the sub
                MessageBox.Show("Please enter the time in the format XX:XX")
                Exit Sub
            End If

            Dim key As String = "#####################" ' Private key from Solis
            Dim keySecret As String = "############################" ' Secret key from Solis

            ' Create a comma-separated value for cid 103 using the inputs and default values
            Dim value As String = $"70,50,{Charge1SetOn},{Charge1SetOff},00:00,00:00,70,50,00:00,00:00,00:00,00:00,70,50,00:00,00:00,00:00,00:00"

            ' Create the map for the API request
            Dim map As New Dictionary(Of String, Object) From {
            {"inverterSn", "##############"}, ' Replace with your actual inverter serial number
            {"cid", "103"},
            {"value", value}  ' Set the parameters as a single comma-separated string
            }

            ' Serialize the map to JSON for the API request
            Dim body As String = JsonConvert.SerializeObject(map)
            Dim ContentMd5 As String = GetDigest(body)
            Dim [Date] As String = GetGMTTime()
            Dim path As String = "/v2/api/control"
            Dim param As String = "POST" & vbLf & ContentMd5 & vbLf & "application/json" & vbLf & [Date] & vbLf & path
            Dim sign As String = HmacSHA1Encrypt(param, keySecret)
            Dim url As String = "https://www.soliscloud.com:13333" & path ' URL for the control endpoint
            Dim client As New HttpClient()
            Dim requestBody As HttpContent = New StringContent(body, Encoding.UTF8, "application/json")

            ' Set Content-Type and Content-MD5
            requestBody.Headers.ContentType = New MediaTypeHeaderValue("application/json") With {
                .CharSet = "UTF-8"
            }
            requestBody.Headers.ContentMD5 = Convert.FromBase64String(ContentMd5)

            Dim request As New HttpRequestMessage(HttpMethod.Post, url)
            request.Headers.Add("Authorization", "API " & key & ":" & sign)
            request.Headers.Add("Date", [Date])
            request.Content = requestBody

            ' Send the request
            Dim response As HttpResponseMessage = client.SendAsync(request).Result ' Non-async for timing purposes
            Dim result As String = response.Content.ReadAsStringAsync().Result

            RunningSeq.Text = "Irridiance received, Battery settings updated"

        Catch ex As Exception
            Console.WriteLine(ex.ToString())
        End Try

    End Sub


    Private Sub CheckBox7_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox7.CheckedChanged

        If CheckBox7.Checked = True Then
            ButtonChargeSet.Enabled = True
        Else
            ButtonChargeSet.Enabled = False
        End If

    End Sub


    Private Sub OpenWeatherIrridiance()
        On Error GoTo ErrorHandler

        ' get solar irridiance from openweathermap.org
        ' API = ##################################
        ' appid = API key

        If CheckBox8.Checked = True Then

            Dim TomorrowDate As String = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd")         ' tomorrow date, so run this sub before midnight
            Dim IrridianceAPIkey As String = "################################"
            ' openweathermap ping retry
            Dim deviceAddress As String = "openweathermap.org"
            Dim maxRetries As Integer = 3
            Dim retryDelaySeconds As Double = 0.2

            ' Call Function
            If TryPingDevice(deviceAddress, maxRetries, retryDelaySeconds) Then
                ' Ping was successful, continue with your specific actions

                Dim IrridianceData As String = ""

                IrridianceData = New System.Net.WebClient().DownloadString("https://api.openweathermap.org/energy/1.0/solar/data?lat=56.9734&lon=-2.2252&date=" & TomorrowDate & "&" & "appid=" & IrridianceAPIkey)
                IsOkIrridiance = True

                ' Turn on the LED
                LEDirridiance.State = OnOffLed.LedState.OnSmallYellow
                ' Start the timer so the LED will light for 1sec
                IndicatorTimer3.Interval = 2000 ' 1 second
                IndicatorTimer3.Start()

                ' Sample return
                ' {"lat":56.9734,"lon":2.2252,"date":"2024-09-12","tz":"+00:00","sunrise":"2024-09-12T05:16:09","sunset":"2024-09-12T18:16:56","irradiance":{"daily":[{"clear_sky":{"ghi":4454.41,"dni":8160.83,"dhi":974.92},"cloudy_sky":{"ghi":1176.86,"dni":0.0,"dhi":1176.86}}],"hourly":[{"hour":0,"clear_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0},"cloudy_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0}},{"hour":1,"clear_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0},"cloudy_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0}},{"hour":2,"clear_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0},"cloudy_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0}},{"hour":3,"clear_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0},"cloudy_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0}},{"hour":4,"clear_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0},"cloudy_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0}},{"hour":5,"clear_sky":{"ghi":13.3,"dni":92.91,"dhi":13.27},"cloudy_sky":{"ghi":3.83,"dni":0.0,"dhi":3.83}},{"hour":6,"clear_sky":{"ghi":112.37,"dni":436.99,"dhi":48.97},"cloudy_sky":{"ghi":31.06,"dni":0.0,"dhi":31.06}},{"hour":7,"clear_sky":{"ghi":244.8,"dni":617.18,"dhi":70.05},"cloudy_sky":{"ghi":61.2,"dni":0.0,"dhi":61.2}},{"hour":8,"clear_sky":{"ghi":372.29,"dni":715.88,"dhi":83.97},"cloudy_sky":{"ghi":98.83,"dni":0.0,"dhi":98.83}},{"hour":9,"clear_sky":{"ghi":478.25,"dni":774.19,"dhi":93.27},"cloudy_sky":{"ghi":136.31,"dni":0.0,"dhi":136.31}},{"hour":10,"clear_sky":{"ghi":551.52,"dni":806.91,"dhi":98.91},"cloudy_sky":{"ghi":153.17,"dni":0.0,"dhi":153.17}},{"hour":11,"clear_sky":{"ghi":584.97,"dni":820.27,"dhi":101.33},"cloudy_sky":{"ghi":160.0,"dni":0.0,"dhi":160.0}},{"hour":12,"clear_sky":{"ghi":575.45,"dni":816.47,"dhi":100.67},"cloudy_sky":{"ghi":151.91,"dni":0.0,"dhi":151.91}},{"hour":13,"clear_sky":{"ghi":523.81,"dni":794.88,"dhi":96.9},"cloudy_sky":{"ghi":130.95,"dni":0.0,"dhi":130.95}},{"hour":14,"clear_sky":{"ghi":434.94,"dni":751.78,"dhi":89.75},"cloudy_sky":{"ghi":108.77,"dni":0.0,"dhi":108.77}},{"hour":15,"clear_sky":{"ghi":317.69,"dni":678.03,"dhi":78.58},"cloudy_sky":{"ghi":79.5,"dni":0.0,"dhi":79.5}},{"hour":16,"clear_sky":{"ghi":185.27,"dni":550.99,"dhi":61.93},"cloudy_sky":{"ghi":46.36,"dni":0.0,"dhi":46.36}},{"hour":17,"clear_sky":{"ghi":59.13,"dni":298.83,"dhi":35.37},"cloudy_sky":{"ghi":14.8,"dni":0.0,"dhi":14.8}},{"hour":18,"clear_sky":{"ghi":0.62,"dni":5.51,"dhi":1.96},"cloudy_sky":{"ghi":0.15,"dni":0.0,"dhi":0.15}},{"hour":19,"clear_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0},"cloudy_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0}},{"hour":20,"clear_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0},"cloudy_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0}},{"hour":21,"clear_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0},"cloudy_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0}},{"hour":22,"clear_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0},"cloudy_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0}},{"hour":23,"clear_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0},"cloudy_sky":{"ghi":0.0,"dni":0.0,"dhi":0.0}}]}}

                ' Pull total irridiance value from returned string
                If (IrridianceData.Length() > 2000) Then        ' usually 2885 approx.

                    ' Your JSON string
                    Dim json As String = IrridianceData

                    ' Parse the JSON string
                    Dim data As JObject = JObject.Parse(json)

                    ' Get the hourly irradiance array
                    Dim hourlyIrradiance As JArray = data("irradiance")("hourly")

                    ' Initialize variables to store the total irradiance for both clear and cloudy skies
                    Dim totalClearSkyIrradiance As Double = 0
                    Dim totalCloudySkyIrradiance As Double = 0

                    ' Loop through each hourly object and sum the "ghi" (global horizontal irradiance) for both clear and cloudy skies
                    For Each hourData As JObject In hourlyIrradiance
                        Dim clearSkyGhi As Double = hourData("clear_sky")("ghi")
                        Dim cloudySkyGhi As Double = hourData("cloudy_sky")("ghi")

                        totalClearSkyIrradiance += clearSkyGhi
                        totalCloudySkyIrradiance += cloudySkyGhi
                    Next

                    ' Output the total summed irradiance for both clear and cloudy skies
                    Console.WriteLine("Total summed irradiance for the day (clear sky): " & totalClearSkyIrradiance.ToString())
                    Console.WriteLine("Total summed irradiance for the day (cloudy sky): " & totalCloudySkyIrradiance.ToString())

                    ' You can use either of the summed values or calculate an average for decision making
                    Dim overallIrradiance As Double = (totalClearSkyIrradiance + totalCloudySkyIrradiance) / 2

                    Irridiance.Text = overallIrradiance

                    ' Output the overall irradiance
                    Console.WriteLine("Overall summed irradiance: " & overallIrradiance.ToString())

                    ' now determine if batteries should charge. Figures below from ChatGPT
                    ' Overcast days:  200-500 W/m²
                    ' Cloudy days:  500-1000 W/m²
                    ' Cloudy/sunny days: 1000-2000 W/m²
                    ' Sunny winter days:  2000-3000 W/m²
                    ' Sunny summer days:  5000-7000 W/m²

                    If overallIrradiance <= 500 Then
                        TextBoxChargeSetOn.Text = "02:00"
                        TextBoxChargeSetOff.Text = "05:00"
                    End If
                    If overallIrradiance > 500 And overallIrradiance <= 1000 Then
                        TextBoxChargeSetOn.Text = "02:00"
                        TextBoxChargeSetOff.Text = "04:30"
                    End If
                    If overallIrradiance > 1000 And overallIrradiance <= 2000 Then
                        TextBoxChargeSetOn.Text = "02:00"
                        TextBoxChargeSetOff.Text = "04:00"
                    End If
                    If overallIrradiance > 2000 And overallIrradiance <= 3000 Then
                        TextBoxChargeSetOn.Text = "02:00"
                        TextBoxChargeSetOff.Text = "03:30"
                    End If
                    If overallIrradiance > 3000 And overallIrradiance <= 5000 Then
                        TextBoxChargeSetOn.Text = "02:00"
                        TextBoxChargeSetOff.Text = "02:30"
                    End If
                    If overallIrradiance > 5000 And overallIrradiance <= 7000 Then
                        TextBoxChargeSetOn.Text = "00:00"
                        TextBoxChargeSetOff.Text = "00:00"
                    End If

                    My.Settings.data40 = TextBoxChargeSetOn.Text
                    My.Settings.data41 = TextBoxChargeSetOff.Text
                    My.Settings.Save()

                    Call SendToSolis()      ' Got the irridiance value so can now send the required settings to Solis

                    ' Turn off the LED
                    LEDirridiance.State = OnOffLed.LedState.OffSmallBlack

                End If

            Else
                Dim currentDateAndTime As DateTime = DateTime.Now
                Dim formattedDateTime As String = currentDateAndTime.ToString("dd-MM-yyyy HH:mm", CultureInfo.InvariantCulture)
                ErrorCode.Text = formattedDateTime & " " & "openweathermap.org ping fail" 'ToErrorString(Err)     ' display error status
                IsOkIrridiance = False
                LEDirridiance.State = OnOffLed.LedState.OffSmall   ' fail RED led
                Exit Sub
            End If

        End If

ErrorHandler:
    End Sub



    Private Async Sub Battery()

        Dim batteryPower As Double = 0

        If CheckBox4.Checked Then ' Solar read must have been done successfully before OB418 read can take place

            ' Async/Await: The HttpClient operations are now asynchronous, preventing the UI thread from being blocked.

            Try
                Dim key As String = "######################" ' Private key from Solis
                Dim keySecret As String = "################################" ' Secret key from Solis

                Dim map As New Dictionary(Of String, Object) From {
                {"pageNo", 1},
                {"pageSize", 10}
}
                Dim body As String = JsonConvert.SerializeObject(map)
                Dim ContentMd5 As String = GetDigest(body)
                Dim [Date] As String = GetGMTTime()
                Dim path As String = "/v1/api/inverterList"
                Dim param As String = "POST" & vbLf & ContentMd5 & vbLf & "application/json" & vbLf & [Date] & vbLf & path
                Dim sign As String = HmacSHA1Encrypt(param, keySecret)
                Dim url As String = "https://www.soliscloud.com:13333" & path ' Url from Solis
                Dim client As New HttpClient()
                Dim requestBody As HttpContent = New StringContent(body, Encoding.UTF8, "application/json")

                ' Set Content-Type and Content-MD5 directly when creating StringContent
                requestBody.Headers.ContentType = New MediaTypeHeaderValue("application/json") With {
                                .CharSet = "UTF-8"
                }
                requestBody.Headers.ContentMD5 = Convert.FromBase64String(ContentMd5)

                Dim request As New HttpRequestMessage(HttpMethod.Post, url)
                request.Headers.Add("Authorization", "API " & key & ":" & sign)
                request.Headers.Add("Date", [Date])
                request.Content = requestBody

                Dim response As HttpResponseMessage = client.SendAsync(request).Result          ' non-asynchronous - Sub will wait for response, stopwatch records properly
                Dim result As String = response.Content.ReadAsStringAsync().Result

                ' Now pull data from JSON string
                Dim jsonObject As JObject = JObject.Parse(result) ' Parse the JSON string

                ' Access the "records" array within the "page" property
                Dim recordsArray As JArray = jsonObject.SelectToken("data.page.records")

                ' Check if the "records" array is not null and contains at least one item
                If recordsArray IsNot Nothing AndAlso recordsArray.Any() Then
                    ' Access the first item in the "records" array
                    Dim firstRecord As JObject = recordsArray.First

                    ' Access the "batteryCapacitySoc" property within the first record
                    Dim batteryCapacitySoc As Double = 0
                    If firstRecord.TryGetValue("batteryCapacitySoc", batteryCapacitySoc) Then
                        IsOkBattery = True
                        LEDbattery.State = OnOffLed.LedState.OnSmall

                        BatteryCapacity.Text = Math.Round(batteryCapacitySoc, 0).ToString() ' 0dp

                    Else
                        IsOkBattery = False
                        LEDbattery.State = OnOffLed.LedState.OffSmall
                    End If

                    ' Access the "batterypower" property within the first record, also charging status
                    If DataGlitch = False Then
                        If firstRecord.TryGetValue("batteryPower", batteryPower) Then

                            IsOkBattery = True
                            LEDbattery.State = OnOffLed.LedState.OnSmall

                            If batteryPower > 0 Then
                                BattStatus.Text = "Charging"
                            ElseIf batteryPower < 0 Then
                                BattStatus.Text = "Discharging"
                            Else
                                BattStatus.Text = "Static"
                            End If

                            batteryPower *= 1000 ' kW to W
                            BattChg.Text = Math.Round(batteryPower, 0).ToString() ' 0dp
                        Else
                            IsOkBattery = False
                            LEDbattery.State = OnOffLed.LedState.OffSmall
                        End If
                    End If

                    ' House Consumption
                    If DataGlitch = False Then
                        Dim solarWValue As Double = Val(SolarW.Text)
                        Dim consumptionValue As Double = solarWValue + OB418DataMeterPwr - batteryPower

                        Consumption.Text = FormatNumber(consumptionValue, 1).Replace(",", "")
                    End If

                    DataGlitch = False ' reset glitch flag
                    RunningSeq.Text = "Received Solis battery data"

                Else
                    ' Handle the case where "records" array is empty or null
                    IsOkBattery = False
                    LEDbattery.State = OnOffLed.LedState.OffSmall
                End If

            Catch ex As Exception
                Console.WriteLine(ex.ToString())
            End Try

        End If

    End Sub

    Function HmacSHA1Encrypt(encryptText As String, KeySecret As String) As String
        Dim data As Byte() = Encoding.UTF8.GetBytes(KeySecret)
        Dim secretKey As New HMACSHA1(data)
        Dim text As Byte() = Encoding.UTF8.GetBytes(encryptText)
        Dim result As Byte() = secretKey.ComputeHash(text)
        Return Convert.ToBase64String(result)
    End Function

    Function GetGMTTime() As String
        Return DateTime.UtcNow.ToString("ddd, dd MMM yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture)
    End Function

    Function GetDigest(test As String) As String
        Dim result As String = ""
        Try
            Using md5 As System.Security.Cryptography.MD5 = System.Security.Cryptography.MD5.Create()
                Dim data As Byte() = md5.ComputeHash(Encoding.UTF8.GetBytes(test))
                result = Convert.ToBase64String(data)
            End Using
        Catch ex As Exception
            Console.WriteLine(ex.ToString())
        End Try
        Return result
    End Function

End Class
« Last Edit: September 11, 2024, 11:28:03 am by IanJ »
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 
The following users thanked this post: Siwastaja

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8833
  • Country: fi
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #1 on: September 11, 2024, 11:27:57 am »
Interesting to hear!

I mean, we do this as a product/service. It's a physical box which connects to the battery inverter through RS485 or modbus TCP (Solis hybrid being one of the supported models) and to the Internet to get prices/weather forecasts/configuration/user bypass controls from our cloud service. So far it hasn't taken weather forecasts into account for battery optimization, and people have had to fine-tune optimization algorithm settings to get good results and that has sucked to the point of causing some well deserved complaints.

We made it the simple way by having a control for maximum SoC during night/early morning charging, instead of controlling it by the length of charge time. This way, if there is still excess solar from previous day, nothing is put into the battery, but if it is empty, a little bit charging is done to supply the morning peak use before the generation really exceeds consumption. But even then this requires manual tuning of this "charge up to SoC%" setting; in winter you want to increase it, maybe up to nearly 100%. And if you really want good results, even daily increase it for cloudy days. Sucks.

As such now I'm in progress of writing a more comprehensive battery optimization algorithm and can share some ideas, like:

Take consumption history into account automatically, too. I'm now doing this by tracking energy meter net sums which are negative on export, positive on import. Track hourly minimums over a few weeks of history and they represent what would be exported on a fully sunny day (well assuming there was at least one sunny day within the period). Net forecast is better than production forecast because maybe there is some load which often/always comes on at a certain time.

When hourly net forecasts show export, multiple them by hourly solar level estimates, sum them up for the day and now you know more exactly how much room you have to reserve into the battery.

I have this tendency that when it comes to designing an algorithm with complex interactions, at some point I just resort to some brute-forcing. So create a model (input with price, weather, energy consumption/production forecasts which are constant over iterations) which runs with not too much CPU time and loop over thousands of different combinations of controls, outputting money made for each set of parameters. Then pick the winner and possibly finetune it.
« Last Edit: September 11, 2024, 11:29:49 am by Siwastaja »
 
The following users thanked this post: IanJ

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #2 on: September 11, 2024, 11:37:45 am »
I did talk to Solis back in January when I first had this idea, and they were receptive but that's as far as it went. I was actually hoping Solis would integrate this functionality into their inverters.....more sales!
I already had an app running monitoring my energy usage, Solar PV output etc.......it made sense to extend the app. I know some folks are using Home Assistant for something similar.
Thanks for the tips, I'm quite eager to see how things go.......I'll probably extend my app to record irridiance forecast values against battery capacity to see where my ruleset needs tweaked......summer and winter.

Ian.
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #3 on: September 11, 2024, 11:59:55 am »
Here's my app.......It doubles as an Aircon control app for my workshop.
It's quite a dense form, the server display is only 1024x768 and runs on a touchscreen on my workshop wall.
The app also writes a webpage containing most of the stats and graphs and pops it onto my webserver so I can access from anywhere.

« Last Edit: September 11, 2024, 12:11:15 pm by IanJ »
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 
The following users thanked this post: Siwastaja

Offline mag_therm

  • Frequent Contributor
  • **
  • Posts: 783
  • Country: us
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #4 on: September 11, 2024, 01:13:07 pm »
Ian, that looks good.
I have been developing/testing a similar system since Jan 2024 on the mini solar battery system here used to power the ham radio station.
With two NOS panels,in parallel, there is a nominal 3 kW.h 42 V bus and a 1 kW.h 13.8V bus each controlled by two 300 W home brew DC converters.

The outer loop of the converters is controlled, along with a 14 point datalogger,  by python via tty on linux.

I use Pyowm API to obtain next day UV Index. Based on UV Index, a calculation of battery ullage is made at 8:00pm local.(0 UTC)
Fo example, UV Index of 10 will switch off the Utility earlier in pm than a UVI of 4.

https://app.box.com/s/a3pfju14qjllbnp3qdwjj258gs603atp

It basically works but there are problems to overcome. The main one is intermittent clouds that occur in this area through summer.
The pyowm is inadequately documented for me, and does not seem to provide an enumeration of forecast cloud cover (as used in aviation for example)
A further problem is that the batteries are floating, and can not take all the solar power available.
I am thinking of adding a third "raw" bus with Li battery and a separate bidirectional controller to take the presently unusable energy.

I will look at openweathermap.org when I do next round of python updates ( next winter).
 

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #5 on: September 12, 2024, 10:17:25 am »
Ian, that looks good.
I have been developing/testing a similar system since Jan 2024 on the mini solar battery system here used to power the ham radio station.
With two NOS panels,in parallel, there is a nominal 3 kW.h 42 V bus and a 1 kW.h 13.8V bus each controlled by two 300 W home brew DC converters.

The outer loop of the converters is controlled, along with a 14 point datalogger,  by python via tty on linux.

I use Pyowm API to obtain next day UV Index. Based on UV Index, a calculation of battery ullage is made at 8:00pm local.(0 UTC)
Fo example, UV Index of 10 will switch off the Utility earlier in pm than a UVI of 4.

https://app.box.com/s/a3pfju14qjllbnp3qdwjj258gs603atp

It basically works but there are problems to overcome. The main one is intermittent clouds that occur in this area through summer.
The pyowm is inadequately documented for me, and does not seem to provide an enumeration of forecast cloud cover (as used in aviation for example)
A further problem is that the batteries are floating, and can not take all the solar power available.
I am thinking of adding a third "raw" bus with Li battery and a separate bidirectional controller to take the presently unusable energy.

I will look at openweathermap.org when I do next round of python updates ( next winter).

Nice data on your chart.

I'm not sure exactly how irridiance figures operate through winter, summer, cloud cover etc......so I will be monitoring closely.
You have to pay for irridiance data through openweathermap.org but it's cheap........it's 0.1p (pence) per API call.......and I need it once per day. The nice thing is you can specify latitude/longitude values for the data and so specify your exact location for the best data.
I get the Outside Temp. via them also, but it's free.

Ian.
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #6 on: September 12, 2024, 10:33:20 am »
Ok, so I decided enough was enough and my app was too conjested......so I have expanded it full screen (1024x768) on the server monitor, bigger buttons, bigger/coloured text, bigger graphs. Nearly done.

That's the first overnight functionality with irridiance data and updating the Solis inverter battery charging times accordingly at just before midnight and it worked just fine.
One thing I might work on is having a table where I can edit the irridiance to charging ruleset without recompiling/restarting the app.



Irridiance Ruleset can now by dynamically changed/applied within the app, and the number of rows is not limited:

« Last Edit: September 12, 2024, 11:29:12 am by IanJ »
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 
The following users thanked this post: EEVblog

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8833
  • Country: fi
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #7 on: September 12, 2024, 11:14:51 am »
I personally like those kind of technical, full-of-info dashboards. Attached is an example what our thing looks like. When I suggest adding more bells and whistles to the UI, I get backlash from the others >:(. As you can see from my attachment (it's from today), price variation can sometimes be quite large and a battery owner is able to make some money by selling into grid at correct time. And even if not selling to grid, when daily consumption exceeds that of battery capacity and production, just timing the self-use during expensive rates is valuable.
 

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #8 on: September 12, 2024, 11:28:18 am »
I personally like those kind of technical, full-of-info dashboards. Attached is an example what our thing looks like. When I suggest adding more bells and whistles to the UI, I get backlash from the others >:(. As you can see from my attachment (it's from today), price variation can sometimes be quite large and a battery owner is able to make some money by selling into grid at correct time. And even if not selling to grid, when daily consumption exceeds that of battery capacity and production, just timing the self-use during expensive rates is valuable.

Thanks for sharing the screenshots.......it's giving me some ideas.
Yup, my app is ONLY for me, not another soul on the planet will use it hence mine is very busy......and I like to just walk past the server screen and see everything/anything without having to touch the mouse/touchscreen.

Ian.
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #9 on: September 12, 2024, 12:28:54 pm »
Modified section of code on evaluating the Irridiance data forecast from OpenWeatherMap.org in order to make a better determination of what the actual figure might look like for the day.
This is necessary because the data provides two sets of numbers for clear and cloudy skies......but there is data there to make a weighted value overall to speculatively decide on how long to charge the batteries for.

Ian.

Code: [Select]
   ' Produces an irradiance figure that factors in whether it is cloudy or clear, we can enhance it by determining the likely irradiance
   ' based on the ratio between cloudyand clear sky conditions, making a decision based on the comparison of irradiance values.

   ' Cloudy vs.Clear Hour Count:
   ' We count the number of hours where cloudy irradiance Is significantly lower than clear sky irradiance (less than 50% of clear sky irradiance).
   ' Weighted Irradiance:
   ' Based on the count of cloudy And clear hours, we use the total cloudy Or clear sky irradiance To calculate the most likely overall irradiance. If more hours are cloudy, the cloudy irradiance Is used; otherwise, clear sky irradiance Is used.
   ' Purpose:
   ' This code now takes into account both clear And cloudy conditions by weighting the irradiance based on the number of cloudy versus clear hours. It will output the irradiance figure you can use to make a decision about solar energy potential for the day.
   ' A generally perfect sunny day max figure would be 7600.
   ' From the data sample above it would be 5449.

   ' Your JSON string
   Dim json As String = IrridianceData

   ' Parse the JSON string
   Dim data As JObject = JObject.Parse(json)

   ' Get the hourly irradiance array
   Dim hourlyIrradiance As JArray = data("irradiance")("hourly")

   ' Initialize variables to store the total irradiance for both clear and cloudy skies
   Dim totalClearSkyIrradiance As Double = 0
   Dim totalCloudySkyIrradiance As Double = 0
   Dim cloudyHours As Integer = 0
   Dim clearHours As Integer = 0

   ' Loop through each hourly object and sum the "ghi" (global horizontal irradiance) for both clear and cloudy skies
   For Each hourData As JObject In hourlyIrradiance
       Dim clearSkyGhi As Double = hourData("clear_sky")("ghi")
       Dim cloudySkyGhi As Double = hourData("cloudy_sky")("ghi")

       totalClearSkyIrradiance += clearSkyGhi
       totalCloudySkyIrradiance += cloudySkyGhi

       ' Count hours where the cloudy irradiance is significantly lower than clear sky irradiance
       If cloudySkyGhi < clearSkyGhi * 0.5 Then
           cloudyHours += 1
       Else
           clearHours += 1
       End If
   Next

   ' Determine the weighted irradiance based on the number of cloudy and clear hours
   Dim weightedIrradiance As Double
   If cloudyHours > clearHours Then
       ' More cloudy hours, use cloudy sky irradiance
       weightedIrradiance = totalCloudySkyIrradiance
   Else
       ' More clear hours or balanced, use clear sky irradiance
       weightedIrradiance = totalClearSkyIrradiance
   End If

   ' Output the total summed irradiance for both clear and cloudy skies
   Console.WriteLine("Total summed irradiance for the day (clear sky): " & totalClearSkyIrradiance.ToString())
   Console.WriteLine("Total summed irradiance for the day (cloudy sky): " & totalCloudySkyIrradiance.ToString())
   Console.WriteLine("Cloudy hours: " & cloudyHours.ToString())
   Console.WriteLine("Clear hours: " & clearHours.ToString())

   ' Output the weighted irradiance
   Console.WriteLine("Weighted irradiance for decision making: " & weightedIrradiance.ToString())

   Irridiance.Text = CInt(weightedIrradiance).ToString() ' Update UI element with the final value
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 

Offline mag_therm

  • Frequent Contributor
  • **
  • Posts: 783
  • Country: us
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #10 on: September 12, 2024, 01:18:13 pm »
Hi Ian,
you have given some useful information, thanks. I presently only have have a free key to Pyowm which uses OpenWeatherMap.org.
That might explain why the data I can access is so limited.

In case you don't already know : https://openweathermap.org/api/solar-panels-and-energy-prediction

I will subscribe and try using that API on the next python update.
The data logger here polls and updates panel controller every 15 seconds (related to digital ham radio) using linux "watch" .
Logger writes to an SQL. which is saved and restarted every 24 h.
My plan is to write  a better predictor for 2025, then use polynominal regression on the accumulated SQL data to relate actual daily kW.h to the input
parameters eg forecast irradiance ,cloud, season.

I have no UI yet, I just update the .py on the run and use "DB Browser for SQLite" as display.
 

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #11 on: September 12, 2024, 01:27:32 pm »
In case you don't already know : https://openweathermap.org/api/solar-panels-and-energy-prediction

No, I never knew about this.....thanks.

EDIT: £250 per location per month for that one.....:-(
I have emailed them to ask if there is another plan I could use given I need 1 API call per day only.

Ian.
« Last Edit: September 12, 2024, 01:38:37 pm by IanJ »
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 

Offline mag_therm

  • Frequent Contributor
  • **
  • Posts: 783
  • Country: us
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #12 on: September 12, 2024, 01:57:11 pm »
Oh...,
That API  is probably aimed at the grid level battery operators.
This must be a hot topic, how to utilize the battery capacity without leaving them empty at the wrong time.
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7950
  • Country: nl
  • Current job: ATEX product design
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #13 on: September 12, 2024, 03:12:32 pm »
Instead of ChatGPT values, you could start by inserting your system into this:
https://globalsolaratlas.info/detail?c=51.896671,13.658811,6&s=51.996927,4.934442&m=site&pv=small,135,45,4

This is an example, you have to enter your own place, azimuth and elevation.
I would take the DNI values, and somehow multiply it with the weather prediction values.
I'm also using openweathermap for a personal project. Because there was library for their API. But I'm trying to switch to a more open/non-profit service in the future.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8833
  • Country: fi
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #14 on: September 12, 2024, 03:16:59 pm »
Indeed, what the actual fuck:

Code: [Select]
                   ' Figures below from ChatGPT
                    ' Overcast days:  200-500 W/m²
                    ' Cloudy days:  500-1000 W/m²
                    ' Cloudy/sunny days: 1000-2000 W/m²
                    ' Sunny winter days:  2000-3000 W/m²
                    ' Sunny summer days:  5000-7000 W/m²

Use simple Google search instead of ChatGPT:
"typical solar irradiance power"
"Average annual solar radiation arriving at the top of the Earth's atmosphere is roughly 1361 W/m2. The Sun's rays are attenuated as they pass through the atmosphere, leaving maximum normal surface irradiance at approximately 1000 W/m2 at sea level on a clear day."

This 1000W/m² is very well known number. It is interesting how ChatGPT really makes up stuff which is easily googleable and almost never wrong anywhere and thus one would except high likelihood of ChatGPT getting it right, but it doesn't work that way so simply: never use these AI services for anything.
 

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #15 on: September 12, 2024, 04:39:19 pm »
Oh...,
That API  is probably aimed at the grid level battery operators.
This must be a hot topic, how to utilize the battery capacity without leaving them empty at the wrong time.

I got an email back from Openweathermap.org and they said that's the only pricing around the solar-panels-and-energy-prediction API.....sadly.

Ian.
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #16 on: September 12, 2024, 04:43:12 pm »
never use these AI services for anything.

 :palm:
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #17 on: September 13, 2024, 12:28:09 pm »
Hi all,

The first full run based on the irridiance value my software had calculated decided batteries didn't need charged. It was marginal based on my rules mind you between that and 30 minutes only.
Anyways, no overnight charging done and in the morning at 7am I had 20% left.....and not long before the sun started to come up again.
Note: At 12% the batteries stop outputting.

So far so good.....but it will be great to see some much lower irridiance values and test the charging it calculates. Tomorrow it's meant to be a cloudier day.
My energy usage is very uniform, except may Mon/Tues where it is less.

Ian.
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 

Offline mag_therm

  • Frequent Contributor
  • **
  • Posts: 783
  • Country: us
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #18 on: September 13, 2024, 01:20:07 pm »
Good, If you can get a succession of days with variable sun it will allow  adjustment your algorithm if necessary.

Yesterday here was full sun all day which is unusual in Great Lakes region.
Here is the SQL Data of Watt.h over 24 h. Control is presently by UV Index as a proxy for irradiance.
https://app.box.com/s/zycwg8pg9dwzd8i2e749rmyc12j16gny
 
The following users thanked this post: IanJ

Offline Electrodynamic

  • Contributor
  • Posts: 42
  • Country: ca
  • Power Engineer
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #19 on: September 14, 2024, 05:13:44 am »
IanJ
I like your app which is heavy on data. My setup is going in a slightly different direction with esp8622/esp32 mesh wifi, Pi4, Node-Red and Grafana.

I see on your app your using cooler, fan, heater offsets. My home automation setup using central AC, whole house fan, condensing furnace is similar with a few tweaks you might find useful.

Every day we have two widows of opportunity in the morning and evening to short cut the cooling cycles. So if a hot day is predicted my 400w whole house fan kicks in at 6am blowing 16C outside air inside to pre cool the house to around 18C. This is enough cooling to delay my 2.5 kW AC unit from coming on by about 3 to 4 hours. Then in the evening when the outside air temp starts dropping and matches the inside air temp the AC turns off around 2 to 3 hours early and the whole house fan kicks in again. The fan blows cooler outside air through the house and into the attic space reducing radiant heat buildup. So by predicting the load I reduced the AC run time by around 6 hours which could amount to 12 or more kWh's.

The smart grid seems to be moving in a similar direction and we don't need more generation if we can predict and control what we already have in a more intelligent way.

I think your ahead of the curve with your 4kW solar & 10kWh battery system. Intelligent automation, prediction and off peak storage could be magnitudes cheaper than generation in the right context. Even more so if the utilities and governments start playing games like the solar energy crisis in Spain.



 
The following users thanked this post: IanJ

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #20 on: September 14, 2024, 10:10:28 am »
IanJ
I like your app which is heavy on data. My setup is going in a slightly different direction with esp8622/esp32 mesh wifi, Pi4, Node-Red and Grafana.

I see on your app your using cooler, fan, heater offsets. My home automation setup using central AC, whole house fan, condensing furnace is similar with a few tweaks you might find useful.

Every day we have two widows of opportunity in the morning and evening to short cut the cooling cycles. So if a hot day is predicted my 400w whole house fan kicks in at 6am blowing 16C outside air inside to pre cool the house to around 18C. This is enough cooling to delay my 2.5 kW AC unit from coming on by about 3 to 4 hours. Then in the evening when the outside air temp starts dropping and matches the inside air temp the AC turns off around 2 to 3 hours early and the whole house fan kicks in again. The fan blows cooler outside air through the house and into the attic space reducing radiant heat buildup. So by predicting the load I reduced the AC run time by around 6 hours which could amount to 12 or more kWh's.

The smart grid seems to be moving in a similar direction and we don't need more generation if we can predict and control what we already have in a more intelligent way.

I think your ahead of the curve with your 4kW solar & 10kWh battery system. Intelligent automation, prediction and off peak storage could be magnitudes cheaper than generation in the right context. Even more so if the utilities and governments start playing games like the solar energy crisis in Spain.

Looks like you are well under control with your system!........and giving me more ideas!
Whole house fans, house aircons are not a thing here, it's generally too cold. However, I need an aircon in my small workshop to keep the temps under control given the server and test gear located in there......and I need to control temps to within 0.5degC if I am calibrating voltage sources. The reason I control the aircon via my app is down to the Daikin aircon having a 4degC hysteresis using it's own control mechanism! I was just lucky to find it could be controlled/overridden via http after I fitted a wifi module to it.

I used to run an esp8266/Oled display for grabbing the SolarPV and Utility meter power stuff, but changed to an app running on my server PC a couple years ago.
My server isn't the fastest thing on the planet so am always aware that I don't push my app or I/O too hard.......but despite 4 virtual serial ports (3 via Modbus), 2 local http connections, 3 external web http connections, 1 local html webpage generator (so I can monitor from anywhere) and the GUI stuff...............it's holding its own!

Ian.
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 

Online EEVblog

  • Administrator
  • *****
  • Posts: 38717
  • Country: au
    • EEVblog
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #21 on: September 14, 2024, 10:34:46 am »
I've always thought this sort of automation would be cool, but I suspect it's too much trouble, at least for my solution.
e.g. If the battery if full and the sun is still out max then I'd love to be able to automatically switch the pool heater on max and a couple of aircons to energy sink the house instead of feeding back inot the grid.

Even though we have just got out of winter, I already have more than enough solar than I know what to do with.
 

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #22 on: September 14, 2024, 10:38:22 am »
Next set of mods to make next to my app.......hopefully!

1. If battery is depleted enough it won't cover 4pm-7pm then boost charge it in advance (3pm-4pm maybe) from the grid. This is because during those hours the electricity cost from my provider goes up significantly, so it'll pay to boost charge in advance.......DONE.

2. Work out if there is any surplus battery between 4pm-7pm and high irridiance the next day because I get more than I pay for electricity (2am-5am) if I export it back to the grid during 4pm-7pm.



Ian.
« Last Edit: September 14, 2024, 12:24:52 pm by IanJ »
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 

Online IanJTopic starter

  • Supporter
  • ****
  • Posts: 1749
  • Country: scotland
  • Full time EE & Youtuber/Creator
    • IanJohnston.com
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #23 on: September 14, 2024, 10:39:46 am »
I've always thought this sort of automation would be cool, but I suspect it's too much trouble, at least for my solution.
e.g. If the battery if full and the sun is still out max then I'd love to be able to automatically switch the pool heater on max and a couple of aircons to energy sink the house instead of feeding back inot the grid.

Even though we have just got out of winter, I already have more than enough solar than I know what to do with.

Yes, it is a LOT of work!.....I only implemented it because I really enjoy doing it. A true glutten for punishment!

Ian.
Ian Johnston - Original designer of the PDVS2mini || Author of WinGPIB
Website: www.ianjohnston.com
YouTube: www.youtube.com/user/IanScottJohnston, Odysee: https://odysee.com/@IanScottJohnston, Twitter(X): https://twitter.com/IanSJohnston, Github: https://github.com/Ian-Johnston?tab=repositories
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8833
  • Country: fi
Re: Automatic Solar battery charging timings based on forecast weather
« Reply #24 on: September 14, 2024, 11:07:25 am »
e.g. If the battery if full and the sun is still out max then I'd love to be able to automatically switch the pool heater on max and a couple of aircons to energy sink the house instead of feeding back inot the grid.

That one is quite easy. You just need a bidirectional metering (e.g. a MODBUS meter as used by the OP) and then accumulate some counter and once it exceeds some level of export, turn relays on, and turn them back off when the accumulator is getting close to zero again.

If netting period of the contract is known, then zero the accumulator for each period. If netting period is unknown or very short or there is no net metering at all, then it's a good idea to choose loads such that they are not excessively large compared to PV production so that you don't pay for import accidentally.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf