Raspberry Pi 2 energy monitor with Inky pHAT (ePaper/eInk/EPD).

Abarbarian

Acruncher
Joined
Sep 30, 2005
Messages
11,023
Reaction score
1,223
How does that old song go ?" I'd walk a million miles for one of your smiles", or something like that. I have a customised version I sing to myself every time the sun shines," I drove a million miles for my sunshine smiles".

I spent the last six years doing voluntary driving for the Welsh Ambulance Service here in the UK. I had to provide my own vehicle, maintenance etc and received a paltry couple of pence per mile in expenses. On average I spent around thirty hours a week out on the road spread over three days and I carried on through the covid crisis.

Why ?

Well loads of reasons. One of the main ones was to accumulate enough loot to buy solar panels and a battery for the homestead.Last year after driving not quite a million miles I had accumulated enough loot to cover the initial cost of my vehicle and the purchase of the solar array and battery.The latter I had installed in December 2023.The gods must have been smiling on me as the installers were up on the roof on the only fine weather day that month.

What has that to do with hats and pi's you may well ask.

Over here we have an energy supplier called Octopuss who have some very interesting energy tariffs. One called Agile is directed towards folk with solar+batteries. This tariff is based on wholesale prices and changes every half an hour.

The 100% green electricity tariff with Plunge Pricing

Agile Octopus is one of our innovative beta smart tariffs, helping bring cheaper and greener power to all our customers, but is directly impacted by wholesale market volatility.

Agile prices can spike up to 100 p/kWh any time - although a typical household in Winter '22-'23 paid around 35 p/kWh average.

This tariff is best suited to customers who can shift large amounts of their energy use to avoid these expensive peaks, often by using smart home technologies like solar and batteries.

So I signed up for the tariff which is a bit of a gamble really and I need to keep an eye on the price fluctuation.

This is where hats and pi's come in. A clever chap has created a program which runs on a raspberry Pi and a InkypHat. Now I have had a Pi 2B stuck in a drawer since 2017 so this looked like an importune moment to use it.

octopus-agile-pi-prices --- program

What does it do?

Octopus is an energy provider in the uk. Agile is a package they provide with half hourly energy prices. https://octopus.energy/agile/ Amazingly they offer an API to allow us nerds to code things.

Yeah but...what does it do?

It's for displaying current prices. It runs in python on a raspberry pi. This is great because it means you don't need to install anything*. The current version of Raspbian has the two things it needs: python and SQLite.

As I had a PI all I needed was a pHat. I could have got one with pretty colours at around £26 but being a Yorkshireman I bought an older with less pixels black and white version for £20 inc postage. I could kick myself as my google foo must have been misfiring as I found today a modern more pixels version for £19 on Amazon.

inky-phat-epaper-eink-epd-black-white

A low-energy, high-falutin, electronic paper (ePaper / eInk / EPD) display for your Pi!

Inky pHAT's beautiful 212x104 pixel, the display is ideal for displaying simple graphics and crisply-rendered text and because it's like paper, it's readable in bright sunlight

So I have the hardware and the software, time to get going.

I used the rpi-imager and followed the guide given by pufferfish-tech.Now I should have been able to ssh into the Pi from my Arch install but was unable to do so. I have a thread running here trying to resolve this glitch,


So I resorted to using a monitor which caused some problems. I have a spare usb mouse. I have four keyboards but they are the old fashioned purple socket type, not usb which you need for a Pi. So I had to use my main pc keyboard which meant that I could not do any information finding on my Arch unless I unplugged the keyboard from the Pi and plugged it into Arch. You can see that is problematic.

A couple of shots of the working environment. WELL I WOULD POST SOME SCREENSHOTS BUT THE STUPID SITE REFUSES TO LOAD MY IMGUR IMAGES

https://i.imgur.com/lZh1pu7.jpg

https://i.imgur.com/dDQqr1P.jpg

https://i.imgur.com/YI127Q8.jpg


I have my screensaver on Arch using 20 giffs which change every two minutes. More later as I need a cup of tea and toast. :cool:
 
Last edited:
So as the previous pictures show THAT IS THEY WOULD SHOW IF THE SITE WOULD POST THEM I managed to install the software and have output to the pHAT. Checked the prices for the time shown and all looked good.The final part of the software guide suggested several cron jobs to restart the program on a reboot and to update the pHAT every half hour and to obtain the daily price list.I have never created a cron job before so this was new territory for me.As I could not ssh into the Pi I could not copy and paste the very long cron details and inputting all that text certainly was tedious.With the job done I sat back and waited for the pHAT screen to change.An waited an waited an waited. Re-checked the cron details, all looked good.Still no change.


