Some Bits: Nelson's log

16 posts about solar

Sunpower solar for 2024

I’ve had my house solar system in Grass Valley for three full years now. It’s working great, just as designed. Some quick data:

YearProduced (kWh)Used
20241559416543
20231537314688
202217700?16000?

2023 and 2024 data are from the MySunPower app. I don’t have full data for 2022 so the numbers are estimates from PG&E’s usage data. I suspect PG&E’s numbers are just larger than what MySunPower measures and have no way of knowing which is accurate. I should go back in a month when PG&E’s accounting has settled and try to collect the data from them.

Anyway, comparing 2023 and 2024 I generated about the same power both years. But I used 1855kWh more. 1336 of that is charging my car.

The car is new for 2024. I charged it another 679kWh in San Francisco, so a total of 2100kWh for the year. I was guessing it’d be about 3000kWh so that’s better than I expected.

Update: NEM true-up

Just got the surprise $700 electric bill, the true-up for the year. The bill is very difficult to read and I can’t make sense of it, but it’s roughly correct(ish) so I’ll go with it.

The actual charge for “NEM Electric charges” is $630.95 for 579.3 kWh. That doesn’t really square with the $695.26 for 121 kWh in the monthly breakdown.

SunPower bankruptcy

2024 is the year SunPower went bankrupt. A lot of operations seem to be continuing. But the mySunPower web application is broken now. Near as I can tell the SSL certificates expired, plus maybe some servers are down. No word on if it will be back. The mobile app is still up though, here are some screenshots from it.

A full year of solar

I’ve had my solar system for just about a year now, time to collect full data.

In 2022 PG&E says I netted -1670 kWh. I used 16,000 kW in 2020 and 2021, so I generated about 17,700 kWh this year. Or just about 10% over my usage. My electricity bill should be 0, or maybe even a tiny bit negative.

My solar system was designed to generate 16,600 kWh a year (with 28 * 410W = 11.5kW of panels). So I generated about 7% more power than expected. Not complaining! I am also glad to be generating a bit more power than I use because I intend to convert to electric heat pumps and cars eventually. Although I don’t really have that much excess power...

Above is a graph of daily net power, based on PG&E’s data. You can see the seasonal effect very clearly. I’m net negative quite a bit in spring and summer. I start using more than I make in August and September, to run the air conditioner. (I was out of town in October, hence much less power usage.) I go full net positive once the days get shorter and the sky gets cloudier. It’s nice that my NEM 2 rate plan nets me out over a full year; it’d suck if they trued up once a month.

I was hoping to have better data with the fancy PVS6 monitoring software I built. That worked great right until the day the PVS6 died, stopped talking to the Sunpower servers. No idea what happened there. They eventually just replaced it for me and I haven’t plugged in my little Raspberry Pi to exfil the data since. I have no idea if my monitoring broke it but I don’t want to chance it. Honestly the kind of minute-by-minute data I was getting from the system isn’t very useful anyway, daily summaries are good. Sunpower’s website should give me that but like I said, only started getting good data in September. (Also their website is awful but I bet there’s a data download somewhere.)

Very glad I got solar, wish I’d done it sooner. My system will pay for itself in about 7 years total. The deal under NEM 3 isn’t nearly as good for California consumers, I’m lucky to have gotten in when I did.

Update: true-up bill

Got my bill which contains the full year’s “true-up” for my NEM 2 solar system. I don’t honestly understand much of this. But they agree that I supplied about 1800 kWh more power than I used and paid me the $0.06/kWh or so I expect. (Note they charge $0.40/kWh for the same electricity, but at least I zeroed that part of the bill out.) Also something like $5/mo for delivery charges, eh.

Battery backups: UPS, battery generators, etc

I’ve learned a surprising amount about how to have battery power for when the AC power goes out. Some summary notes.

One important stat: “transfer time”. That’s how long it takes for the backup power to kick in. You need this to be fast if you don’t want the device to turn off and on again. For reference, 60Hz power cycles every 16ms. UPS units are the only ones I know of fast enough that a computer won’t be interrupted when the power goes out. You can use a UPS along with one of the bigger and slower backups.

Many of us have good ol’ UPS units to keep our computers up in momentary power outages. My favorite consumer brand is Cyberpower. These are typically sold by max power + runtime and it’s hard to find how many watt-hours are actually in the battery. There’s a surprising variety of types of UPS units. I now buy PFC Sinewave units that condition the AC power and produce a nice clean wave. As a side effect this makes the UPS work better when on dirty power like a generator; with a cheaper UPS on generator it would switch to battery backup every few minutes. Transfer time on a UPS is < 10ms and consumer devices shouldn’t even notice.

Gas or propane generators. I have a Generac Guardian 22kW for when PG&E takes our power out for hours or days. These are expensive and terribly inefficient, particularly when running at low power. They also put out pretty uneven power; when they get loaded the 60Hz briefly slows down to 58Hz or whatever. But if you need to be off-grid for days at a time they are the most practical choice. I paid $15,000 for mine. It’s rated for 3000 hours, so that’s $5 / hour! Although presumably it can be refurbished? Transfer time is ~15 seconds, everything will turn off before it switches on.

