Giter Club home page Giter Club logo

teslachargedooropener's Introduction

TeslaChargeDoorOpener

Open the Tesla charge door with an Arduino and an ASK STX882 transmitter

Introduction

The Tesla charging cables come with a button that can open the charge door of the car so that is is quicker to plug in. Non-original cables do not have this button.

With an Arduino and a STX882 or similar ASK transmitter that costs a dollar or less on eBay, it is very easy to use this program to obtain the same functionality. I have not used an antenna, as the STX882 has long enough reach without one. This makes it a quite compact solution.

It can be programmed on an ATtiny to make it fit into small places, or on any other type of Arduino. It uses only 1078 bytes of storage and 53 bytes of RAM. I use an Arduino Nano and added a microswitch to the charge plug wall holder so that the signal is sent when I pull the plug out of the holder, making it smooth to plug it into the car with the door already open. For this use I do not use a battery.

Using a push button to power it on, it can be battery powered and last virtually forever.

How it works

This sketch will when powered on send a radio signal that will open the charge door of a Tesla car. After sending this signal at power-on, it will do nothing. This is meant for battery powered operation using a push button. You can of course change it to be always on and trigger on something else.

Pin 11 must be connected to the signal pin of an ASK STX882 433.92MHz transmitter that can be bought on eBay for a low price.

Normally, a transmitter should not be used without an antenna, but I have used the STX882 without one without problems for this project to keep the range very short to avoid opening the charge door of other cars nearby. The transmit times are so short it is unlikely to cause problems.

The message that is sent has been grabbed by using an SRX882 receiver to pick up the data sent by a Tesla charging cable with built in push button. The signal will be sent 5 times repeatedly, just like the charge cable button does.

The cable uses this signal to open the charge door when pushing the button while not being plugged in to the car. The car must be unlocked or you must be in bluetooth range with your paired phone.

When plugged in, the button of the cable can unlock the cable from the car too. This is not done by RF but through wires in the cable, so this sketch will not unlock the cable when plugged in.

teslachargedooropener's People

Contributors

fredilarsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

teslachargedooropener's Issues

Works on ESP32 and ESP8266 on 3V Lithium Battery

Dear Fredilarsen,

thank you so much for publishing this code. It works in my 2022 Tesla M3 delivered in December 2022 in Germany. I checked it on ESP32 and ESP8266 boards with 3V supply from a CR123 battery. The voltage is sufficient for both, the uController and the STX882 (I use it with the antenna). Boot time is less than 100ms, so, it works instantly.

I also added a 3V relay - both, the ESP8266 and the relay are directly powered by the battery thru a momentary switch (so, the relay is not connected to the ESP). The relay is used to switch the resistor for unlocking the charge plug. For the 22kW plug I use, two 220 Ohm resistors are in series, one so shorted by the relay when the switch is released. If the switch is pressed, the relay is actuated and opens the short so that the resistance increases to 440 Ohm which unlocks the plug. So, here, the NC pathe of the relay is used.

For a 11kW cable, one need to put a 1200 Ohm resistor in parallel to the built in 680 Ohm resistor. The relay is in series to the 1200 Ohm resistor on switched „on“ to unlock the charge plug. So, here, the NO path of the relay is used.

Details in thus in German here: https://blog.thesen.eu/tesla-command-button-beenden-und-entriegeln-des-steckers/

With an ESP8266 D1 Mini, I could fit everything in a Europen Type 2 plug. With just one switch I can now do both, open the charge door and release the charge plug.

With a CR123 lithium battery, it will last probably 10 years …

Best regards

Thomas

Adding code for RF sniffing the Tesla cable

Hi fredilarsen,
thanks for that great project. I already tried it using my EU Model 3 and it works perfectly!

One other question:
Could you maybe add the code you used for sniffing the rf signal form the charging cable? I would really like to take a deeper look into this. With common rf sniffing libraries I don't get any data from the Tesla cable....

That would be highly appreciated!

Also isn't there a method to unlock the charging cable after charging using an rf signal? The Tesla key fob is able to unlock the charging port!....

Thanks a lot!
Best,
Leo

Can you please share the waveforms how they look in a oscilloscope?

I tried this setup with an Arduino mega 2560 & ASK STX882. Code is exactly the same.
Then I checked the signals on data pin of STX882 on the oscilloscope but the signals were not as expected I suppose.
Are the signals supposed to be 433 MHZ for each duty cycle?
I had same experience with a 315MHZ transmitter also.
Can you please suggest what is wrong?
Attached few images for reference.

image
image
image
image

Working on Attiny85 and FS1000A cheap 433 Mhz transmitter

