"Superior Detector" - another version

Recently it appeared in the DIY section "Supervisor Detector" by @szdom. The topic aroused great interest, including mine. However, I decided to approach the problem differently - ESP was to collect data and periodically send it to the server. The main task is to detect the presence of someone`s cell phone nearby. This is possible thanks to the RSSI information. Generally, weak RSSI (small RSSI value) means greater distance between the transmitter and receiver. It may also result from an unusual pattern of occlusions and reflections. Therefore, this is a poor indicator. A high RSSI value indicates the proximity of the transmitter and receiver. This is rather a certain fact - I ignore directional antennas, etc.
I searched the Internet for code - how to acquire data and send it. I was thinking about constantly switching between listening and sending mode. The solution turned out to be much simpler - it is the WIFI_AP_STA mode, i.e. dual mode in which ESP works as both AP and STA.
Below is the original code that I found on several websites:
Code: Arduino
I failed to compile it in the original version - the reason was the newer ArduinoJson library. I also made a number of changes:
- blinking of the built-in diode - signaling the start, connection to WiFi and each sending,
- initial login using wifiManager,
- extension of MAC address collection time to 1 minute,
- for a given MAC, only one item is remembered, containing the highest RSSI value and the number of occurrences of a given address. Arduino code:
Code: Arduino
Below is an example code in PHP that receives data and writes it to a log file:
Code: PHP
Hardware
The hardware is so trivial that I did not dare to present this article as a DIY

MAC devices
Current cells use random MAC addresses when trying to connect:

Random MAC addresses are easy to recognize - if the second MAC digit is 2, 6, A, or E, it is a random MAC address. As you can see from the diagram above, Android introduced random MAC addresses in connection attempts in 2017. Interestingly, random MAC addresses have also been used since 2019 when connecting to a WiFi network. However, there is an exception here - the randomly selected address is constant for a given SSID. This solution is necessary due to access points presenting regulations or requiring consent. We find this type of access in hotels, restaurants and other public access points. A permanent change to the MAC would require constant confirmation of the regulations. There will probably be changes in this respect, e.g. MAC address randomization if you have not logged in to a given network for a given period (e.g. 24 hours). So, can the “supervisor detector” work? Well, if a phone with active WiFi is within the range of its network, it can be identified. However, if it is outside "its" WiFi network, this is not possible.
Because the log contains information about all "caught" MAC addresses, if they are not random, you can identify the manufacturer of the WiFi card, and sometimes also the manufacturer of the equipment. However, these will mainly be routers and other stationary equipment.
However, my goal was to use the system for some kind of supervision. After placing it in a building (preferably inside), it can tell us whether any cell was near the house or even inside. I use it in a newly built house and I can say that it detected my (and not only my) presence. Of course, RSSI thresholds need to be established. In my case, it turned out that non-stationary devices with RSSI above -75 mean they are close to home. RSSI above -70 is directly at the house or inside the building. Cells are very talkative. A connection attempt is recorded practically every minute. By looking at the table, I can determine the time of arrival, stay and departure from the house.
If you liked the article or contained useful information, give it a "plus"
Comments
Thanks for developing the idea, I also think that user @szdom`s idea deserves further development. If you give me the Parcel Locker, I will send you a small gift! :) [Read more]
I use a system to detect whether someone is near or inside the house. As I wrote, the MAC address in the WiFi network in which we are logged in, although random, is permanent. If we assign such a MAC to... [Read more]
@krzbor Nice project. Thanks for reminding me about the WIFI_AP_STA mode, I forgot that this mode existed. The tracking possibilities are truly enormous. By installing several/dozen such devices in an... [Read more]
An interesting development of the project may be replacing the sending of information to the server with MQTT. Instead of a minute, we can collect data for a second. Our MQTT client on ESP can subscribe... [Read more]
If someone's arduino code wasn't working, a small correction needs to be made, in two places. Such was: HTTPClient http; ... http.begin(host); Replace with this: WiFiClient client; HTTPClient... [Read more]