├── README.md └── TeslaScanner.ino /README.md: -------------------------------------------------------------------------------- 1 | A Tesla scanner for ESP32 devices. (with bluetooth) 2 | 3 | Tesla uses the same device naming convention for the bluetooth door lock or whatever for all of their vehicles, 4 | first letter is "S" and the eighteenth is "C". 5 | 6 | This program will constantly scan for devices in the area fitting that convention, and (in this case) flash the 7 | LED when one is found. Flashing speed/length is dependent on signal intensity, sort of war movie radar style. 8 | It's a fun game when driving, but can become obnoxious in certain areas. 9 | 10 | You can of course modify this program to control whatever your little heart desires. 11 | 12 | Written in the Arduino IDE and uses several libraries included with the ESP32 boards. 13 | 14 | For educational use only, we are not responsible for any use outside of education. 15 | -------------------------------------------------------------------------------- /TeslaScanner.ino: -------------------------------------------------------------------------------- 1 | /* A bluetooth scanner for ESP32 devices to find Tesla vehicles and do things. Tesla in all their genious uses the same bt device naming convention 2 | across all (truck included) vehicles, first letter "S" eighteenth letter "C". 3 | 4 | I'm a codelet and this was written in the Arduino IDE, this particular version for an ESP32-CAM module. (POS, avoid) 5 | Will flash the very bright LED when a Tesla is in the vincinity, altering speed/duration dependent on signal strength. 6 | This can of course be modified to fit your device/desired action. 7 | 8 | Uses the libraries listed below obviously, thank you to Neil Kolban and Evandro Copercini. Update to newest libraries 9 | in case of errors. 10 | 11 | */ 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | //change this to your LED pin or whatever you want to control 20 | int goPin = 4; 21 | 22 | 23 | 24 | int scanTime = 5; //In seconds 25 | BLEScan *pBLEScan; 26 | 27 | class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks { 28 | void onResult(BLEAdvertisedDevice advertisedDevice) { 29 | 30 | 31 | if (advertisedDevice.haveName()) 32 | { 33 | //print device name, determine if characters at 0 and 17 match Tesla convention 34 | Serial.print("Device name: "); 35 | String stringName = (advertisedDevice.getName()); 36 | Serial.println(stringName); 37 | Serial.println("--"); 38 | char firstletter = stringName.charAt(0); 39 | char lastletter = stringName.charAt(17); 40 | 41 | //its a Tesla, do things 42 | if(firstletter =='S' & lastletter =='C' ) { 43 | Serial.println("FOUND IT"); 44 | 45 | //determine signal strength, maybe map a trimpot input here to adjust 46 | int rssiSigned = (advertisedDevice.getRSSI()); 47 | int rssi = constrain (rssiSigned - (rssiSigned * 2), 80, 100); 48 | Serial.println(rssi); 49 | int jaws = map (rssi, 80, 100, 50, 1000); 50 | for (int i = map (rssi, 80, 100, 10, 1); i > 0; i-- ){ 51 | digitalWrite(goPin, HIGH); 52 | delay(100); 53 | digitalWrite(goPin, LOW); 54 | delay(jaws); 55 | } 56 | 57 | } 58 | 59 | } 60 | 61 | 62 | } 63 | }; 64 | 65 | void setup() { 66 | Serial.begin(115200); 67 | delay(2000); 68 | 69 | pinMode(goPin, OUTPUT); 70 | digitalWrite(goPin, LOW); 71 | 72 | Serial.println("Scanning..."); 73 | 74 | BLEDevice::init(""); 75 | pBLEScan = BLEDevice::getScan(); //create new scan 76 | pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); 77 | pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster 78 | pBLEScan->setInterval(40); 79 | pBLEScan->setWindow(40); // less or equal setInterval value 80 | } 81 | 82 | void loop() { 83 | // put your main code here, to run repeatedly: 84 | BLEScanResults *foundDevices = pBLEScan->start(scanTime, false); 85 | // Serial.print("Devices found: "); 86 | // Serial.println(foundDevices->getCount()); 87 | // Serial.println("Scan done!"); 88 | pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory 89 | // delay(500); 90 | } 91 | --------------------------------------------------------------------------------