Just wanted to thanks you for your code !

I had an Attiny85 and FS1000A on the bench so decided to give it a try instead of buying new hardware... (I know other github on tesla door opener mention FS1000A can't be used but still wanted to give it a try) It took me some time to compare the tesla charger 433 signal output to the produced Attiny85/FS1000A one... Nor Attiny85 and FS1000A a super stable / calibrated devices... out of the box. The key element to this is the calibration of the Attiny85 internal clock to properly drive the FS1000A. There are several source for calibration of the Attiny85 on the internet (search for Attiny85 OSCCAL calibration). My option, since i wanted to calibrate the couple Attiny85+FS1000A was to use a logical analyser (cheap CY7C68013a mini board <$5) and record the 433 signal at different temperature and compare the time for one seri of pulse to the original tesla recording... (as reference a seri is 132ms on tesla charger EU and it send 5 of them).

Once calibrated I just set the OSCCAL value in the setup function, also I found it more "stable" to "warn" the FS1000A with a data HIGH before the sendsignal (at least it clearly helped the receiver to adapt the noise level for my analysis, but seems also to be more responsive on door opening...)

below the code (with the limited 2/3 changes mentioned above (attiny uses pin 0 for FS1000A, and pin 1 for LED)

`/*

  • TeslaChargeDoorOpener
  • This sketch will send a signal that will open the charge port door of a Tesla car.
  • It is similar to the button of a Tesla charge cable when not plugged into the car.
  • It will send the signal when powered on, then do nothing. Suited for battery-powered
  • operation using a push button.
  • Pin 11 must be connected to the signal pin of an ASK STX882 433.92MHz transmitter
  • that can be bought on eBay for a low price.
  • The message has been grabbed by using an SRX882 receiver to pick up the data sent
  • by a Tesla charging cable with built in push button.
  • The cable uses this signal to open the charge door when pushing the button not being plugged in.
  • When plugged in, the button on the cable can unlock the cable too. This is not done by RF, so
  • this sketch will not unlock the cable when plugged in.
  • The signal will be sent 5 times repeatedly, just like the charge cable button does.
  • Author: Fred Larsen
  • Github: www.github.com/fredilarsen
  • License: Apache
    */

// Pins
const uint8_t signalPin = 0; // The number of the pin with the output signal

// The signal to send
const uint16_t pulseWidth = 400; // Microseconds
const uint16_t messageDistance = 23; // Millis
const uint8_t transmissions = 5; // Number of repeated transmissions
const uint8_t messageLength = 43;
const uint8_t sequence[messageLength] = {
0x02,0xAA,0xAA,0xAA, // Preamble of 26 bits by repeating 1010
0x2B, // Sync byte
0x2C,0xCB,0x33,0x33,0x2D,0x34,0xB5,0x2B,0x4D,0x32,0xAD,0x2C,0x56,0x59,0x96,0x66,
0x66,0x5A,0x69,0x6A,0x56,0x9A,0x65,0x5A,0x58,0xAC,0xB3,0x2C,0xCC,0xCC,0xB4,0xD2,
0xD4,0xAD,0x34,0xCA,0xB4,0xA0};

//OSCCAL = 0x86;

void setup() {
OSCCAL = 0x91; //orig 86 //Best 91 Need to be calibrated per AtTiny
pinMode(LED_BUILTIN, OUTPUT);
pinMode(signalPin, OUTPUT);
digitalWrite(signalPin, HIGH); //HIGH to warm the FS1000A

}

void loop() {
sendSignals();
delay(1500);
}

void sendSignals() {
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(signalPin, LOW); //LOW before starting sendByte
for (uint8_t t=0; t<transmissions; t++) {
for (uint8_t i=0; i<messageLength; i++) sendByte(sequence[i]);
digitalWrite(signalPin, HIGH); //HIGH to keep FS1000A up between messages
delay(messageDistance);
}
digitalWrite(LED_BUILTIN, LOW);
}

void sendByte(uint8_t dataByte) {
for (int8_t bit=7; bit>=0; bit--) { // MSB
digitalWrite(signalPin, (dataByte & (1 << bit)) != 0 ? HIGH : LOW);
delayMicroseconds(pulseWidth);
}
}`

Constant broadcast of the signal

Dear Fred Larsen,what needs to be modified in the arduino sketch to emit the signal constantly?I'm sorry, but I'm not sure what to change, because I want radio signal to be always on .
Thank you!

Unlocking charge plug by wire

If you allow me, I modified your code so it can also remove the charging cable when connected.

It consists in a ESP32 (I used a compatible wemos esp32 d1 mini, a lipo battery, a wemos relay shield, and a STX882) PP cable is connected on the NC side of the relay, and it only cuts if the esp32 is powered on, and a registered BLE device is closeby.

Thank you for your code.

Regards,

CODE:
`/*

  • TeslaChargeDoorOpener
  • This sketch will send a signal that will open the charge port door of a Tesla car.
  • It is similar to the button of a Tesla charge cable when not plugged into the car.
  • It will send the signal when powered on, then do nothing. Suited for battery-powered
  • operation using a push button.
  • Pin 11 must be connected to the signal pin of an ASK STX882 433.92MHz transmitter
  • that can be bought on eBay for a low price.
  • The message has been grabbed by using an SRX882 receiver to pick up the data sent
  • by a Tesla charging cable with built in push button.
  • The cable uses this signal to open the charge door when pushing the button not being plugged in.
  • When plugged in, the button on the cable can unlock the cable too. This is not done by RF, so
  • this sketch will not unlock the cable when plugged in.
  • The signal will be sent 5 times repeatedly, just like the charge cable button does.
  • Author: Fred Larsen
  • Github: www.github.com/fredilarsen
  • License: Apache
    */

// Libraries
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEAddress.h>
#include <BLEAdvertisedDevice.h>

// Authorized BLE devices

String mybluetoothdevice1 = "11:22:33:44:55:66";
String mybluetoothdevice2 = "11:22:33:44:55:66";
String mybluetoothdevice3 = "11:22:33:44:55:66";
String mybluetoothdevice4 = "11:22:33:44:55:66";

// Pins
const uint8_t signalPin = 17; // The number of the pin with the output signal
#define LED_BUILTIN 22
// The signal to send
const uint16_t pulseWidth = 400; // Microseconds
const uint16_t messageDistance = 23; // Millis
const uint8_t transmissions = 5; // Number of repeated transmissions
const uint8_t messageLength = 43;
const uint8_t sequence[messageLength] = {
0x02,0xAA,0xAA,0xAA, // Preamble of 26 bits by repeating 1010
0x2B, // Sync byte
0x2C,0xCB,0x33,0x33,0x2D,0x34,0xB5,0x2B,0x4D,0x32,0xAD,0x2C,0x56,0x59,0x96,0x66,
0x66,0x5A,0x69,0x6A,0x56,0x9A,0x65,0x5A,0x58,0xAC,0xB3,0x2C,0xCC,0xCC,0xB4,0xD2,
0xD4,0xAD,0x34,0xCA,0xB4,0xA0};

int scanTime = 20; //In seconds
BLEScan* pBLEScan;
BLEScan* pServerAddress;

void sendSignals() {
Serial.println("sending chargeport transmission, disabling PP");
digitalWrite(LED_BUILTIN, HIGH); // Turn relay high, so it CUTS PP pin in order to unlock handle.
for (uint8_t t=0; t<transmissions; t++) {
for (uint8_t i=0; i<messageLength; i++) sendByte(sequence[i]);
digitalWrite(signalPin, LOW);
delay(messageDistance);
}
Serial.println("transmission ended, giving time for charging handle removal");
delay(10000); // Let's give you 10 seconds to remove the handle.
Serial.println("activamos manguera");
digitalWrite(LED_BUILTIN, LOW); // Turn relay low, reconnecting PP pin in order to lock handle.
}

void sendByte(uint8_t dataByte) {
for (int8_t bit=7; bit>=0; bit--) { // MSB
digitalWrite(signalPin, (dataByte & (1 << bit)) != 0 ? HIGH : LOW);
delayMicroseconds(pulseWidth);
}
}

class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
void onResult(BLEAdvertisedDevice advertisedDevice) {
// Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
// Serial.print("BLE Advertised Device found: ");
// Serial.println(advertisedDevice.toString().c_str());
// Serial.println(advertisedDevice.getAddress().toString().c_str());
String resultaddress = advertisedDevice.getAddress().toString().c_str();
if (resultaddress == mybluetoothdevice1 || resultaddress == mybluetoothdevice2 || resultaddress == mybluetoothdevice3 || resultaddress == mybluetoothdevice4) {
Serial.println("BLE device found");
pBLEScan->stop();
sendSignals();
// delay(10000);
}
}
};

void setup() {

pinMode(LED_BUILTIN, OUTPUT);
pinMode(signalPin, OUTPUT);
digitalWrite(signalPin, LOW);

Serial.begin(115200);
Serial.println("Scanning...");

BLEDevice::init("");
pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
pBLEScan->setInterval(40);
pBLEScan->setWindow(39); // less or equal setInterval value
}

void loop() {

BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
delay(2000);

}`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.