A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By shivansps
#95268 Hi,
i wanted to share a little project that i just finished, it is a wifi based smart door using a ESP-01 and a relay module.
The idea behind this is that any family member can easily open a door that has a electric lock, whiout having to being up a app or URL to press a button, since i already have a wifi everyone is connected to i had the idea of using packet sniffing to detect "friendly" cellphones and RSSI to detemine proximity.

Since i didnt need to do channel hoping, since i know the channel of the AP where the cellphones are connected to, this works better than i expected, yet, but its not perfect. In my phone just unlocking the phone near the ESP-01 is enoght for the phone to send wifi packages and the ESP-01 can easily detect it, but with other phones sometimes it takes some extra effort. Also the phones need to be using 2.4ghz wifi and not 5ghz. A 5Ghz ESP32 or something would be very usefull for this.

Using BT and a ESP32 should be better for this, because when the BT is enabled on the phone, the ESP32 should always see it whiout having to do anything, at least in theory, but cellphone BT usually changes the mac every time, and i could not come up with a viable method that could work, not even in theory. Also using a ESP32 for something as simple as this is kind of a waste.

Here what im doing is having a php file on a internal web server on my network. On my router (mikrotik) when a device connects to the wifi and the DHCP gives a IP, a script runs that calls the php file with the mac address, this stores the mac on a database. When the ESP-01 boot ups first it connects to the AP, calls the php, the php dumps all macs in the database, and the ESP-01 just checks if a device is close enogh (based on RSSI) and the mac is contained on that string, it actives the relay.

All the code is located here:
https://github.com/Shivansps/esp-01-proximity-wifi-door

The code is based on kalanda esp8266 wifi sniffer, i just removed everything that wasnt needed.
User avatar
By rooppoorali
#95275 Thanks for sharing your code. I came across a similar project using ESP32.

https://www.pcbway.com/project/sharepro ... 7d060.html

Could you please tell me what problems may occur if I implement this project? I find ESP32 more user-friendly than ESP-01. But from your post, it sounds like you prefer ESP-01 over ESP32 for this project.
User avatar
By shivansps
#95280 The purpose is the same but the way it works its diferent.

What that does is having the ESP32 connected to your network and to a relay, and when you run the blink app in your phone, it can trigger the relay.
I had similar system running for years that worked like that with my ESP-01. And i replaced it with this. I would open a URL in my phone and click a button to open the door.

You dont really need a ESP32 to do this very simple task. Im actually using a ESP-01 relay module that is very small for this:
Image

If you use a full ESP8266 or the ESP32 you are going to need more space. And if you are not using any of thos extra features that the ESP8266 or the ESP32 have, whats the point? I would definately use the ESP32 if i was using some of his features, like BT... or if it had 5ghz wifi.

The relay need only one GPIO, means there are still 3 working gpios on the ESP-01, you can add extra indicator leds, a i2c display, even audio to play a message or one of those serial based fingerprint readers too. For a basic smart lock the ESP-01 is enoght.

As for you main question, this works in a diferent way, in this way the ESP-01 detects your phone when it is transmiting data via wifi, any data, and for me this works perfectly because just pressing the unlock button (whiout even having to unlock my phone) near the ESP-01 is enoght to open the lock whiout having to open any apps ot even unlock it. So it is a lot faster, i got tired of having to open the browser url, sometimes i just cant specially if i have stuff on my hands. This way if im carrying something i could just have the phone in my pocket playing some internet audio or video and when im near the door it opens whiout having to do anything.

As i said this is not perfect, the main drawback is that the ESP-01 is 2.4ghz only means your phone needs to be connected to a 2.4Ghz AP in so the ESP can "see it", this is why you also need to know the channel that said AP is working on, as this only scan one channel.
Nothing of this is a issue doing it with a app like in the example you posted.

Other problems may be:

-You may miss your window, for example pressing the unlock button on my phone causes it to send wifi packages that the ESP can detect but if i do it too soon before the phone is close enoght it may not work until i actually open something that uses internet because the phone would not send any more wifi packages on his own.

-A door that opens based on a MAC address that transmits data nearby on a specific channel is not very secure, anyone that learns that the system works this way can just copy a known allowed mac to a device of his own and thats petty much all is needed to get access. In my case im not worried about that.

-Some other phones, like apple phones may requiere more interaction to cause it to send wifi data, but at worse i would need to open the browser in any random page, but that is not different than having to open an app or a browser url to press a button.

-The main drawback is that the phone needs to use 2.4Ghz Wifi in order to be detected...

As i said, a better way would be using BT (and that means a ESP32), because if you run round around with "BT ON" on your phone the ESP32 should be able to see it whiout you having to do anything, that would be a true proximity triggered smart lock, but as phones BT mac changes every time you power it on and off there is no way you can only allow the lock to be opened for some specific persons only.