Darn !!!


So it was back to searching for information again.


Found out there are two different types of cron with files in different locations and that cron uses sh not bash. All not of any use to me. Then I found this site which gave some very useful information.

https://stackoverflow.com/tags/cron/info

Like use

ps aux | grep [c]ron

then add an entry via crontab -e and check whether the file is created after a minute.

* * * * * touch /tmp/my_cronjob_ran

to see if cron is in a useable state on the pc. Yup it was, file was created, so the problem was not a start up cron problem. It must be in the cron job details.Below is the crontab entry from the guide,

@reboot sleep 10; cd /home/$USER/octopus-agile-pi-prices; /usr/bin/python3 octoprice_main_inky.py > /home/$USER/cron.log
*/30 * * * * sleep 20; cd /home/$USER/octopus-agile-pi-prices; /usr/bin/python3 octoprice_main_inky.py > /home/$USER/cron.log
05 16 * * * cd /home/$USER/octopus-agile-pi-prices; /usr/bin/python3 store_prices.py -r <your region> -t <your tariff> > /home/$USER/cron.log

Notice the environment variable $USER. I recalled reading that environment variables may cause problems in cron due to the sh/bash thing. So I changed the $USER to the username I am using on the Pi. Also I changed the logging part of the command.The parts in red I belive mean that the log is appended to as opposed to being overwritten and the last red part means that errors will be shown in the log too, at least I hope so.

@reboot sleep 10; cd /home/myusername/octopus-agile-pi-prices; /usr/bin/python3 octoprice_main_inky.py >> /home/myusername/cron.log >2&1

An whooopeeee it worked. the pHAT's screen showed a different price every half an hour.

The output on the pHAT is a tad erratic, in that it does not always show all the information. It shows enough for my purpose and rectifies itself as it runs along.

Here are some shots of the Pi's final resting place. Firstly cabled up for testing. THAT IS THEY WOULD SHOW IF THE SITE WOULD POST THEM

https://i.imgur.com/c2lAME5.jpg

Uncabled and finally tidily at rest.

https://i.imgur.com/TfJ9IA6.jpg

As the Pi was caseless and I do not want to spend loot on a case I cobbled together a non conductive plinth for it to sit on. Neatly angled for easy reading. The pink box was what the pi shipped in and I found a couple of brass threaded screws and nuts in a drawer.Simply folded the box lid back on itself which gave an incline. Punched some holes in the box with the trusty Swiss Army Knife tool. The screws were a tight fit going through the pi's breadboard but the holes in the pi were nylon lined which was handy. Screwed the screws through the pi and two layers of the box and hey presto a bodged plinth that is sturdy and holds the pi securely and at a good angle. Plenty of ventilation too.

https://i.imgur.com/QoXNeiY.jpg

https://i.imgur.com/nU0hhBD.jpg

Last two small jobs to do. I have plenty of standard sd cards but only one 16 GB micro card which I am using for the project at the moment. So I need to buy a 4 GB card and swap over the os.

Also not necessary at the moment I need to figure out why ssh does not work. That is for another day though.

Am I happy ? Well yes I have at long last completed my first real useful Pi project since I bought my first Pi way back when.:thumb:

WELL I WOULD BE HAPPIER IF THE SITE WOULD POST MY PICTURES BUT APART FROM THE I AM HAPPY
 
As well as the Pi project making me smile. The Octopuss Agile prices make me beam too.

Here are some links to screenshots of my latest energy prices showing on the Inky pHAT.

https://i.imgur.com/q9uhpKa.jpg

https://i.imgur.com/mIcOUPh.jpg

Those are pence per kilowatt hour. An the minus sign is not a mistake, Octopuss were paying me to use electricity in that half hour. :cheers:

If anyone is thinking of joining Octopuss I am on their https://octopus.energy/smart/tracker/ tariff for GAS and am paying 4.6p per unit and have been since December last year. It was a little lower at 3.8p but has risen lately.

The electric cost has averaged out at around 17p per kwh since December too.

Using this referral code would give me £50 and the user £50

https://share.octopus.energy/sky-sheep-473

The agile tariff is mainly for solar users so not so good for ordinary users. however the TRACKER tariff can be used by any normal user and would save a ton of loot. You would need to keep an eye out on the tariff rates though.

https://octopus.energy/smart/tracker/

:cool:
 
Back
Top