Battery generators. These are a new class of product that replace portable gas generators, basically a very fancy lithium battery with an inverter. I have an EcoFlow Delta 1300 that PG&E gave me to avoid liability for my power going out. These are really capable devices, absolutely excellent for being off-grid for a few hours. They charge via AC and also come with the circuitry to charge via solar panels or electric car chargers. I’m impressed with mine as a product. One drawback; you need to drain the battery occasionally to avoid it wearing out. Also the transfer time is 30 ms; fast, but not fast enough to keep your computer on. It’s not a UPS.

Whole house batteries. These are the fancy things like the Tesla Powerwall. I don’t have one but wish I did. They’re expensive as backup power, a gas generator is a lot cheaper. I’d particularly like to have a small battery, just like 4000Wh of capacity or something. Enough to bridge an hour long power gap and let me keep my solar running; during the day I can charge it faster than I’d use the power. Last I looked no one made a small product like this. Not sure about transfer time; I think the Tesla Powerwall is slow enough everything is turned off briefly.

One extra note: all these systems I use are focussed on providing AC power. But 90% of what I care about plugged into it runs off DC power, it’s dumb to have a battery, an inverter to produce AC, and then a transformer to swap back to DC. The EcoFlow Delta has serious USB charging circuits. I suspect it’d be possible to get adapters to power things like network routers off those USB ports and that might be more efficient.

California electricity grid; resource adequacy

California has its own electricity grid, roughly independent from other states. The California ISO that runs it has an excellent dashboard (and mobile app) showing grid status, predicted demand, the march towards renewable energy, etc. It’s very well done, I think a response to the chaos around the year 2000 when we didn’t have enough electricity for the state.

We’re about to have a very hot week so I looked in detail at the 7 day resource adequacy graph. What this means is documented mostly here.

There’s two datasets: graphed in teal and purple respectively. Teal is more or less actual power. Dashed line is forecast capacity; it fluctuates mostly with solar. The faint dotted line is forecast demand; it fluctuates mostly with air conditioning need and evening home demand. What this is showing us is that towards late afternoon on 9/4, 9/5, and 9/6 we’re going to have a little more demand than supply. That’s not a catastrophe; CAISO can buy power from other states, at least assuming any is available.

The purple graph is the same data but excludes wind and solar from production, that’s why it’s so steady. (It also excludes something from demand but I’m not sure what). An added complication are “credits”; I’m not sure what those are, but if you visualize them they’re only about 2GW out of 55GW.

It’s worth noting that these are predictions, promises of what the electricity providers are telling CAISO they can generate. I believe they’re obligated to actually supply all this promise, the shortages in 2000 and 2001 was partly because some of the generators were playing games with supply to manipulate the market.

There’s a lot of other neat data on the CAISO site, particularly the supply pages that highlight renewables. May 8 2022 was a banner day: we had enough solar and wind to cover all demand, so fossil fuels dipped very low. (Not zero, but we exported more power than we generated in fossil fuels. I assume that was a choice made for financial reasons.) Alas this is only possible in late spring when solar is high and demand is low.

Another interesting dataset are the curtailment reports, times CAISO tells solar or wind providers to stop providing power because they have no place to put it. It’s not a huge amount of power and seems mostly to do with local bottlenecks, not pure overcapacity. Exta power first goes to batteries and pumped hydro.

One thing CAISO doesn’t provide much is graphs of trends over year; they’re very focussed on intraday reporting. They do publish monthly reports with data in PDF format.

PG&E solar billing; two channels

Did you know PG&E smart meters have multiple channels? “Channel A represents energy pulled from the grid” while “Channel C represents energy exported back to the grid”. Weird! Details below.

PG&E screwed up during my solar period and for 6 months even though their records showed I was sending them more power than I was receiving, they were billing me for $200 worth of electricity a month. I eventually got a refund but I made a CPUC complaint about what looked like abusive and fictitious billing.

To PG&E’s credit they got in touch with me to resolve my complaint and I had a chat with a knowledgable customer agent who gave me a clear answer. Here’s how CPUC summarized it:

PG&E advised that NEM customers are billed with interval data using 2 channels on the SmartMeter: Channel A registers consumption, while Channel C registers exported generation.

The PG&E docs show pictures of bills with breakouts by channel, but I can’t find that in my bill. But the docs I’ve found online are 15 year old, many for NEM1 (I’m on NEM2) so maybe it’s not available now, or I won’t see it until my yearly true up.

I can’t make any sense of how this would work electrically. AFAIK my solar feed was installed with vampire taps between the meter and the circuit breakers; there’s no separate wire coming in from my solar directly to the meter to record. Maybe the two channels are more of a synthetic thing, with A being the sum of watts used during intervals that are positive and C being the sum of the negatives. Or maybe there’s some magic in the energy grid that can detect flow? I doubt it.

