MAC based Wifi Door with an ESP-01
Posted: Sun Sep 18, 2022 10:29 pm
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.
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.