Price Driven Electricity Controller

In 2020, I built a controller on a Raspberry Pi 4 to operate my storage hot water heater when the electricity price is at its lowest.
My electricity supplier provides me with wholesale electricity through an interval meter at the prevailing half-hourly market price.
Since hot water service accounts for a third of my daily consumption, charging it for 2 hours when prices are lowest during the day makes a significant saving.

A challenging part of the project was making a radio link for remote control and I tried several protocols with varying degrees of success before finding a solution.

Recently I bought two PiicoDev Transceivers, a Pico , a Pico W and some sensors.
I was astonished to find how quickly these devices could be set up to read the sensors and transmit the data wirelessly using the software modules with the aid the Getting Started Guides.
In addition, the Pico W could connect to my NBN modem and interrogate the supplier’s API to obtain the current and forecast electricity prices.

In short, this is the essential functionality that took me months to develop the first time around.
Well done PiicoDev.


Hey @Peter121683 - What a glowing review :heart_eyes: It’s awesome to hear that the PiicoDev Transceiver exceeded your expectations. We really strive to provide user-friendly products and comprehensive support, so it’s delightful knowing that our guides and software modules got you over the line quickly.

We’re jazzed you took the time to let us know how things are tracking.
Happy Making :metal:

If you feel inspired to, I’d personally love to see your project on our Projects page. Please consider sharing your project - it sounds too good to not share more details :smiley:


honestly, this is a brilliant life hack! with electricity prices rising it would be wonderful to implement.
yes please share this project :heart_eyes:


Hello Michael and Wolf

Thank you for your interest.
I will be pleased to provide more information on my project.

I have a contract with Amber Electric who have provided me with an interval meter and sell me electricity at the prevailing market price for each half hour.
This includes a mobile phone app for me to see the current and forecast half hourly prices and I can access their API to download the prices.
Amber charge me a flat rate of 50cents per day for this service.
They have a service called SmartShift for energy management but I preferred to build my own behind-the-meter control.

The main elements of the project were;

  1. Downloading the market prices from the Amber API via the internet using my NBN modem
  2. Writing an adaptive control algorithm in Python on a Raspberry Pi 4
  3. Making a radio control using Digi Xbee S2C modules
  4. Building a receiving circuit for a Solid State Relay in the power supply to the Hot Water Heater

Since the project was built in 2020, there have been several developments;

  • The half hourly electricity prices have become more variable which makes the Price Driven Controller more attractive.
  • SA Power Networks introduced in Dec 2021 a Time Of Use Network Charge which has supercharged the savings available, especially during the solar period from 10am to 3pm,
  • Amber Electric have introduced an improved Application Progam Interface for the electricity prices, which is more user friendly but also more secure and reliable.
  • PiicoDev have developed very useful transceivers for remote control.


perhaps you could include a link to the presentation you did for EESA. (was it recorded?)
This is a great example of inspired DIY.
Allan H


Hello Allan

I am pleased that you remembered my presentation to the EESA.

The video recording of the Webinar is still available on the EESA website titled
“Household Demand Management : Case Study”
but can only be accessed by members of the EESA.

However I have uploaded a pdf of my slide presentation with the notes.

regards Peter

20210421 EESA Case Study.pdf (596.7 KB)


Obtaining electricity prices from the Amber API

A practical introduction to wholesale electricty would be to interrogate the Amber API to obtain the current electricty prices using the python program amberAPIpy.pdf
see link below.

I have python 3.8 installed on my PC and run the python script on the Windows 10 PowerShell.

The program requires an api-token and a siteid, available from the Amber Website Go to the FOR DEVELOPERS page

A sample output from the program is shown in the file amberAPIpy_Output.pdf

The response from website looks formidable but can be readily unpacked once the data structure is recognised as a list in which each element is a dictionary.

amberAPIpy.pdf (38.6 KB)
amberAPIpy_Output.pdf (47.3 KB)
20230614 AmberWebsite.pdf (299.8 KB)



Genius. Just came to say this is an incredible project.


Hey! I’m Myles - I’m the Technical Product Manager at Amber, I’m in charge of our battery product: Smartshift, the API and our home assistant integration.

It’s really great to see you using our API!

We recently had an internal hack day where we used an ESP32-C3-DevKitC-02 board to connect to our API and change the colour of the LED depending on the price.

Here is the Arduino sketch we used: AmberLight.ino · GitHub


Hello Myles

Very good indeed to have you on board.

Once we are able to interrogate the Amber API for the electricity prices, the next step is to write a loop in python that synchronises with periodic intervals of the National Electricity Market.

The loop runs every five minutes to check for changes in the current price and at the start of every thirty minute period it obtains a revised forecast of half hourly prices.

This loop is the main framework for the program and various tasks can be slotted in to occur daily, half hourly or at 5 minute intervals.

The output file shows the prices obtained from the Amber API
However the program will run with dummy prices for anyone who may not have Amber api_token

priceloop1.pdf (55.1 KB)
priceloop1_Output.pdf (36.8 KB)