The funny thing about all these attempts to verify what PG&E is saying is they come to nothing; you’d never prevail in a dispute over how they bill. My Sunpower monitoring regularly shows me about 1kWh a day better off than PG&E bills me. Flaky meters? PG&E skimming? Who knows. The PG&E data looks roughly accurate though and they are effectively the law, so not much point second guessing it.

Sunpower PVS6 web console

The Sunpower PVS monitor has a full HTML web console accessible on its internal network. The PVS acts as a full Internet router on a debug ethernet port you can plug into. If you plug a laptop into it the laptop will be online (routed through the PVS) and also serve extra stuff at http://www.sunpowerconsole.com/. It’s mostly a web view of the data in the JSON API but it’s an official debugging tool and is quite nice.

I have my RPi plugged into that debug port and am proxying all web traffic, so on my LAN I can access http://pvspi0.local/ and get at these pages.

Here’s a list of URLs that it supports. These come from this detailed comment which also describes what these URLs do. A lot of these are steps on a little configuration wizard that presumably installers use. I think all these URLs are safe to load but some clearly have buttons to press that could reconfigure or break your system. Don’t press those.

The info view is particularly good; here’s a partial screenshot (I didn’t include the serial numbers.) Three sections: the PVS as a whole, per-panel/inverter data, and then CT monitors.

Solar panel max output, microinverter details

My solar system is mostly doing great. But I’m obsessing over small details and one thing I’ve noted is some (but not all) of my panels seem to max out or even underperform in the middle of the day by 5-10%. I’m trying to figure out why.

Panel 2122: expected
Panel 9897: clipped in the middle

Above is a graph of two of my 28 SunPower SPR-A410 panels with SPR-A410-G-AC microinverters. These were built and installed in 2021. The graph on the left shows what I’d expect; a steady increase in output following the sun. The panels face west, so it’s not a symmetric curve. The falloff end of the day is shading.

The graph on the right is the weird thing; the DC power gets up to about 300W and then sticks there, even dropping down a bit to under 290W. It does briefly get to 334W at the end of the day, so it’s not some absolute max. It’s like that’s the max output of the panel is being limited somehow. It looks like 15 of my 28 panels do this, the other 13 have the smooth curve. It’s clipping about 10% of power production for the middle part of the day, so maybe 5% of a panel’s possible output or 3% of the whole system.

I know a 410W rated panel will never actually put out 410W. But how much should it put out? The maximum I’ve ever seen is 385W (DC) or 367W (AC).

But what I really want to know is why some panels do this odd clipping thing when others don’t? Some theories:

  • Shading. I really don’t think so, both on visual inspection and also just looking at the pattern.
  • Overheating. That was my first theory but the temperature graphs don’t really bear it out.
  • AC conversion. There’s no obvious difference in the AC vs DC power for the panels, they all look to have about the same conversion efficiency. The clipping pattern is visible in the DC as well.

Some things to do next:

  • More statistical exploration. Is it the same panels doing the same thing every day? Is the effect consistent day to day?
    select SERIAL, max(p_mppt1_kw) from pvs6_inverter where SERIAL='…9897' group by time(1d);
  • Get out the map of which panels are installed where and see if there’s a spatial correlation.

Data Details

I’m pulling this data from the SunPower PVS6 device_list API call which is accessible from the device itself. It reports the following variables for each microinverter at each panel:

  • Status: STATE, stat_ind. Always “working” or “error”
  • Temperature: t_htsnk_degc.
  • Cumulative production: ltea_3phsum_kwh.
  • Instant power measurements: p_3phsum_kw, p_mppt1_kw
  • Instant current measurements: i_3phsum_a, i_mppt1_a
  • AC frequency: freq_hz
  • No longer available: v_mppt1_v vln_3phavg_va

The interesting measures here are temperature and power in kW.

Power (and amperage) are reported both for DC power (mppt1) and AC power (3phsum). DC is always(?) the higher number so I assume the small difference is a measure of microinverter inefficiency. Which seems to be about 5% when the panel as a whole is producing about 300W.

Updates

This pattern didn’t happen on 2022-06-21, a fully sunny day. The only real difference I can think of is that my house was using more power; very hot day, AC running. So there’s more load in the house. But surely that doesn’t matter, PG&E will absorb however much power I can produce? Anyway here’s a graph of 9897, the problem panel above. All of the panels look like this this day.

9897

My custom solar monitoring system (PVS6)

I’ve been tinkering with monitoring my solar system and have come to a fairly nice useful setup. Time for a post documenting where I am. The details on how I did all this are in previous blog posts but I’m summarizing here. Some code in this gist.

The Display

Daily view

