ESP8266 Automotive Keyless Entry (no keypad)

373 views
Skip to first unread message

Zim

unread,
Feb 18, 2020, 7:58:09 PM2/18/20
to annex_w...@googlegroups.com
 After locking my keys in the truck, I always wanted a keyless entry. I hate the idea of drilling holes for a keypad or having any kind of switch out in the elements.
Along came the XKC-Y25-PNP fluid level switch from china. Easy to position inside a vehicle behind glass. I have since relocated to the side rear window. Then came Annex!!
 You will have to do your own homework on how to attach to your door locks. Connect across the outside key switch
is the easiest, as it will also disable the alarm if it has one.  I am lucky to have a vehicle schematic, so I'm going to the Body Control Module....
 The esp8266 parasitic drain is too high, so deep sleep is applied  when unlocked, or  30 seconds after the last code attempt.
The 30 seconds also allows you to log in to AP mode as well, if you want to change the code.
 The added electronics allows the code entry pin to also issue the "wake up" call, so no need for 2 sensors.
Watch the bottom video for operation.

 Total project was under $20
Hope this helps someone!


lock.jpg



























Door locks_schem3.jpg











CODE: xxxx.bas

' lock v5
GOSUB CREATE_PAGE
CREATE_PAGE:
CLS
TIMER0 1000, CHECK
TIMER1 30000, SLEEEP  'puts it to sleep after 30 sec of inactivety
CNT = 0
CNT2 = 0
UNL$ = ""
D1=5:D2=4:D6=12:D7=13      'D1 mini format to io
PIN.MODE D6, OUTPUT       ' keeps reset high, preventing reset while awake
PIN(D6) = 1                 
PIN.MODE D2, OUTPUT    'D2 is an output to relay
PIN.MODE D1, INPUT   'D1 is input pin for sensor. It also wakes from sleep
PIN(D2) = 0                   
AUTOREFRESH 1000
WAIT

CHECK:
IF PIN(D1) = 1 THEN TIMER1 30000, SLEEEP 'sleep 30 sec. after last key press
IF UNL$ = "AB" THEN LET CNT2 = (CNT2 + 1) ELSE CNT2 = 0
IF CNT2 = 6 THEN LET UNL$ = ""
IF PIN(D1) = 0 THEN LET CNT = 0
IF PIN(D1) = 0 RETURN
PIN.MODE D7, OUTPUT  'led flash
PIN(D7) = 1     
PAUSE 100      ' for indicator visibility
PIN(D7) = 0
PAUSE 800       'critical for finger off responce time
CNT = CNT + 1
IF PIN(D1) = 0 AND (CNT = 2) THEN LET UNL$ = "AB"                          ' unlock
IF PIN(D1) = 0 AND (CNT = 1) AND (UNL$ = "AB") THEN LET UNL$ = "ABCD"      ' code
IF PIN(D1) = 0 AND (CNT = 3) AND (UNL$ = "ABCD") GOSUB UNLOCK ELSE RETURN  ' 213
IF PIN(D1) = 0 RETURN
RETURN

UNLOCK:
PIN.TONE D7, 8, 1500 'flashes led to confirm unlock
PIN(D2) = 1    
PAUSE 900   'pulse relay
PIN(D2) = 0
UNL$ = ""
PAUSE 500
SLEEP 0
RETURN

SLEEEP:
PIN(D2) = 0
PAUSE 10
SLEEP 0



















Untitled.mp4

Dwight

unread,
Feb 18, 2020, 9:00:35 PM2/18/20
to Annex WiFi RDS
Hi Zim,
Great project!  Reminds me when I added a intermittent windshield wiper controller to my 1966 Chev Truck back when I was in college (1979)  But then I used a 555 timer circuit.  Microcontrollers weren't even invented yet, and wifi??, what's wifi??

A few questions, though.

It seems you are calling a subroutine right at the start that does not end with a return.  Is that intended?

As I look at the doc's for the SLEEP statement it says Note : GPIO16 must be connected to RST pin to wakeup from sleep
Yet it appears that you have gpio14 connected to RST through the diode.  Can you explain.

Are you using the water sensor to detect your finger?? if so that is pretty ingenious! 

All in all a great project.
Would be a nice one to share with Hackaday.
Would be awesome if we could get some publicity to Annex.

thanks for sharing!!
dwight



Zim

unread,
Feb 18, 2020, 9:43:49 PM2/18/20
to Annex WiFi RDS
Hi Dwight
"It seems you are calling a subroutine right at the start that does not end with a return.  Is that intended?"
Only missing at the last routine. Just lazy....when it goes "sleep 0"  all is forgotten, so its not needed


".Yet it appears that you have gpio14 connected to RST through the diode.  Can you explain"
Once the module is awake, D6 keeps the reset pin "high" so that the reset pulse from D1 doesn't keep
resetting it with additional presses.
GPIO16 is only used to wake up the module at a predetermined time, set on an internal timer.
I want to wake up the module on the first touch of the sensor, which could be weeks later.

Are you using the water sensor to detect your finger?? if so that is pretty ingenious!
Yes, and it detects it very well, and the sensitivity is adjustable.
Really cool sensor...

Thanks for your interest!
Zim
 

Dwight

unread,
Feb 18, 2020, 11:15:41 PM2/18/20
to Annex WiFi RDS
Thanks for the reply, Zim.

Very clever circuit... I've never played with the SLEEP command... gonna have to try it out.

But I'm worried that your esp/annex might turn on you some day for always putting him to sleep with that one item on the stack without a RETURN.  Might cause some sort of imbalance in the negative charges and holes and result in some sort of mental breakdown :-)

you could just eliminate the first line of code and 'fall' right into the main routine.

