Jump to content

Inky pHAT (ePaper/eInk/EPD) + Raspberry Pi 2B project.


abarbarian

Recommended Posts

abarbarian

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.

 

Quote

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

 

Quote

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

 

Quote

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,

 

https://forums.scotsnewsletter.com/index.php?/topic/97963-shh-i-have-a-problem/

 

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.

 

lZh1pu7.jpg

 

dDQqr1P.jpg

 

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. 😋

Edited by abarbarian
  • Like 2
Link to comment
Share on other sites

abarbarian

So as the previous pictures show 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.

 

Quote
@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.

 

c2lAME5.jpg

 

Uncabled and finally tidily at rest.

 

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.

 

QoXNeiY.jpg

 

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. 😋

Edited by abarbarian
  • Like 1
Link to comment
Share on other sites

abarbarian

As well as the Pi project making me smile. The Octopuss Agile prices make me beam too. Compare the half hourly rates alongside the UK average price of 27p kWh.

 

I top up my battery to 100% between 01-30 to 03-30 and again at 12-30 to 15-30. The rest of the time the battery runs down slowly to 20% before needing to draw of the grid. Apart from topping up the battery I rarely draw from the grid.

 

 

Quote
00:00 - 00:30 0.92p/kWh
00:30 - 01:00 4.14p/kWh
01:00 - 01:30 2.31p/kWh
01:30 - 02:00 0.02p/kWh
02:00 - 02:30 1.89p/kWh
02:30 - 03:00 0.73p/kWh
03:00 - 03:30 0.23p/kWh
03:30 - 04:00 -2.06p/kWh
04:00 - 04:30 -1.88p/kWh
04:30 - 05:00 0p/kWh
05:00 - 05:30 2.77p/kWh
05:30 - 06:00 6.93p/kWh
06:00 - 06:30 10.78p/kWh
06:30 - 07:00 14p/kWh
07:00 - 07:30 15.38p/kWh
07:30 - 08:00 15.1p/kWh
08:00 - 08:30 14.44p/kWh
08:30 - 09:00 14.67p/kWh
09:00 - 09:30 15.15p/kWh
09:30 - 10:00 14.55p/kWh
10:00 - 10:30 14.46p/kWh
10:30 - 11:00 12.66p/kWh
11:00 - 11:30 11.8p/kWh
11:30 - 12:00 12.71p/kWh
12:00 - 12:30 12.94p/kWh
12:30 - 13:00 13.21p/kWh
13:00 - 13:30 14.07p/kWh
13:30 - 14:00 13.82p/kWh
14:00 - 14:30 16.17p/kWh
14:30 - 15:00 16.17p/kWh
15:00 - 15:30 15.25p/kWh
15:30 - 16:00 14.58p/kWh
16:00 - 16:30 26.39p/kWh
16:30 - 17:00 30.39p/kWh
17:00 - 17:30 30.6p/kWh
17:30 - 18:00 30.96p/kWh
18:00 - 18:30 30.89p/kWh
18:30 - 19:00 30.55p/kWh
19:00 - 19:30 18.48p/kWh
19:30 - 20:00 17.63p/kWh
20:00 - 20:30 18.48p/kWh
20:30 - 21:00 16.21p/kWh
21:00 - 21:30 16.48p/kWh
21:30 - 22:00 15.2p/kWh
22:00 - 22:30 16.4p/kWh
22:30 - 23:00 15.48p/kWh

 

Also when the sun shines I export to the grid and receive 15 kWh. Which may not be a lot in winter but in summer when I use miles less electricity it will add up.The more I can save on energy the more I can spend on fuel on the Royal. 😋

Link to comment
Share on other sites

  • 2 months later...

As well as the Pi project making me smile. The Octopuss Agile prices make me beam too.

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

 

q9uhpKa.jpg

 

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/

 

😋

Link to comment
Share on other sites

21 hours ago, securitybreach said:

So this is your project??

 

If you mean the software -- then I wish ----i am not that clever.

 

Developer is called pufferfish-tech this is the software of his I used,

 

https://github.com/pufferfish-tech/octopus-agile-pi-prices

 

Quote

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.

 

Quote

What do I need?

currently:

  • A raspberry pi. The zero W works fine. The pi needs network one way or another.
  • A display adapter. If you use an inkyphat, it should work out of the box. Same with the DOThat assuming I didn't accidentally break that code.
  • An sd card (obviously) - 4GB works fine. Raspbian buster LITE version uses only about half of that. No need for any more.
  • Octopus Agile API key.

 

All the above attracted me as I had an older Pi 2 and it seemed as though setting up seemed not too complicated. Turned out it was a little more complicated than I thought and I seem to have messed up getting shh to work. Turns out shh is not a problem as I have unplugged the Pi several times and it has restarted with no problems. If Octopuss change their net address I will have to plug the Pi into my tv to make adjustments.

 

 

😎

Link to comment
Share on other sites

1 hour ago, securitybreach said:

Well you didn't quote the post so I wasn't for sure if that was you're work or not.

 

You must have missed the link and1 quote in the first post . 🫣

Link to comment
Share on other sites

How so?

 

Quote
So as the previous pictures show 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..............

 

Without quotes, it looks like you were saying that.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...