Speak EV - Electric Car Forums banner
1 - 5 of 5 Posts

·
Registered
Joined
·
3 Posts
Discussion Starter · #1 ·
I've just changed to Octopus Agile and while we all know to avoid the peak times of 16:00 to 19:00 sometimes the price at other times can be a little on the high side.

As a solution I decided to try and add some smartness to my basic rolec charger.

Using an ESP8266 and a relay module I've managed to get the ESP8266 to connect to my wifi network, retrieve the current price for my region and compare it to a threshold value set on the ESP via web interface. If the current price is equal or below the threshold then the relay modules is energised.
This was my attempt at coding for a considerable number of years. I think the last time was in using Vic20 basic!. Fortunately there are plenty of tutorials, examples and sample code online for the Arduino IDE and ESP8266. What I have mostly done is take sections of these bits of code and modified them and stitched them back together

As I wanted to keep the 240V as separate as possible from the low voltage side, I've used the relay to interrupt the pilot signal. Though I have heard that some cars don't like having the pilot signal interrupted, mine seems fine with it.
Fortunately, the rolec control module already has a 5V output which is ideal for powering the ESP and relay module.

To set the threshold value just type in the IP address of the ESP into your browser, enter the value and hit submit. I'd suggest that your reserve the ESP's IP address on your router DHCP settings so that it gets the same IP address always.


Things I still need to do are:
put the hardware into a little box instead of just dangling in the charger box
look at what I want to happen if the current price can't be retrieved.
add a manual override switch.
try and turn the code into a series of functions that are called in turn.
add some secuirty to setting the threshold value and then I can do it via the internet, rather than just my local network.


The ESP8266 and relay module came from Amazon and cost about £8

Code is attached for anyone who wants to give it a try.

Relay trigger output is on D2 on the ESP

You will need to change your region in this line

String Starter = "/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-E/standard-unit-rates/?period_from=";

and add in your wifi credentials in these lines
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";


If anyone is more proficient than I in coding, feel free to offer suggestions and improvements.

Richard
 

·
Registered
Joined
·
231 Posts
Vic20 basic!
Wow I assume you mean the Commodore Vic20 because I had almost forgot this old machine and the ZX Spectrum, I used to love playing with the coding on these, sadly coming from a relatively poor larger family I couldn't afford to follow this route for a career, but good times lol.
 

·
Registered
Joined
·
2,398 Posts
I use a sonoff in my Rolec, and just have it switch the power to the controller off.

Currently it's just on a basic timer, but I've also started working on some code which queries the Nissan API to figure out how much charge the car needs, and the queries the octopus API to figure out the best time to switch the charger on
 

·
Registered
Joined
·
3 Posts
Discussion Starter · #4 ·
Wow I assume you mean the Commodore Vic20 because I had almost forgot this old machine and the ZX Spectrum, I used to love playing with the coding on these, sadly coming from a relatively poor larger family I couldn't afford to follow this route for a career, but good times lol.
yep, showing my age there. But while I haven't done coding since my youth I work a lot with computers, control systems and networks
 

·
Registered
Joined
·
3 Posts
Discussion Starter · #5 ·
I use a sonoff in my Rolec, and just have it switch the power to the controller off.

Currently it's just on a basic timer, but I've also started working on some code which queries the Nissan API to figure out how much charge the car needs, and the queries the octopus API to figure out the best time to switch the charger on
Good luck, the trickiest part I found was thinking about the time manipulation. As far as I can see the Octopus API doesn't have a call for "give me the current price please". It has to be specified as period from and to query, and taking into account either side of midnight, month end and year end wasn't obvious at first.

If you regularly want the car charged by a set time and you know how long it takes to charge, you could pull 24hrs of pricing from Octopus and look for the cheapest X number of slots within the time frame you are plugged in. Unfortunately I don't have anything like a regular pattern and just want to be able to plug the car in and not worry that it will start charging if it's over ,say, 15.0p a unit,

I was also wondering about using another one controlling a bank of immersion heaters dunked in a IBC of water and configured to kick in for negative prices!
 
1 - 5 of 5 Posts
Top