Your code/circuit combination is something I'm gonna have to breadboard up and test out.

I love it!
cheers
dwight

PeterN

unread,
Feb 19, 2020, 3:24:17 AM2/19/20
to Annex WiFi RDS
Hello Zim

Very cool design - especially the deep sleep / wake up circuit!!
And again very amazing what a few well thought out lines in ANNEX can do.

Sensor: For similar purposes I used a cheap capacitive touch sensor TTP223 which can be placed behind a non-conductive surface.

Thanks for sharing
  

Electroguard

unread,
Feb 19, 2020, 4:58:22 AM2/19/20
to Annex WiFi RDS
Nice practical project Zim, and nicely presented....I suspect sales of fluid switches may spike (I've just ordered mine).

Theo

unread,
Feb 19, 2020, 5:31:08 AM2/19/20
to Annex WiFi RDS
The flyback diode for the relay is missing, the port of the esp8266 will soon be gone!

PeterN

unread,
Feb 19, 2020, 5:42:46 AM2/19/20
to Annex WiFi RDS
Hi Theo

The relais  is an active relai module with a transistor input and the schematic is only a bit simplified 

Otherwise, the ESP8266 output might not be able to supply enough current for a directly connected relay 

Theo

unread,
Feb 19, 2020, 7:45:26 AM2/19/20
to Annex WiFi RDS
Ok, I was a little worried. :)

Zim

unread,
Feb 19, 2020, 1:48:26 PM2/19/20
to Annex WiFi RDS
Thanks Electroguard. The sensor is very useful.

Thanks PeterN. I just ordered 10 of those touch switches. I didn't realize they have a 5mm range. They also may work good for this application! (and way cheaper)
Maybe one could glue them to the inside of the window and have a full keyboard. Maybe even stick a decal between them and the glass for numbers/letters.

Man...there is just no end to Annex projects!

Zim


PeterN

unread,
Feb 19, 2020, 2:38:15 PM2/19/20
to annex_w...@googlegroups.com
Hello, Zim,
I have had good experience with the touch sensor also as a standalone switch for a LED kitchen unit lighting. I designed the sensor surface as 10cm*5cm metal stripe behind 3mm glass.  Works great!
The switch can also be set for the toggle mode so I could switch one of the relais modules that you know.:

schematic.gif


The Sensitivity can be adjusted by  C3 at pin1  and by the size of the sensor:  "When do not use the Cs to VSS, the sensitivity is most sensitive. When adding the values of Cs will reduce sensitivity in the useful range (0≦Cs≦50pF).   "
For an MP3-Player I have uses thumbtacks as touch sensors 


Here you will see it operate thru 6mm wood:
https://www.youtube.com/watch?v=rcp-eIQ44I0

PeterN

unread,
Feb 19, 2020, 2:44:26 PM2/19/20
to Annex WiFi RDS
PS: I used the tacks with the tip down for safety reasons!!

Dwight

unread,
Feb 25, 2020, 12:44:31 PM2/25/20
to Annex WiFi RDS
I bought a few of those TTP223 touch sensors already made up as a touch switch and they work GREAT!
If you search for TTP223 on either Amazon, Aliexpress or ebay you can see the tiny little pre-made boards.

Thanks for sharing that tip Peter!
dwight

Zim

unread,
Feb 25, 2020, 12:51:10 PM2/25/20
to Annex WiFi RDS
Hi Dwight
I haven't received mine yet. Can you see if the will work through 1/4" of glass?

Thanks
Zim

PeterN

unread,
Feb 25, 2020, 2:51:10 PM2/25/20
to Annex WiFi RDS
Hi Zim 

that will unfortunately not work with an unmodified sensor ....

BUT: I removed C3 (by cutting the ground line) and then enlarged the touch area  to a 30mm disc.
Than I had no problem with 5mm  glass (and then an additional 1.5mm glass)

Important when testing with different sensor diameters: The sensor startup-routine calibrates with the actual capacitive load. So give it a new start when changing the sensor plate 


I use a very much larger sensor for a kitchen lighting. And that works fine!  But the larger it is the more it reacts as an antenna to nearby electrical impulses. 


IMG_6263.JPG



IMG_6255.jpg


IMG_6262.JPG





PeterN

unread,
Feb 25, 2020, 3:05:54 PM2/25/20
to Annex WiFi RDS
Hi Dwight
Glad to hear it helped you out.
It was a bit problematic for me to modify this design to toggle operation because of the very small SMD components, but even that worked out fine.

Dwight

unread,
Feb 25, 2020, 10:58:39 PM2/25/20
to annex_w...@googlegroups.com
Hey Zim,

The ones I bought are 1cm x 1.5cm Red boards and they seem to work just fine through 1/4" (6.25mm)  plate glass.

they have an A & B jumper setting so you can choose latching/non-latching and High/Low for the output.

what a treat at 20 for $6usd off amazon
even cheaper if you can wait from china.

dwight

Zim

unread,
Feb 25, 2020, 11:03:44 PM2/25/20
to Annex WiFi RDS
Thats good news Dwight.
I will try them in my keyless entry. They will be easier to mount than the level sensors.

Thanks
Zim

Dwight

unread,
Feb 26, 2020, 2:26:56 PM2/26/20
to Annex WiFi RDS
Hi Zim,
I hope you don't mind... I had some time and modified your schematic to show the TTP 223 touch sensor module as well as the relay module.

see attached image
Thanks for sharing your project!
dwight

Zim's Keyless Entry.jpg

Zim

unread,
Feb 28, 2020, 3:52:36 PM2/28/20
to Annex WiFi RDS
No Prob Dwight!

Zim
Reply all
Reply to author
Forward
0 new messages