My solar inverter doesn't include any external monitoring or data collection. But it does have an RS232 socket - Raspberry Pi Zero to the rescue! This is a scratch pad page for the project

Raw data from the inverter

The Kaco documentation for the RS232 port is really helpful. The data spec itself is pretty simple - serial settings are 9600 baud, 8N1, no flow control. The data is sent line at a time, every 10 seconds, while the inverter is generating. The data is fixed width, space separated, all numeric, no headers.

An example of the data that comes out is (now taken from my inverter readings on the Pi, yay!):

00.00.0000 06:21:30   5 319.0  3.17  1012 252.0  3.89   971  20
00.00.0000 06:21:40   5 332.0  3.17  1052 251.1  4.06  1010  20
00.00.0000 06:21:50   5 325.3  3.28  1068 251.1  4.12  1025  20
00.00.0000 06:22:00   5 325.1  3.30  1074 252.2  4.12  1031  20

The documentation defines each column in that data:

ColumnDataExample
1Placeholder00.00.0000
2Daily running time07:36:40
3Operating state5
4Generator voltage in V297.0
5Generator current in A2.40
6Generator power in W713
7Line voltage in V251.3
8Line current - grid feed current in A2.78
9Power fed into the grid in W685
10Temperature of the unit in °C22

Data Pattern

Going from the specs and a day of monitoring data (on a cloudy winter day), it appears the data follows this pattern:

  • no data feed at all while it's dark
  • as the first light appears, we start to get status=1 (startup) rows with some voltage and temp readings, but no amps or watts
  • if status=1 readings go on for a while, we may get status=2 (shutdown) rows if the inverter decides the sun is going away again :-(
  • after an hour or so of status=1 and occasional status=2, we start getting status=3 (low power). That includes values for all readings. It appears (a few watts of) power is going into the grid now.
  • after another hour or 2 we start getting status=5 (yay power!) and at least 50W of power going into the grid
  • as the clouds and sun and rain go through we get status=3 and status=5 depending on how much power is being generated.
  • at the end of the day we get status=3 for a few hours
  • after about 9 hours of generating, we start getting status=1 again (dunno why we get "startup" messages as it's shutting down)
  • for an hour or so we get mainly status=1 with a few status=3 and status=2, probably as it got a bit clearer as the sun went down
  • then it's into a run of status=2 for a few mins, followed by no more data, when it's too dark for the panels to generate anything.

The specs say there's potential for a status=0 to appear briefly on first startup - but I guess that may only last a few seconds, so we may not see it if the data spurt happens after the startup sequence has completed.

It looks like a really sunny day may also cause a few status=11, 60, 64 if we generate too much power. But I don't think our system should hit that.

A sunny day in summer may also cause status=10 or 58 (too hot), after which the inverter shuts down for a while, then does a status=57 as it tries to reconnect to the grid. Hopefully we won't see this!

All the other status codes appear to be faults of various kinds, all of which will need reporting.

Monitoring Requirements

don't lose any data, if possible

  • Pipe from Serial (/dev/ttyUSB0) to file in a very simple script that runs on startup.
  • archive and start a new file at end of every day - once readings stop
  • archive and start a new file on reboot
  • trash files after 1 month (assuming MQTT is working). Each day's raw file will be < 250KB so 1 month = 31 x 250KB = 7750KB. Cater for 8MB of data files being kept - no problem on an 8GB sd card.
  • compressing a 250KB data file takes it to about 40KB. A month of those is about 1.3MB. Don't care about compressing for now.

Pass on readings to a separate collector/consumer

  • use MQTT? Seems reasonable
  • One queue to accept the pushed readings
  • multiple consumers
    • construct charts
    • construct summary stats
    • update blinkts
    • send alerts
    • RSS or open monitoring feed?

Stats web page

  • current status: code + desc + alert if necessary
  • latest raw figures
  • today's stats: latest KW, average KW last min & hour, KWh today, max & min temperature, start & stop times
  • historical stats: total KHw (use data from config), total days operating, days since last FIT record
  • chart: KW readings today
  • chart: status codes (follow blinkt colours) today
  • chart: running average KW today
  • Form to record new FIT reading

Replay history

  • Ability to reparse and pass on existing data files
  • insert extrapolated readings for a missing data row (only for missing reading - by averaging)
  • construct timestamps for the data as it's read from the files
  • push data into the same MQTT queue
  • construct

parse data for sanity

  • data parseable
  • values within max/min bounds
  • parse error codes

clean & instrument data before passing on

  • add timestamp for each reading
  • add error info
  • add generator efficiency (power-out x 100 / power-in)
  • strip placeholders
  • calculate KWh so far today? Or since last reading (using averages)? Or leave for consumer?

blinkt monitoring

  1. power generation - status good, green for over 90% of max capacity, shade to red for under 10%, off for 0%
  2. status - bright green=good (status=5), light green=low power (status=3), yellow for startup/shutdown (status=0,1,2), red for minor/temporary fault code, blue for serious fault code, off for not generating
  3. temperature - green=5<T<30, yellow=30<T<40, red=T>40, blue=T<5, off for not generating
  4. data - green=last data written and passed on ok. yellow=parse fail. red=data not passed on. blue=file write fail.
  5. wifi - green=connection up & signal strong, shade to red as signal fades, blue for fail
  6. system - green=ok, yellow=high CPU/mem, blue=low disk, red=serial problem
  7. ??
  8. heartbeat - on white when data received on serial, purple when writing/parsing, blue when sending on, green on updating status/blinkts, off when finished.

Previous Post Next Post

© Me. Best viewed with a sense of humour and a beer in hand.