The daily view is focused on giving me a basic picture of my electricity usage. Green is production for the day, black is the PVS6 measurement of net (ie: production - consumption). Yellow is PG&E’s own view of net. I suspect PG&E’s data may be more correct; I’m not sure if the PVS6 CT sensors measure reactive loads correctly. Doesn’t much matter anyway; PG&E is the authority whether they are right or wrong. Mostly I just care that they are close. (Jan 7 is a data measurement anomaly.)

Minute-by-minute view

This view gives a lot of detail minute by minute. The top panel is a detailed view of production and consumption, what is a single bar in the daily graph. The second graph compares production to a forecast. Below that are details of individual panel production. The individual sparklines towards the bottom are fun; the panel in the upper left goes to 0 in the morning in the shadow of the chimney on my roof. At the bottom is a simple sparkline of lifetime net production, I had a little party when it passed 1MWh.

Implementation

The data import code is all in this gist. The Grafana panels are not shared anywhere, sorry.

Here’s all the places I’m pulling data.

  • PVS6: the Sunpower solar monitoring system
  • PG&E: manual downloads via their “Big Green Button”
  • Predictions: forecast.solar

The whole system is built with Telegraf collecting the data into an Influx database and a Grafana dashboard to visualize it. What a great set of tools those are! A real pleasure to learn and work with.

The PVS6 stuff is the bulk of it. Turns out Sunpower has a JSON endpoint on a web server in your PVS6 and folks have worked out how to interpret the data. It’s pretty hacky; I’m using a Raspberry Pi to proxy the data onto the rest of the network. I’ve written a ~200 line Python script to collect the JSON data from the PVS6 every minute and emit it in Influx wire format for import. It also does a little analysis within the minute’s dataset to facilitate easier graphing.

The PG&E import is a very simple bit of Python code that converts PG&E’s data into Influx. I have to do this download by hand in the website right now. They do have an API but it requires some sort of signup I haven’t tried to do yet. I should add that PG&E’s Big Green Button CSV export is really quite good. The CSV data is clean and simple. And they have history! I was able to get 9 years of this house’s electricity usage. Nicely done.

The forecast.solar import is also very simple. They have a easy-to-use API where you tell them your location and the size and orientation of your solar system. Then they give predictions for power generated, including weather-corrected. The free version of the API is fine for this use; I download a new prediction every six hours.

Next steps

I plan to keep tinkering with the data display. I suspect as time goes on I’ll be more interested in the daily summaries than the per minute view, so I’ll probably pay more attention to that.

It’d be nice to automate the PG&E data download.

I’ve had some thought about packaging this all up as a Raspberry Pi image. I think the whole thing could run on pretty much any flavor of RPi, it’d be like an add-on to the PVS6 with a nice local web dashboard. But that’s a lot of work and I have zero interest in offering a product that uses an unauthorized Sunpower interface. Sunpower has a fairly decent monitoring website with something much like my daily summary view. They also have tools for installers showing per-minute data. Those aren’t available to end consumers, I think on purpose, and I suspect they would not be thrilled by me offering a competing product.

Solar sparklines

Look at all this free electricity! Time scale is 6 hours. These are 410W panels which in practice seem to max out about 320W AC, or 350W DC before the inverter takes its share. This is from Jan 13; maybe I’ll get more in summer.

Debugging a WiFi problem

Still tinkering with Raspberry Pis and my Sunpower PVS6 solar controller. I had it all set up with a new RPi Zero 2 W when I had a new problem; the WiFi was flaky. It kinda sorta mostly worked well enough, I could get the HTTP requests through to it usually. But ping was showing 40% or more packet loss with a latency of 200+ms. I have a very clean WiFi environment, that should be 0% loss and 2ms latency.

A whole lot of testing later and I established that the problem is some sort of interference on 2.4GHz Channel 1, but only in my garage near the Sunpower box. That corner also has all my other ethernet equipment, is where the generator and solar feeds come in, and where the utility power and electrical panel are. So a lot of wires. None of that stuff should interfere with 2401-2423Mhz and there are a lot of mysteries still.

Switching my access point to channel 3 (2411-2433Mhz) seems to solve the problem. Part of the root cause of my troubles is I’d pinned the WiFi channel in the garage to 1 a year or more ago, I forget why. I’ve now set it to auto. I’ve had experiences where it seemed to be working for a few hours at a time before, so I don’t fully trust it yet. Edit: after rebooting the AP went back from channel 3 to 1. So I’ve configured it to hardcode channel 3 instead of “auto”. Whatever the interference is, the Ubiquiti hardware isn’t detecting it.

The most useful thing I did in the end was get 2 access points and 3 clients and try moving them around every few hours to see what triggered the problem. I used telegraf to ping them once a minute or so (but see below) for long term monitoring, and then occasional command line pings once a second for short term testing. Over two days I was able to narrow the problem down to the one channel in the one location, but it’s not related specifically to any particular hardware.

