In the world of gas cars we have a well-accepted metric for understanding a car's efficiency: Miles per Gallon (MPG). MPG is often used to get a general sense for how "expensive" a car will be to operate. (e.g. "35 MPG is pretty good......5 MPG is pretty bad.") It also is used to compare the efficiency of two cars. However in the world of electric cars this metric obviously doesn't make sense, as there are no "gallons of gas" in an electric car.
The Electric Vehicle industry has developed a metric they hope will be an equivalent to MPG: Miles Per Gallon Equivalent (MPGe). The thought process goes like this: One gallon of gasoline contains the same energy as 33.7 kWh of electricity. Therefore, if an electric car can travel 100 miles on 33.7 kWh of electricity, it would have an efficiency of 100 MPGe. This methodology can be used to compare the relative efficiency of two electric cars. But it doesn't help gasoline car owners get a sense of the operating costs of an electric car. Our electric car has an MPGe of 117 city and 131 highway. I don't know about you - but that data doesn't help me understand whether operating this car will be "expensive" or "cheap".
We took delivery of our electric car on Dec 8, 2021. Through Jan 31, 2022 we've driven 635 "local" miles (i.e. errands and other trips close to home). We also drove 2,911 miles over 9 days during a trip to CA and back. The following cost comparison excludes that road trip - since that was not "typical" driving for us.
Gasoline Vehicle Cost
Our electric car replaced a 2019 GMC Terrain. The Terrain typically got about 25 MPG in city driving. 635 miles would require a little over 25 gallons of fuel. At $3.34/gal - that's a fuel cost of $83.50.
Electric Vehicle Cost
We charge our car using electricity from two sources. Our preferred power source for car charging is our solar panels. If we're not able to get the power we need from solar we pay for power from our electric company - like we do when we use any other electric appliance in our house.
Driving the 635 of in-town miles required 301 kWh of electricity. 251 kWh came from the solar panels. 50 kWh were purchased from the electric utility.
The 251 kWh from solar that went into the car weren't "free". If we had returned that power to the utility (sold it to them) we would have received $15.06 of credit toward our electric bill. The 50 kWh we purchased cost us $3.50. Therefore, the energy needed to drive those 635 of in-town miles cost us $18.56. This, of course, does not include other costs of gas cars such as oil changes, etc. Including those would make the difference even more dramatic.
$83.50 for gasoline vs $18.56 for electricity - to drive 635 miles. On a per-mile basis the electric car costs us about 22% of the cost of a gasoline vehicle.
Not everyone has solar panels. So what would the energy for the 635 miles cost if all of it had been purchased from our utility? $24.57. Still - considerably less expensive than gasoline-based transportation.
Sometimes technology utterly stuns me. The first time I downloaded an album from the comfort of my couch is one instance. Receiving a phone call in the car for the first time is another. The most recent example: A car having an API and what can be done as a result.
The first few hours of learning to use the Tesla API were pretty frustrating. My "Hello World" program was a few lines of code to honk the horn. After an hour or two I got it to work:
Wife: "What was that?"
Me: "That was the sound of Python talking to the car!"
A program talking to a car was the first stunning event. The second came when I used a simple "Get Status" command and saw what was returned. Listing all of the information here would make this post too long. But examples of available car data include: GPS coordinates, battery charge level, odometer reading, cabin temperature, status of each of the 5 seat heaters, is someone sitting in the driver seat....and on...and on...and on.
The final stunning event: The Tesla is connected to the internet all the time. So getting this data, as well as the ability to control various car functions, can be performed wherever the car is. Before learning the detailed capabilities of the API I figured, when checking if the car was home, I'd attempt a ping on the local network. But instead Suncatcher checks the car's GPS coordinates to determine if it's in the garage or not.
For those interested in learning more I'm using TeslaPy: https://github.com/tdorssers/TeslaPy
A few weeks ago I wrote of a project I was starting that would adjust the charging rate of a Tesla based on the electric production coming from solar panels. The goal is to "capture" excess solar being produced (i.e. power that normally would be sold back to the utility) and direct it to the car. There are two drivers for this goal:
Since "excess power" can vary widely through the day (solar production can change based on clouds, weather, etc.; and in-house consumption varies as well with tasks such as cooking, laundry, etc.) some form of automated solution is desired to respond to these variabilities and adjust the car charging rate as needed.
The First Half Of The Solution
Prior to the car's arrival I put together some basic code to talk to our Eagle-200 hardware device. This little box connects wirelessly to our smart (electric) meter and reports whether electricity is flowing to the grid or being pulled from the grid. This is the key information that is required when deciding if the car charging rate should be increased or decreased.
The Second Half Of The Solution
Now that we've taken delivery of the car the second half of the solution has been able to be put into place: communicating with the car using Python. Initial interactions with the car's API was a fascinating experience all on its own. The amount of car information accessible via the API is simply astonishing. More on this will be written in a separate post. In order to implement this project the Tesla API is being used to:
After establishing the basics of how to communicate with the car, work could begin in earnest to debug and refine the software. After about a week of work the software is now in a pretty stable state - successfully changing the rate of car charging based on leftover or "extra" power coming from the solar array.
The images below show (on the left) a graph of solar production on a recent day and (on the right) a graph of car charging (amps) through the day. All adjustments to car charging (including identifying when the car was physically unavailable for charging and restarting charging on its return) were handled automatically by the software.
Anyone interested in running this solution is welcome to have it - free of charge. The code needs to be "cleaned up" to make it easy for users to change some settings based on how they would prefer the software to behave (e.g. how often the system checks to see if adjustments need to be made). I will also be putting together some documentation/instructions for getting the system running.
If you wish to be notified when this is ready for distribution please send me an email. I will contact you when it is ready for download. Or watch this site for new blog posts on the topic.
My wife recently read Ashlee Vance's book about Elon Musk. She found it compelling - and reported I would as well. She was right. I loved it.
As a result of learning more about Musk, his vision, and his drive we decided to order a Tesla. Delivery is a ways out (Mar 2022). But that hasn't stopped us from thinking about what driving will be like with an electric vehicle, and figuring out ways to use it as efficiently as possible.
Since we already have solar panels on our house, we started thinking about whether we'd need additional solar production, as well as strategies for optimizing charging the car. It would be great if we could automatically adjust car charging based on electricity being produced by our solar array and electric consumption in the house ... all in real time. We want to see how much power we really need to meet our needs.
Monitoring Solar Output
A number of months ago we decided we wanted a better real-time handle on whether we were sending power back to the grid or pulling power from the grid. We bought an Eagle-200 from Rainforest Automation. This little box (~$100) connects (via Zigbee) to your smart electric meter. There is a nice phone app that provides a view of what is happening at the meter. This enables us to see if power is being sent to the grid (solar production exceeding current household use) or the opposite - we're pulling power from the grid.
Controlling Car Charging
The Tesla's phone app enables the user to start and stop car charging, charging based on time of day, and also charging speed.
Putting Them Together
The easiest solution to synchronize the two is to look at the Eagle-200's app and see if excess power is going to the grid, and then use the Tesla's app to start or stop charging as appropriate. While this method clearly provides benefit, it's not ideal. Weather changes through the day impact solar production. Usage in the home also varies. This results in sometimes significant variations in how much energy is being returned or pulled from the grid at any given moment. An automated solution would be much more effective.
Fortunately both the Eagle-200 and the Tesla have APIs that can be used to programmatically communicate with each device.
Since I have the Eagle-200 I was able to work out getting instantaneous power data from it into a Python program. I wrote a simple program to start/stop car charging, as well as adjust rate of charge based on power flow at the meter. Obviously I need to actually have the car before the solution is truly implemented. But placeholders have been created where car-specific code will be placed when we take delivery of the car and the connections can be tested. (I'm also confident the code, as written below, won't behave as expected when it really gets connected to the car. I always surprise myself with unexpected realities when testing software.)
Hopefully a simple solution like this will enable us to maximize the utilization of power being generated by the solar array.
Thanks to Lalit Pandit for help with JSON and Python!
Thoughts about Solar Energy, Electric Cars, Train Alert and more.