Pontus, 2021-11-17
The whole summer has come and past since my last update π
In short, this is what I'm been up to the last year regarding this project:
I have rewritten a lot of the code to be more component base to enable easier expansion in the future. This introduced a lot of new bugs, but all is now working again.
Added system config file to support more systems than just my own.
Studied, learned and write my own GUI(Graphics User Interface) using Tkinter.
I have bought and installed a touch screen to my Raspberry Pi and hanged it in the garage next to my ev-charger.
Solved a big issue with MQTT was very slow and kept crashing all the time.
Implemented automatic charging of EV when the spot price is at it's lowest.
Okay, so let's get in to the juicy details, here comes some details regarding
The code just had to be rewritten, refactored, it was a big mess just to get something working and prove that I can control my ev charger. All code was in one huge file. So I broke it down in three levels; common code for a battery controller, common code for a EV charger and specific code for one specific charger.
After this I can easily expand my support for other EV chargers and energy storages.
The system config file can look something like this:
"main_fuse": 16,
"charger": {
"id": "GLBDCM-T222WO",
"ip": "192.168.1.21",
"max_power": 9000,
"default_mode": "MAX_POWER"
},
"car_info": {
"id": "Nissan Leaf 2018 40kWh",
"target_soc": 0.85,
"battery_capacity": 37000
}
The "main_fuse" setting is for the system to know what the max allowed effect over the main fuse. If any excess power is detected any active charger "should" limit it's power input to save the main fuse from trigger. In theory this should work, I just have to do some more test to make sure it works as designed.
The "charger" setting contains all relevant information for the charger, like the 'id' to know what typ of charger it is, ip to access it, max allowed power and wanted default charge mode.
"car_info" setting contains information about the car, like what the wanted state of charge is, and the max capacity of the battery.
I look into a lot of different systems for rendering user interface for my python code. I wanted something light, fast and not to hard to implement. After trying out some some tests using Tkinter I was hooked. Even though I spend ridiculous amount of hours trying to compile and run latest version of python and Tkinter. My tip to you; just install python and tk using your favorite package tool.
Install tk-python on macOS
brew install python-tk
pip3 install tk
Install tk-python on Raspberry Pi OS
sudo apt-get install python-tk python3-tk tk-dev
The book I picked for learning Tkinter was "Modern Tkinter for Busy Python Developers: Quickly Learn to Create Great Looking User Interfaces for Windows, Mac and Linux Using Python's Standard GUI Toolkit". Decent book, though it focuses too much in the beginning on that the user should compile and install latest version of Tk, just skip that and install tk through your package tool.
After reading and fiddling around with Tkinter (and a lot of googling!) I ended up with the GUI below running on macOS.
And this is how the GUI is rendered on Raspberry Pi OS. (Yes, I got bugs! π )
The touch screen I did go with was the 'Raspberry Pi Touch Screen 7"' + associated casing from my local Kjell & Company store.
To connect the screen to my raspberry Pi I just followed this Youtube tutorial.
Screen with mounted Raspberry Pi on top.
Screen mounted in casing.
The final installation below.
My GUI running on the device. The screen is not great, but it works for now.
Okay, that's it for now. Please feel free to give me feedback on the project or this blog post by sending me an email, you find my address below.