Some things I learned:

  • wavemon is a helpful tool on Linux for showing WiFi status. so is /proc/net/status and learning all the arcane options to the iw command.
  • The UniFi dashboard has some decent stats of its own hidden away under “Air Stats” for each individual access point device.
  • WiFi has its own link layer retransmit; lots of those might account for higher latency. But I don’t know what timescale it is on: 1 ms? 500ms? You can see WiFi retransmits in wavemon as “failed” and in Air Stats as “retry”.
  • Despite all these diagnostics none of them really showed me evidence the link was bad. All the basic link quality reports were 90% or better. No ridiculous number of retries (although it is 16% at the access point.)
  • Linux machines, including RPis, need to be configured for the country for wifi to work at its best. Particularly important for 5GHz.
  • Even with a perfectly good 5GHz channel available an RPi4 might still choose 2.4GHz. I could not find a way to reliably coerce it to use 5GHz.
  • Raspberry Pis have a variety of low power optimizations that mean they may not respond well to a ping every minute when otherwise idle. My RPi4 regularly takes 100ms to answer the first ping, then is a solid 2ms after. My original RPi Rev B just misses pings entirely if nothing else is happening on it. The RPi Zero 2 W seems pretty solid but then I’ve got it doing other real computation. Anyway my once-a-minute ping was showing phantom errors where there were none. A once-a-second ping test worked better.
  • There’s a power saving mode in the RPi radio hardware itself you can turn off with iw.
  • Raspberry Pis may in general just not be very good at wifi.
  • Don’t use mDNS names for ping testing. The mDNS query itself may get lost to a flaky / low power Pi and you never find the host.
  • TCP retransmits hide a lot of sins. But it only works right until it doesn’t. When my WiFi link was bad about 5% of my requests wouldn’t get through at all.

Customizing a Raspberry PI Zero 2 W for PVS6

Awhile back I set up a Raspberry Pi to be a gateway to get access to my SunPower PVS6 monitoring system. That’s going great; the extra status info is really helpful and interesting. (Bonus screenshot below). I just bought a Raspberry Pi Zero 2 W to be the new computer for this. It’s so tiny it’ll fit entirely in the PVS6 box, powered by the USB that’s in there.

It works! The wifi is pretty flaky, despite me getting an amazing -30dB signal. It seems to be a problem with one specific access point, need to tinker some more. (Update: it may be wifi power saving.) The cable mess is pretty janky but it’s going to be shut inside a box, not sure I care. A smaller ethernet adapter would sure be nice.

Here’s my detailed software notes on setting this up.

  1. Mostly I’m just following this guide
  2. Use the RPi image installer to burn RPi OS Lite to a new SD card. Note this is a 32 bit OS.
  3. Create and configure a wpa_supplicant.conf file on the DOS partition of the SD card
  4. Create an empty ssh file on the DOS partition
  5. Boot the RPi, find its IP address via my DHCP server. (The name raspberrypi.local might also work.)
  6. Log in with ssh as pi/raspberry. Ignore locale complaints.
  7. Change the password for pi
  8. Become root
  9. apt update; apt upgrade. (This takes awhile!)
  10. Enable console autologin using raspi-config
  11. Fix locale using raspi-config
  12. Change the hostname to “pvspi0” using raspi-config
  13. Edit /etc/dhcpcd.conf so the ethernet is not used as a gateway
  14. apt install chrony
  15. apt install avahi-daemon
  16. Disable wifi power saving
  17. Reboot the pi
  18. Log in to pvspi0.local using pi/newpassword.
    Note mDNS takes awhile to start working, a minute or two after the RPi starts up
  19. Install haproxy
  20. Configure /etc/haproxy/haproxy.cfg. I did not include stats.

A brief note on power consumption. Idle the RPi Zero 2 W seems to use about 165mA (at 5W). Running stress-ng -c 4 peaked at 570 mA. The magic number here is 500 mA, that’s the minimum power for a USB port. I expect the system to basically be idle all the time so I think I’m safe with no extra measures. But some ideas on reducing power consumption.

  • Turn off HDMI. Instructions don’t work.
  • Turn off LEDs
  • Use fewer than 4 cores
  • Turn off unnecessary daemons. bluetoothd, hciattach (the serial console)

Here’s the bonus snapshot of some of my Grafana config. Not running on the RPi; all its doing is proxying requests. These graphs are centered on showing the status of all 28 separate panels, something you can only do by accessing the PVS6 data directly.

Small multiples in Grafana

I learned how to make lots of little graphs in Grafana 8 today. It’s a bit strange but I figured it out thanks to this video on variables and these docs. Here’s a visualization of the power production of all 28 solar panels on my house. Some of those panels aren’t doing a lot of work in the morning; hope it’s better in the summer!

The first step is to declare a variable. You do this in the dashboard settings. In this case I wanted to create a variable named “inverter” which has 28 possible values, one per serial number. I’ve already stored the serial numbers as tags in my Influx data so this Influx Query will get at them

show tag values from pvs6_inverter with key=SERIAL

When you do this Grafana will magically add a little selection UI to your dashboard. You can configure whether there’s an “All” option and whether multiple sections are allowed when you define the variable.

