How to Create a Tesla Geofence: Automated SMS from your Model 3/S/X

Jamie Bailey
Initial State
Published in
5 min readMay 24, 2020
Tesla Geofence: Automatic Text Message from your Model 3/S/X

*Update 11/13/2020: Unfortunately, Tesla has started restricting access to their API through most major services including AWS. This decision has broken this tutorial.

Introduction

Your Tesla can do many amazing things from driving itself to updating itself. Let’s add another cool trick — automatically texting someone when you get close.

Here is my motivation for implementing such a feature. Every day I pick up my daughter from swim practice, which means driving through an obnoxious pickup process. She stays inside until I arrive, park, and text her that I am here. Or, she just texts me over and over “are you here yet?” while I am driving. Once she knows I have arrived, she grabs her stuff and walks out to the pickup area, which has a car line I pull up to after giving her a couple of minutes to get outside.

After repeating this 500,000 times, there are some unnecessary steps in this whole process I really want to eliminate for my own sanity. I could make everything so much quicker if I text her that I am almost there while driving and her meet me at the pickup area without parking first. That solution would be unsafe for obvious reasons (don’t text and drive!).

Here is what I want to happen. When I am about 3 minutes away from the pool, my Tesla automatically sends her a text message to get her stuff and meet me at the pickup area. I don’t park but go straight to the front where she is magically waiting for me, ready to get in the car every time.

This tutorial will show you how to create a Tesla geofence to automatically send a SMS text from your Model 3/S/X when you get close to a location. This is particularly useful for daily tasks like picking up the kids from school or practice. It is also another “look at what my Tesla can do that your puny car cannot” feature.

What is a geofence?

A geofence is a virtual perimeter or “fence” around a physical location.

A Geofenced Virtual Perimeter
A Geofenced Virtual Perimeter

The typical application of a geofence is to trigger an alert on entry or exit of the established perimeter. To implement a geofence like the one we need for this tutorial, you need a device that is detecting your location (such as a GPS monitor) and a web service that can trigger an action/alert if your device enters/exits a programmed perimeter.

What we will use for this tutorial

We need a GPS device and a geofencing web service to implement this project. Your Tesla Model 3/S/X is already equipped to be the GPS device as it constantly updates your GPS location to your Tesla account. You can access such data through the Tesla API (unofficially supported by the Tesla community — https://www.teslaapi.io ).

For the web service, we will use Initial State (https://www.initialstate.com). Two reasons to use Initial State. #1 it has a built-in integration to the Tesla API. #2 it can do geofencing trigger alerts. This will make implementing this project completely code-less and quick. Initial State is free for students and has a 14-day free trial for everyone else ($8.33/mo billed annually after the free trial).

Step 1: Set up an Initial State / Tesla integration

The first step in this tutorial is to set up an integration between your Tesla Model 3/S/X and an Initial State account. This will take about two minutes. Follow the detailed Getting Started guide at https://medium.com/initial-state/how-to-build-a-tesla-data-dashboard-with-the-tesla-api-4ebee4b9827c to complete this step (lots of screenshots!). Once data is flowing from your Tesla into your Initial State account, you can drive around and see your map data update with your GPS location.

Step 2: Set up a Geofence trigger

The next step is to set up your first geofence trigger. You need the GPS coordinates of the physical location you want to establish a virtual fence around. Go to Google Maps and find your location.

Using Google Maps to find GPS coordinates
Using Google Maps to find GPS coordinates

The GPS coordinates for your location can be found in the URL. For example, the GPS coordinates for my daughter’s pool above is 36.0020015,-86.7911145.

Initial State geofence trigger setup
Initial State geofence trigger setup

Inside your Initial State account, click on the settings link under your Tesla data bucket. Click on the Triggers tab to create a new trigger.

  • Select the Stream Key to be location.
  • Choose the Operator to be enters.
  • Set the Radius (km) to be how wide you want the geofence perimeter to be (e.g. 0.5).
  • Paste the GPS coordinates in the Location Coordinates field (e.g. 36.0020015,-86.7911145).
  • Set a notice to be the phone number you want to message (you will need to verify your phone number the first time).
  • You can change your message template to be whatever you want (e.g. I am getting close to the pool, get your swim bag and meet me outside). You can use emojis to give your message a bit more style.
  • Click the Create button to create the trigger. Don’t forget to do this step or your trigger will not be created.
A set up geofenced trigger alert
A set up geofenced trigger alert

If successful, your trigger setup will look like the screenshot above.

Step 3: Test it out

Your geofence trigger is now live. Drive to your target location and make sure you get a text message every time you enter the geofence.

Tesla geofence trigger SMS message
Tesla geofence trigger SMS message

Conclusion

Geofenced trigger alerts can be really useful or just convenient for certain applications. While this tutorial set up an alert on entry of a geofence, you can just as easily set up an alert on exit. For example, you can have your Tesla text your spouse when you leave work. If you let someone borrow your car, you can set up an alert if they drive too far away. If traveling, you can use geofence alerts to set reminders to do something when you get there (e.g. “don’t forget to charge your Tesla when you arrive!”). Geofencing can be more than just a cool trick but end up being a really helpful, automated function you use daily.

--

--

Jamie Bailey
Initial State

EVP Strategy, Alto | ex-CEO Initial State | SaaS | startup guy | nerd