I built this project because my wife and I sometimes forget to plug in our Tesla after parking it in the garage (I forget, she just doesn’t do it). It usually happens when we unload groceries because I wait to plug in until after the bags are out of the trunk, otherwise the charging cable is a trip hazard and the charge plug could get bumped. We tried setting a reminder alarm for 8PM every evening but it eventually became background noise.
I wish Tesla would add some code to their phone app to remind me to plug in the car. This issue has been discussed numerous times on the Tesla forums but nothing has been done. There is a third party “Stats” app that can do the task and a whole lot of other stuff but it costs 50 dollars.
I don’t know how to program phone apps but I can hack together some code that runs on an Arduino. Since only 5 I/O signals are needed, an ATtiny85 microcontroller can also do the job. I've provided the schematic and code for both. I have a lot of spare electronic parts so I based the design on the components I already had in stock. This project ended up costing me nothing but time.
Two sensors are necessary, one to tell if the car is in the garage and the other to tell if the charge cable is hanging on the wall hook. I used an HC-SR04 Ultrasonic distance sensor to tell if the car is in the garage otherwise it reads the large distance over to the opposite wall. The second sensor is a push button switch at the base of the charge cable wall hook. If the switch is depressed, then the cable is hanging on the wall and not plugged into the car.
Obviously you can defeat the system if the charge cables are not on the wall hook and not plugged into the car. I’m not worried about this situation because I would never leave the charge cables in a heap on the floor. My solution also requires that if the car is in the garage, it must always be attached to the charger. I only charge to 80% (unless we're going on a road trip) but I leave it always plugged in so we don’t gradually loose charge to the “Vampire effect".
Circuit Description:
A simple active buzzer is turned on by the microcontroller if the car has been in the garage for over 30 minutes and the charge cord is still resting on the wall hook. This gives me plenty of time to unload the vehicle. As a debug aid and a power indicator, an LED blinks to show how many feet the ultrasonic sensor is measuring.
The circuit runs on less than 100ma at 5 volts DC which is provided from a spare wall wart power supply (I never throw them away). If using the Arduino Nano, 5 volts will be provided by the USB cable. When power is applied, the code turns on the buzzer for 1 second to confirm it works.
The main loop, which runs every 10 seconds, reads the pushbutton switch on the wall hook and the HC-SR04 distance measurement. If the car is in the garage and the charge cable is still on the hook, a counter is incremented. Once the counter reaches 30 minutes, the buzzer is turned on.
Two conditions will zero the counter (and turn off the buzzer); if the charge cable is taken off the wall hook or if two consecutive distance readings show the car has left the garage. I was worried that the HC-SR04 might occasionally give a bad (large) distance reading which would zero the counter so I added the requirement for two consecutive readings.
Blinking the LED to show the distance takes 10 seconds and is done at the end of each loop to control the repeat rate. If the distance is under 1 foot, no blinks are given for 10 seconds. If the distance is 10 or more feet, the LED is turned on for 5 seconds and turned off for 5 seconds. For a distance of 1 to 9 feet, the LED is turned on and off at a 1 second rate from 1 to 9 times. Then the LED is left off until the total time has reached 10 seconds.
The ATTiny85 code is called “Attiny_Buzzer.ino” and the Arduino Nano code is called "Arduino_Buzzer.ino". The code is the same for both, just different comments. Download the code from my GitHub repo.
I used the "ugly wiring" method with a general purpose prototyping board to wire the ATTiny85 as shown below. For an Arduino Nano, the extra parts can be wired "dead bug" style, so no board is needed.
I'll be using the ATTiny85 for future projects so I designed the general purpose circuit board shown below. The PCB is 20.4mm x 28.2mm and costs $4.45 for 3 boards from OSH Park. It still requires a few jumpers but it’s much easier to assemble than a blank board. The backside ground and front side power planes are exposed for easy solder connection. An 8 pin DIP socket is required so the ATTiny85 can be moved to a separate programmer like a Tiny AVR. The Eagle board file “ATTiny85.brd” or the Gerber layout “ATTiny85_2021-12-29.zip” can be downloaded from my repo.
Initial testing was done with all items out of the box until the code was finished.
Holes were drilled in the project box for the HC-SR04 transmitter and receiver sensors as well as the LED. They were epoxied to the box with JB Weld. The barrel jack power connector hole was drilled on the side. The lid for the project box was not used because the box was screwed directly to the mounting board.
The hook for the charge cables is made from a National Hardware N208-736 corner brace. The push button switch is bolted to the inner hole and the outer hole is screwed into the mounting board. The metal brace is pretty thick but just to be safe, I added a wood block underneath so it can't bend. The slot for the charge cables was too wide so I added 4 popsicle sticks to take up space. They are held in place with several wraps of electrical tape. A cleaner method would be to use large heat shrink tubing.
The mounting board is screwed to the wall studs for support. A large hole was drilled in the board directly behind the project box for wire routing. Wires from the switch under the wall hook are tacked under the board with staples and fed into the project box. To make sure the buzzer could be heard in the house, it was located on the other side of the wall, and glued in place. Two small holes were drilled in the wallboard for the wire connections.
Contact me if you have any questions.
Comments