Then you need to make a Grafana panel for the graph that is parameterized by that variable. This is as easy as adding a where SERIAL =~ /$inverter$/ to the query for the graph data; you can do this via the graphical query builder. Once you’ve done this you can choose which graph you want to see, but there’s still only one panel with one graph.

The last step is to enable repetition. This is under “Panel Options / Repeat Options”. You choose which variable to repeat by, then what layout you want. “Horizontal” actually means vertical too; I have it set to 6 max per row and it creates multiple rows automatically. Then go back to the dashboard view and select “All”. You should see all your panels. It’s a little wonky about reloading on changes, you may have to do something to force the UI to refresh.

The last bit of polish I did was to remove all the decorations from the graph I could to get it to display more densely. No title, hide the legend, no Y axis. I switched to the Graph (old) widget because I couldn’t figure out how to hide the X time axis in the new Time Series graph. The only thing I couldn’t do was change the padding of the graphs themselves; there’s more whitespace than I’d like. But it’s not bad and I appreciate how much UI work Grafana does, so nicely.

InfluxDB 1.8 schemas

I’m using Influx more and more for system monitoring. I’m setting up a new system to monitor my solar system and realized I don’t understand Influx data schema. Here’s my notes, based on the docs. This is for Influx 1.8; I think it’s broadly the same in Influx 2 but I’m not sure. Their docs are really quite good but I had to summarize it here to understand it.

Influx schema concepts

I’m going to follow those docs’ example: you have two scientists (langstroth and perpetua) conducting a census, recording observations in two locations (1 and 2). Each observation records two things: the count of butterflies and the count of honeybees. Observations are timestamped. Note the term observation is something I made up; it’s not an InfluxDB term. The question is how you store a bunch of observations in Influx.

Influx feels a little free-form and schemaless but really it’s pretty structured. Each observation is a row. Every row has a bunch of columns in it that boil down to key/value pairs. Rows can have different numbers of columns in them. Here’s all the components of an Influx schema

  • Measurements. These are more or less like tables in databases. You have one Influx measurement for each observation. In a traditional relational database you’d have a table per kind of data and a row for each observation. In our example there’s one measurement called “census” that records all the observations.
  • Timestamp. An integer, in nanoseconds. Signed 64 bit numbers from the years 1677 to 2262. In a table database you’d have a column named timestamp. It’s probably indexed.
  • Fields. These are the measured data for each observation. Fields have keys (names like “butterflies”) and values (numbers like 12). Field values can be strings, floats, integers, or booleans. In a table database you’d have one column per field with the column name being the field key and the values being the field values. There’s probably a lot of different values for field values. Field values are not indexed.
  • Tags. These are labels for the observations. Tags also have keys (names like “scientist” or “location”) and values (strings like “langstroth” or “location 1”). In a relational database you’d also have one column per tag, named by the tag key and with the tag value stored in the row. There’s probably only a few values for tag values. Tag values are indexed.
  • Series. A series is the name for all of the measurements that match the same measurement name and tag values. A series isn’t a thing you create explicitly, it’s implied by the set of values of tags. Ie: one series is “all of langstroth’s observations in location 1.” There’s no direct analog for a series in a relational database, but it’s the kind of data you’d regularly query.
    select timestamp, butterflies, honeybees from census
    where scientist = langstroth and location = 1

InfluxDB is schemaless in that you can create new series without having to define them first. Insert some new data with a new measurement name and tag values and it will make a new series. Each measurement can have its own collection of fields with values of various types.

In practical use it’s a pretty close match to how we use tables for storing observations in a relational database. The big difference is the distinction between tags and fields; some of the columns are independent variables like who took an observation and some are dependent variables like the count of butterflies.

Designing my solar schema

Going back to my solar monitoring project, the whole reason I’m looking at this is the code I found creates a whole lot of measurements when I think it should create one.

For example there’s a measurement named “sunpower_pvs_inverter_operating_frequency_hertz” and a different one named “sunpower_pvs_inverter_heatsink_temperature_celcius”. Each measurement then has a single field typically named “gauge” where the actual data is stored, a number like the temperature or frequency. That feels clumsy to me, maybe it’s a consequence of the data being cast in Prometheus format?

To me it feels more natural to have a single measurement named “sunpower_pvs_inverter” and for each observation to have two fields with keys “operating_frequency_hertz” and “sunpower_pvs_inverter”. Each field would store the data directly; no “gauge”.

I agree more with the tag design of the code I found. For instance I have 28 inverters and these are represented in the data with tags like device_id=E00100128000007. But they went overboard with tags; there’s separate tags for software version, URL the data came from, etc. This might come in handy with a complex hetereogeneous system but it’s confusing complexity for my simple system.

Here’s the schema I think I want. It kind of tracks the schema implied in Sunpower’s own JSON output from the device_list call. Just four measurements.

