GivEnergy Inverter networking

Overview

Rather off-topic, but I’ve been doing a dive into the TCP networking of the GivEnergy inverter which is the heart of our recent solar panel installation. The inverter connects to the solar panels and battery, converting DC to AC, and routing the power to/from the the battery as required. There’s a very handy app for your mobile, a web-based dashboard for monitoring and control, and it also integrates nicely into Home Assistant systems.

However, it’s not perfect. I get frequent “Inverter Timeout” errors when trying to update settings from the web portal, and I’ve also seen blatantly ‘wrong’ data arrive in both Home Assistant and the portal. Given that this is all over TCP/IP which is reliable and mature, I was curious about what’s happening. Time for a deep dive..,

Hardware

The inverter is a Gen 2 model – which means it has built-in ethernet and Wi-Fi, rather than needing a separate USB to Wi-Fi dongle like the Gen 1 model. The inverter and battery are in the garage, and I’m running this via ethernet powerline adapters back to a Unifi switch in the house.

The first step is to find the IP address of the inverter. The mobile app has a handy option to do this, so lets start there.

Let’s also take a look in the router’s DHCP settings to find what address was allocated, and the MAC address.

Let’s find the vendor for that mac address, using a lookup tool like https://macvendors.com/

Connect via Browser

OK, let’s try connecting to the inverter IP address with a browser. We’re presented with a HTTP Basic Auth login prompt – luckily the username and password are well documented in GivEnergy Wifi dongle setup guides, as admin/admin.

And, we’re in!

The obvious things to note are that this doesn’t look remotely like an inverter control page. There’s no GivEnergy branding. What, exactly are we talking to? The clue is in the MAC Address, and the hostname “HF-A21” we saw earlier. Googling the vendor and hostname, you’ll end up here which allows you to download the manual for this device.

I’d recommend NOT changing any parameters via the Web UI unless essential. There are hidden settings that can’t be changed from the Web UI and you’ll be in a world of pain getting it running properly again.

An HF-A21 is a UART to Wi-Fi/Ethernet module: It claims to converts a serial port (UART) to a TCP connection, but such devices are far from ideal.

Looking at the HF-21 manual and web interface, there are two main modes of operation which they call AP and STA. In “STA” mode, the module acts as a TCP client, and establishes a connection to an external TCP server. The server IP address doesn’t appear to be configured in the Web UI.

In AP mode, the module acts as a TCP server itself, allowing clients to connect to it. This is configured as listening on port 8899. Importantly, there’s also an AP + STA mode – although this can only be configured via the module’s serial port.

How does this work for the Inverter?

The inverter’s controller is connected to the serial side of the HF-A21 module. The inverter must place the module into the AP+STA mode, and sets the remote server address to an Amazon AWS address running the backend of the GivEnergy portal. Update: the HF-A21 actually uses DNS to find an IP address for comms.givenergy.cloud. I can’t see any mention of how this is possible from the HF-A21 manual, so my best guess is that the HF-A21 has been customized to perform this function.

All commands and data are sent using a variant of MODBUS protocol over TCP , which defines the layout and meaning of each command.

When the module starts, it opens a TCP connection to the Amazon server, and every five minutes the Inverter sends out a block of data to the AWS servers to update the web portal. Similarly, any changes to settings made in the portal are sent via AWS to the inverter. On it’s own, this will all work fine.

AP Mode

So, if the connection to the portal uses STA mode, how does the “local connection” option in the mobile app work? This is where AP mode (server mode) comes in. The HF-A21 acts as a TCP server, accepting connections on port 8899 and forwarding TCP data to/from the inverter UART.

But, we’ve now got multiple TCP connections to the HF-A21: What happens if both the AWS server and the mobile app send a message at exactly the same time? Luckily this doesn’t present too much of a problem. Although TCP is stream-based rather than packet-based, careful programming will ensure that MODBUS commands are sent as single TCP packets, so no interleaving of data on the UART occurs.