I have included a method to determine the threshold price required to capture a quota of lowest price half-hourly periods for the day, in this case 5 half hour periods.
This threshold price will be different for every day depending on the forecast prices and may change within the day, as the forecast is sampled every half hour.

I initially tried using a rolling 24 hour horizon stretching ahead of the current time, but found that the forecast prices for tomorrow were usually less reliable that those for today.
The program would often baulk at acting on today’s prices in the hope of getting even lower prices tomorrow.

Currently my strategy is to trade off some uncertain future gains for more certainty in the short term.
So the program tries to satisfy it’s daily quota of operations from today’s prices and then at midnight starts with fresh quota to be filled from tomorrow’s prices.

This program will run on a PC with Python installed where it is more convenient to develop and test the software. Later the program can be transferred to a Raspberry Pi or a similar device.with Python installed.

priceloop2.pdf (63.3 KB)
priceloop2_Output.pdf (47.8 KB)


That’s a pretty way of doing it! You’re essentially guaranteeing quality-of-service by selecting from the pool of lowest projected prices rather than setting a hard price threshold.

Do you have any photos of the updated hardware setup @Peter121683? We’d love to feature this thread on our social media.


Hello Michael

My PiicoDev Transceivers are still on the breadboard, so unfortunately I dont have any presentable photos.
However I have used micropython on the Pico W to interrogate the Amber API for the electricity prices, adapted from the “Getting Started with Pico W” Guide. see links below

For the hot water heater, this project only requires two radio channels for set and reset signals so it should be straightforward to adapt using the PiicoDev Tranceivers.

For my own home, I would keep my existing Xbee S2C radios as they have been very reliable in service, although they were quite involved to set up.
For a new build, I would propose using the PiicoDev Transceivers as they are more user-friendly.

I will work on a modified design to use these Transceivers.

amberAPIup.pdf (39.1 KB)
amberAPIup_Output.pdf (38.1 KB)

1 Like

Hello Michael
Some further thoughts.
I have another Raspberry Pi 4 with a touch screen which I use with dummy receiving circuit for testing software changes.
I recently bought 2 PiicoDev transceivers and a pico ( and a picoW )
So with the addition of a PiicoDev RPI adaptor, I could make a prototype Controller using the PiicoDev Transceivers fairly promptly.


I have included control and actuator tasks so that the program produces outputs that could be used switch on and off a physical device.

The program will run on a PC or a Raspberry Pi provided that it is given the hostname.of each machine.

So now we have obtained the electricity prices and generated control signals.
Next we need to use the control signals to operate a physical device, in the first instance a storage hot water service.

This could be by wire but a radio link will be more flexible.

priceloop3.pdf (60.5 KB)
priceloop3_Output.pdf (50.3 KB)


I have breadboarded a radio link using the PiicoDev Transceivers and have adapted the software provided in the guide “Getting started with PiicoDev Transceivers”.

The brown prototyping board has the same receiving circuit that I used on my existing XBEE radio design.
It comprises a 555 timer operating as a RS Flip Flop and requires a falling edge pulse on the set channel and on the reset channel.
The opto-isolators serve to isolate the 3.3 volt RPI signals from the 5V circuit for the 555 timer and Solid State Relay control. ( Also they have saved my RPI from being damaged by my wiring mistakes.)

The output from the receiving circuit will trigger the Solid State Relay in the power supply to the hot water service.

202340625 Receiving Circuit.pdf (268.4 KB)


Nice @Peter121683! Thanks for keeping us updated as the project evolves. Awesome to see you were able to fit the PiicoDev adapter in your Pi enclosure without too much trouble.

And the 555 Timer :smiley: it’s just the gift that keeps on giving!


I have adapted the control program to use a radio link between two piicodev transceivers.
The Raspberry Pi uses a piicodev adapter to connect to the master transceiver, as per the photo above.
The receiving station comprises a tranceiver, a piico and a latching circuit.
The LED on the latching circuit indicates when the 5V input to Solid State Relay would be triggered.
Before running these programs, the master RPI and the piico receiver should to be set up and tested as per the :“PiicoDev Transceiver | Getting started guide” .
I found that it was necessary to use this terminal command on the RPI in response to an error message
sudo curl -L | bash
For those without an API-token from Amber, the program will toggle the output at each interval to show that the link is working.
The timing intervals at line 290 are set to shorter times for testing purposes.

pdcontrol1.pdf (61.4 KB)
pdcontrolRX1.pdf (31.5 KB)


Solid State Relay

While there are cheaper devices available, I thought that an industrial grade Solid State Relay was warranted for the heavy duty 240v supply to the heater. .
There are several reputable brands of 25Amp SSR with a 3 - 32 volt dc input and a zero crossing trigger available for around $50.
I chose the Schneider Electric SSP1A125BD, which is the basic model, together with a 150AB1000MB heat sink.

1 Like

I have made some minor cosmetic changes to the two pdcontrol programs

pdcontrol2.pdf (53.0 KB)
pdcontrolRX2.pdf (33.2 KB)