PVS status. This is information on the monitoring computer itself. No tags needed, some field keys:

  • SWVER dl_err_count dl_comm_err dl_skipped_scans dl_scan_time dl_untransmitted dl_uptime dl_cpu_load dl_mem_used dl_flash_avail

Production. This is measuring data from the PVS6 CT sensors on the solar power production power line and has type “PVS5-METER-P” in the JSON. I don’t think I need any tags at all for this. Some field keys I will record values for:

  • STATE p_3phsum_kw net_ltea_3phsum_kwh freq_hz s_3phsum_kva q_3phsum_kvar p_3phsum_kw

Consumption. Again CT sensors, this on the house consumption side independent of the solar. This has type “PVS5-METER-C” in the JSON. There’s two values for many things because I have a split phase system with different sensors on each side. Some interesting values:

  • STATE net_ltea_3phsum_kwh p_3phsum_kw q_3phsum_kvar s_3phsum_kva freq_hz i1_a i2_a v1n_v v2n_v v12_v p1_kw p2_kw neg_ltea_3phsum_kwh neg_ltea_3phsum_kwh

Inverters. This is the detailed data from each solar panel, there’s one JSON block for each of 18 panels. Some values:

  • STATE SERIAL ltea_3phsum_kwh p_3phsum_kw vln_3phavg_v i_3phsum_a p_mppt1_kw v_mppt1_v t_htsnk_degc freq_hz

Inverter rollup. I might want to add a synthetic fifth measurement, something that summarizes the state of all the inverters. You could do this at query-time in Grafana or whatever but it’s probably easier to do it in the Python code which is collecting the data. Probably this is what I’d actually graph; trying to draw 28 different inverters separately seems like a mess. Some possible measurements

  • Count of working inverters
  • Sum, average and S.D. of inverter kW (both AC and DC)
  • Number of inverters well below average kW
  • Sum, average, and S.D. of inverter voltage and current (both AC and DC)
  • Average and SD of inverter temperature

I think in all cases the timestamp should be when my own monitoring code ran. Each bit of JSON data in the PVS output has its own timestamp and I bet that can matter sometimes, say if an inverter isn’t communicating correctly. But I could imagine a lot going wrong too; I trust my own clock more.

A big question for me is if I should try to filter and reprocess all the data coming from the PVS6 JSON. Or just insert it more or less as-is. Filter each JSON item into either a tag (“SWVER”) or a field (“killowatts”). That means inserting a bunch of junk into Influx I will never care to query. But then again it means not losing data, either.

Data meanings

This has nothing to do with Influx but I was trying to understand what some of these data values mean.

“LTEA” seems to stand for “life time accumulator” and is one of the few (only?) bits of data that has history. Most of the rest are instantaneous values; current watts, not watt-hours.

“3phsum” seems to refer to three phase power, presumably the sum of all three phases so you have a single number. I think my inverters are simple single phase so this doesn’t really apply, but maybe they use that word for consistency with other products. The only measurements of wattage are labelled “3phsum” so I’m gonna just ignore the details.

Getting local access to SunPower PVS6 data

Tinkering with my new solar system. The install includes a fancy SunPower monitoring system called a PVS6. SunPower has a decent website which gives you current conditions and hourly history of energy production. But I want more detailed data! And thanks to this guide I’ve got access and am starting to unpack what all is there. This GitHub project also has lots of notes and this PDF is quite detailed.

Access to monitoring data

The PVS6 has a web server with stats you can access over the network. The trick is you have to use the LAN1 installer port to get to it. You don’t want to just plug it into your network; it has a DHCP server of its own that might make mischief. So instead I set up a Raspberry Pi with haproxy to forward HTTP requests to the PVS6. The guide I followed has detailed instructions and now I have access to the PVS6 web API.

So what’s there? The notes here are a detailed guide. The main command for monitoring is DeviceList. Apparently most of the data updates every 15 seconds. The JSON output is complicated, but it boils down to a block for the PVS itself, a block for each CT sensor measuring overall electricity flow, and a block for each inverter (28 microinverters for me). Note it’s pretty slow, about 6-7 seconds to answer a DeviceList query.

The numbers I get from the PVS6 do seem to match what SunPower shows me in their consumer app.

sunpower-pvs-exporter

At this point I took a left turn and decided to install this monitoring setup. It’s a Python project that creates a Prometheus service from the PVS6 data, which Telegraf can import. The project also includes some Grafana dashboards. Looks nice!

I installed sunpower-pvs-exporter directly on the Raspberry Pi, no need for haproxy in the path. Then I set up telegraf to query it (just need to configure the URL) and insert the data in to InfluxDB. The resulting schema is a bit messy; Grafana is now polluted with lots of measurements with names like sunpower_pvs_power_meter_net_energy_watt_hours. And a whole lot more series inside that, and the values all are named “gauge”. Not awesome but I can work with it.

Unfortunately importing the sample dashboards from the project did not work. Some config did come through but not the queries. (Schema mismatch?) I hand-edited a few and got some stuff working but it’s not great. Also the schema is not a great match for Grafana so the queries are pretty contorted. All told I got discouraged at this point; if I’m going to have to do this much hand-work I might as well write my own code to pull data straight from the PVS6 JSON and output it in nicely aggregated Influx format.

