Guy's Tesla Panel Build
The ugliest page on the net
UPDATES
3 March 2021: Rather big update:
Updated all the code to use JSON rather than manually finding text in the return value from the Gateway
Updated the code to display local tempature on Strip 6 rather than Grid Voltage. There is a variable Display6 in the script you can set to Temp or Volt to display Temperature or Voltage.
All diplays default to off pixels for those not having data now. To turn back to the light blue as in the photos, change the RGB values from (0, 0, 0) to (0, 1, 1)
9 Feb 2021 9:30PM : Sweet! New code released below in the link to the ZIP file which now logs into your Tesla Gateway to get the data required. You will need to edit the script to add your LOCAL Customer Login email and password to the script. To find out how to set up this local login account (if you hanv't already) follow the instructions on Telsa's page HERE.
9 Feb 2021 : eeek! Tesla just
updated my Gateway 2 and my code has stopped working as it now needs to login to
the Gateway before gettng the data for display.
I am looking into how to address this however it may take some time.
1 Feb 2021: Origonal page posted
Not yet finished, but getting there.
Currently, from left to right:
1: Battery Charge % (red when charging, green when 100%)
2: Solar generation (scaled to my max 10kW
3: Feed in kW to Grid (green for feed in, deep blue for draw)
4: Current house load (scaled to 10kw currently).
Next steps:
-Print some logos for the bottom (maybe an excuse to buy one of those laser
engravers 🙂
-Work out a good 5v power solution (currently running off a lab power supply. I
think I have an idea for this.
So you found my little page. 1st thing to note is I
am no web designer so yes, I know this page is not fancy, it is plain, but
hopefully it is also 'functional'. I am also sure there are many spelling
mistakes and typos in this page!
I started this little project as I have a Tesla Powerwall 2 with associated
Gateway 2 and I have found that I am always looking for a quick way to see what
is happening with not only the status of the battery, but also the PV panels,
household power usage, feed in or draw from the grid etc.
The Tesla app gives you a pretty nice way of seeing all that, but I have to open the app on my phone, its not exactly there at a glance.
I have set up an old Microsoft Surface 2 table/laptop to display the Gateway's local interface however from a distance its not easy to see the values, and because the Gateway uses a self signed certificate every now and then I need to re-accept the certificate for the page to display. I probably could find a way around this, perhaps installing the cert on the laptop would do it, but the display is still too small.
Therefore I embarked on a little project to create an analogue display to present the data. Analogue is always best for a quick glance of a value, when accuracy isn't overly critical.
Step 1: Set up your Raspberry Pi in the standard way. This is not part of this 'instruction set'. You just need Raspbian installed and the ability to access either a SHELL or VNC connection. VNC is easier for novices as it also lets you copy files from your computer to the Pi.
Step 2: Open a shell and run the command sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel
Note: This command is also in the text file you downloaded in the file "Setup For Light Strip.txt"
Step 3: Copy the file tesla.py from the ZIP file to your Raspberry Pi.
You can close this window now
Step 4: Move the file into your home folder. If you open the Folder browser it will default to your home folder. Just put the file in there. You really can put it anywhere you like however this is the folder a shell window opens in to it makes it easier to run if it is already in this folder
Before you run the code you have two tasks to complete.
Connect your Light Strip/s to the Raspberry Pi
Modify the code for YOUR light strip setup
Your light strip should be connected as one long string. This way we only need one signal line and just divide the strip up in the code for different display segments.
You will need to inject power into your strip from a separate power source as the Pi will not be able to power the strip itself.
My strip was 5v. As the Pi is also powered from 5v I was able to power both the strip and Pi from the same power supply. You can just use the USB port to power the Pi. Make sure the strip and Pi share a common ground. Connect the ground to the Pi on Pin 06. More info on powering your Pi here.
The default code runs the LEDs at almost their lowest brightness. Each 72 pixel strip consumed about 150mA at these low settings.
Connect the SIGNAL of the Strip to PIN12 (GPIO18) of the Pi. This is the default pin for the nanopixel library. See here for which pin is which on the Pi.
Open tesla.py with a text editor or Thonny IDE on the Pi itself
Find the section marked Constants
BEFORE
AFTER
Part 4: You will need to create an account and get an API key from openweathermap.org if you want to be able to display your local weather temperature on a strip.
If you want to slow up the refresh interval, find the line below and change the 1 to how many seconds you want to pause between updates
I hope that is enough to get you going. How you mount it is up to you, I might add some information later on how I did it if I have time.
Cheers
Guy Barwood