The real problem is when the inverter/UART side of the module receives data, and needs to send it over TCP. It can’t know which TCP connection to send it to, so instead, it sends the data to all current TCP connections.

For example, if you have the mobile app running in ‘Home’ mode, every ten seconds the app will ask the inverter for data. The inverter must send this data to both the app, and to the AWS server! You can see this clearly with a packet monitoring tool like Wireshark. Add Home Assistant into the mix, and every message from the Inverter must now go to three locations, regardless of who requested it.

I suspect that the “Inverter Timeout” messages are due to the portal software sending a command and expecting a reply – but instead, getting a reply that’s really intended for another client. Of course, it should be possible to ignore these, but maybe this isn’t happening.

More to follow…

Oregon: Nesmith Point

Something rather different : I’ve been in the USA for a couple of weeks and packed the bare essentials in case an opportunity to get presented itself.

I was staying in Portland,  Oregon, and a visit to the waterfalls in the Columbia River gorge was suggested.  It was great weather, and I started late, so unsurprisingly all the parking at the trailheads was taken.  I drove on , and took the trail marked towards Nesmith Point. At a little over four miles with just under 4,000ft of elevation gain, it’s a good workout.

IMG_20150418_133011.jpg

The trail leads into the forest, gradually rising towards a series of switchbacks as it steepens.  There are good views over to Beacon Rock on the north side of the river once you gain a little height.

The rock on the path gives plenty of clues about the volcanic nature of the terrain,  and there’s  an interesting selection of flowers out – mostly very different from those found in the UK.

IMG_20150418_134627.jpg

This one with the white petals is Trillium.

IMG_20150418_134348.jpg

The trail climbs steeply under the impressive canyon walls, and finally (with a huge sense of relief) the grade eases dramatically.

IMG_20150418_141809.jpg

IMG_20150418_152548.jpg

The summit is a couple of kilometres on, after a marked junction. The views west down the gorge are impressive, but the trees still block the view north and east.

IMG_20150418_153428.jpg

The fresh landslip here shows the instability of a lot of the gorge – one major landslide a few hundred years back formed the Bridge of the Gods a few miles upstream.

A quick snack, a rest, and then a faster and easier descent back to the car.

First Winter Day

Black Mountains – 19-01-2015

Having just replaced my long-suffering boots with a new pair, the weather forecast gave an ideal opportunity to bed them in. The amount of ice on the driveway and local roads meant that somewhere near was athe best option, so I headed south to the Black Mountains at the eastern end of the Brecon Beacons NP.

Plenty of snow was visible on the hills as I drove towards Hay and then Talgarth, so I was a little surprised that the ground was mostly free of snow and unfrozen at the bottom of Y Grib – the undulating ridge head onto the high ground.

But after crossing over Castell Dinas and climbing out of the bwlch, there was no shortage. I followed the ridge up to the cairn, with Pen y Fan and friends impressively coming into view round the side of Mynydd Troed.

wpid-P1020841.jpg

wpid-P1020848.jpg

On the ridge, the snow mostly just inches deep – the wind scouring from the ridge and depositing it on the leeward slopes – but on the plateau towards Pen Y Mallwyn it was much deeper and unconsolidated, making every step an effort.

wpid-P1020850.jpg

Much post-holing and floundering later,  and I reached the ridge path heading towards Waun Fach. The snow again was a lot easier here, and I made good progress on the path to the summit plateau.

I’d seen figures on the skyline earlier, and now could see they were all carrying unfeasibly large packs. And the SA-8o’s were bit of a giveaway that this wasn’t a D of E award group out training.

wpid-P1020853.jpg

wpid-P1020854.jpg

After stopping for food, I took a wide loop round the summit plateau, before heading back to the car via Pen Trumau

wpid-P1020859.jpg

wpid-P1020858.jpg

wpid-P1020862.jpg

Hillwalking, and other frivolous pastimes