Mysteries

My solar install has something weird; their estimate of my usage is wrong. They seem to think that in the middle of the day I’m using 6kW, 3-4x more than I use. Also usage goes up with solar power. I think maybe the CT sensors aren’t installed correctly. Or maybe this has something to do with not being fully activated at PG&E? The electric meter display looks correct, just not the SunPower monitoring, so I’m thinking I have an install problem.

The other confusion is arithmetic. I have one CT power meter labelled “GROSS_PRODUCTION_SITE” and one labelled “NET_CONSUMPTION_LOADSIDE”. That’s what’s graphed in the picture above, those two numbers. But note that’s net consumption; if you want gross consumption you need to add those two numbers. That’s baked in to the sunpower-pvs-exporter’s queries but it confused me at first. Particularly since my net consumption numbers from the power meter seem to be wrong.

jq

I took a quick crack at getting basic wattage output with JQ. This dumps the wattage of all the things in my report; the two meters and also the individual inverters.

jq '[.devices[1:][].p_3phsum_kw? | tonumber * 1000 | round] | @csv'

p_3phsum_kw appears to be the actual AC power production. I assume that means “3 phase sum”. It seems to account for reactive loads.

Thoughts

At this point I’m declaring victory for the day. I’ve got access to the data. I still need a system to massage it and import it into InfluxDB and I don’t think sunpower-pvs-exporter is it for me. Too many problems. Telegraf’s JSON plugin might be sufficient but I’ll probably end up writing my own Python code so I can massage things as desired. In particular I’m trying to think how to handle the data streams for all 28 inverters, that seems a bit unwieldy.

Some solar calculations

I just got solar installed on my roof in Grass Valley, CA. 28 SunPower SPR-A410 Panels for a nominal maximum of 11.5kW. I’m not officially done yet but in testing it seems to be working and I’m enjoying the spectacle of my meter running backwards. Looking forward to getting access to SunPower’s monitoring software and hopefully lots of data.

In the meantime I was curious what to expect for power generation. NREL has an excellent calculator called PVWatts that takes precise details on the panels orientation, location, etc and estimates how much power you’ll generate. It takes into account local weather, various inefficiencies in the system (I’m calculating a total loss of 11.5%), etc. Anyway the final number they give me is just about 15,000 kWH in a year. The proposal estimated 10% more but that could easily just be different assumptions about efficiency. The system is sized to just about zero out my historical usage over the course of a year and take full advantage of PG&E net metering.

How about monthly variance? November works out to 22kWH per day in November or an average of about 900W. And what about variance over time of day? Here’s a curve of total insolation from this calculator; this doesn’t include factoring the orientation of the panels.

PVWatts doesn’t have a nice display for this, but they do let you download per-hour calculations for the entire year. Here’s an excerpt for today

HourWatts
07:00195
08:00456
09:00775
10:001968
11:002579
12:003578
13:003619
14:005147
15:002705
16:001060

Interesting how skewed this is to the afternoon; I assume it’s because my panels are at an angle on a west-facing roof.

Anyway that’s all theoretical calculations. I’m excited to get actual measured outputs and compare. Soon!

Some rough watt-hour numbers

PG&E’s incompetence means I’m thinking about electricity storage recently. Some rough numbers:

Devices you charge and use:

Batteries you can charge things from:

There’s a huge variety in the stuff I lumped together as “charger”, particularly how well they furnish AC or DC for usage. Your car battery is only as good as the inverter you plug into the stupid cigarette lighter, for instance. That EGO Power Station is designed to be a full portable AC power solution that can put out 3000W of clean power (well, for 20 minutes). Briefcase solar systems can also recharge themselves from solar panels.

I currently own a Powercore and two spare UPS units, for a total of about 275Wh. With that I can charge my laptop 4 times, my iPad 8 times, or my phone 25 times. I also have the car which is good for about 3x more charging just off the battery, which doesn’t count idling the engine to keep its battery charged.

Update learned a couple of things in the latest outage. The car inverter works pretty well, but my 2017 A3 only puts power out the 12V sockets if the engine is running. You can leave it running unattended if you start the engine with the door open. The car manual says 120W maximum out the socket, so my 300W inverter purchase is overkill and I guess I could blow a fuse. Other thing I noticed is the inverter was no good for trying to charge a CyberPower 875AV UPS; the display on the UPS showed it was picking up a little charge but not really. The cheap TrippLite UPS I have did seem to charge better from the inverter, or at least the inverter got awfully warm.

My electric bill says my house averaged using 35,000 Wh a day for the last year. A lot of that is optional load; in a low power situation I wouldn’t be running the pool pump, the electric oven, etc.

A single rooftop solar panel generates roughly 300W maximum, or 1370 Wh per day (average over the course of a year in NorCal).