Setting the time on a Growatt Inverter

After monitoring my solar inverter for over a year now, I have had a couple of instances where the daily energy graphs went a bit strange. It turns out that the inverter’s internal clock will occasionally drift by several hours.  This causes the daily energy production figure to reset at a time other than midnight.

Setting the time on the inverter is quite painful due to the “knock knock” user interface.  Thankfully, you can set the date and time by writing to ModBus registers.

I have created a script that now runs each morning to set the inverter’s date and time to the current date and time:

#!/usr/bin/env python
""" Created on Fri Sep 29 2016
@author: Paul Wilkinson
from datetime import datetime
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
# choose the serial client
client = ModbusClient(method='rtu', port='/dev/tx0000', baudrate=9600, stopbits=1, parity='N', bytesize=8, timeout=1)
now =

Monitoring a Growatt PV inverter over WiFi using Python

I recently had a 5kW solar array installed and it came with a Growatt 5000MTL inverter.  This inverter is installed in my garage and comes with RS232 and RS485 ports for monitoring.

I wanted to connect to to publish my system’s production.

I found a Python script that could do the job on but it needed an RS-232 connection via a TTY on Linux.

Because of the location of the inverter, connecting a device directly to the inverter serial port would be tricky. I could use a Raspberry PI with a USB serial adapter, but that seemed a bit icky and I already have a Linux box running WView to upload my weather station data so I wanted to use that box if I could.

WiFi Terminal server

WiFi Terminal server

I found an inexpensive WiFi/Serial port solution on eBay and so now all I needed was some way to make the connection to Linux.  Initially I tried socat, but this needed to be restarted each time I wanted to connect to the inverter and proved to be unreliable.

A bit more searching revealed TruePort from Perle.  This is a kernel module that bridges between a network terminal server port and an entry in /dev and although it is designed to work with Perle’s products, it works with any generic serial-port-on-the-end-of-a-TCP-port device.

Getting it running required the usual Linux check-the-dependencies-recompile-the-kernel-install-the-mods drama, but once I got it running it has proven to be very reliable.

Bluetooth Low Energy Lock using a LightBlue Bean – Part 3 – iOS Code

In part 1 I described the hardware for this project and how to connect it. In part 2 I described the Arduino code that runs in the LightBlue Bean.  In the final articles we will take a look at the iOS code for a simple application that triggers the lock.

Due to the size of the iOS code, I have decided to split the final part into two.  This first half looks at the main iOS code and the second will look at the settings screen.

The source code for the Arduino and iOS application is available on GitHub


In order to run this project on an iOS device you need a paid-membership of the Apple iOS developer program, as without this you can only run apps under the simulator, and the simulator doesn’t have BLE support.

In order to help with this, I have added a simple OSX application to the repository.  It is functionally equivalent but can be run on any Mac without any payment to Apple.

Continue reading

Bluetooth Low Energy Lock using a LightBlue Bean – Part 2 – Arduino Code

In Part 1 I described the hardware for this project and how to connect it. In this part I will describe the Arduino code that runs in the LightBlue Bean.

Punch Through  Design, the creators of the LightBlue Bean, provide a library that provides integration between the Arduino and the other hardware on the Bean.  The first step is to get an Arduino development environment set up.

Head on over and follow the Punch Through Getting Started Guide – I’ll wait here until you’re done.

Continue reading

Bluetooth Low Energy Lock using a LightBlue Bean – Part 1 – The Hardware

This is the first of three articles that will describe how to create a Bluetooth enabled electronic lock. Technically it isn’t actually a lock, but rather a relay that could be used to operate a lock or other device such as a garage door opener.

Before we go any further, let me say that this is intended as a demonstration of how to communicate between a LightBlue Bean and an iOS app – The solution is not designed to be particularly secure, so if you use it to protect your priceless gemstone collection, don’t complain to me if it gets stolen.

There are 3 pieces to the hardware

  1. The LightBlue Bean – This module has a Bluetooth Low Energy chipset connected to an Arduino.  The Arduino provides the logic and the digital output that controls the relay.
  2. A relay board – I bought a cheap board from eBay.  As well as the two relays the board has opto-isolators that enable control of the (relatively) high-current relay coils from the low-current Arduino digital output.
  3. An external power supply – The coin-cell battery on the LightBlue Bean doesn’t have enough power to drive the relay boards.

Continue reading

NBN predictions update

Just before the election I made my NBN predictions. Less than two weeks after the election there is some speculation that my 5% chance option 1 – continue with FTTP – may happen. Although I didn’t include the use of fibre-to-the-basement (FTTB) as an option for apartments and other MDUs such as shopping centres in this option, the Coalition plan was always to include FTTP in areas where the NBN was already committed, ‘greenfields’ sites and other locations where the copper needed too much remediation. So I will fudge it a bit and say that it was implied 😉

Just before the election I did head Malcolm Turnbull say on 702 Sydney words to the effect that ‘no one doubts the technological superiority of FTTP, but it shouldn’t be done at any price’. This struck me as quite a departure from his prior position which was ‘FTTP isn’t needed'; he was emphasising cost and not FTTN being a suitable technology.

For what its worth I think that FTTB is a reasonable approach to MDUs – the copper runs are likely to be relatively short and relatively new. An on-demand extension of FTTH from a basement is more likely to be both feasible and cost-effective than a couple of hundred meters down the road from a node to a house.

As others have observed a truly independent review would be hard-pressed to find that FTTN makes sense as a long-term solution for the delivery of a data network and given that the bulk of the cost will be labour any savings will be illusory in the long-term.

My NBN Predictions

It seems almost certain that in about 15 days we will have a new coalition government. Broadly speaking their NBN policy is a switch from FTTH to FTTN. Much has been written about why FTTN is inferior to FTTH and why, given the state of the copper and the likely lifetime of an FTTN solution, any savings are probably illusory so I won’t repeat it all again.

What I do want to do with this post is try and predict what the LNP will actually do with the NBN. I am not brave enough to make a single prediction, so I will give some options and my opinion on how likely they are.

Option 1 – They conduct a review of the NBN and decide that FTTH is the right way to go after all – 5%

Option 2 – They spend 6-8 months negotiating with Telstra for access to the copper at a reasonable price before giving up and deciding to stick with the current FTTH plans – 10%

Option 3 – They spend 6-8 months negotiating with Telstra for access to the copper at a reasonable price before giving up and selling NBNCo to Telstra in exchange for some agreement on ‘structural separation’ between wholesale and retail – 50%

Option 4 – They spend 6-8 months negotiating with Telstra for access to the copper at a reasonable price before giving up and giving NBNCo to Telstra and paying them $20B in subsidies to complete the rollout in exchange for some agreement on ‘structural separation’ between wholesale and retail – 20%

Option 5 – They spend 6-8 months negotiating with Telstra for access to the copper, end up paying them $10B and rollout an FTTN network that is obsolete before it is completed, takes longer to deploy than the original FTTN NBN and costs more – 30%

Although options 1 & 2 involve a complete about-face on their FTTN policy, it is conceivable as they will very likely be in a strong position, electorally, and able to blame it on Labor (“they committed us to FTTN and it is unfair to have some people with lower speed access”) or Telstra.

Under options 3 and 4 (especially 4) I think there is a reasonable chance that Telstra will continue to roll out FTTH – they have already done this in new estates and in South Brisbane, and it gives them a chance to be rid of the majority of their copper network. This will reduce the cost of maintenance and give them an excuse to retrench a lot of maintenance employees & replace them with subcontractors (those that haven’t already been replaced with subcontractors that is). A homogeneous FTTH network would also be cheaper to manage than a mixture of FTTH, FTTN and HFC.

It will be interesting to come back in August 2014 and see how my predictions have panned out.


*Update* – Scott’s comment reminded me that I meant to point out that under both the Labor and Lib’s plan rural areas get fixed-wireless or satellite. This means that there may not be much horse-trading required with the Nationals. It also means that I guess the one issue that I might care about in this election doesn’t affect me either. hmm…

And we’re back…

I have built a new OS image for the weather station Raspberry Pi and reinstalled WView, so the weather pages are back up.  Unfortunately I wasn’t able to recover the new HTML template I made, so it is back to the standard page for the moment, until I can recreate it.

*NOTE TO SELF* – Back up the flash card this time!

Service Information

Last week I migrated to a different server at my hosting provider in order to get access to some additional features.  Unfortunately this had a serious impact on the performance of this site.

After talking to GoDaddy support last night they were able to migrate me again, but this time to a newer hosting farm and now performance is better than ever.

Unfortunately the Raspberry Pi flash got corrupted, so the weather station is down until I can rebuild that.  I managed to recover most of the data, but unfortunately lost my new web page template, so I will need to recreate that :(