Ever wondered how to check who's connected to your Wi-Fi? That's exactly what I did! Using the ESP8266 Wi-Fi module, I built a system to monitor my network and keep track of all connected devices. Whether you're at home, in the office, or living in a shared flat, this setup gives you a clear view of who's using your Wi-Fi.
At home, I can easily see when family members are online or who's currently around. In the office, it helps identify any unfamiliar devices trying to connect. And in a shared flat, it’s a simple way to know who’s home without needing to ask.
The system is specifically designed for my Airtel Xstream Fiber router, and it’s easy to set up. It also sends notifications through a Telegram bot, making it super convenient to stay informed.
Features:
- ✳︎
Device Monitoring: Detect all known and unknown devices connected to your Wi-Fi.
- ✳︎
User Presence: Instantly know who’s at home, in the office, or in your flat.
- ✳︎
Alerts: Get updates via Telegram.
- ✳︎
Compatibility: Tailored for Airtel Xstream Fiber routers, especially my home setup.
Supplies:
- ✳︎ESP8266 WiFi Module
- ✳︎3D Printer (Blue, PLA)
- ✳︎USB C Cable
- ✳︎3.3V Power Adapter
This link is not affiliated with anyone and is not a recommendation. It's always a good idea to explore other options and do some research before making a purchase
Step 1: Get Started
I've set up an ESP8266 Wi-Fi module to crack into my own Wi-Fi and figure out who’s connected to it. This little device stays near the router, constantly on, scanning for the MAC addresses of all connected devices.
By matching these addresses against a list I’ve made, I can see exactly who’s on my network. The best part? Whenever I need an update, the module sends the full list of connected devices to me through Telegram.
It’s my personal way of keeping tabs on my Wi-Fi and spotting both known and unknown devices in real-time!
Step 2: Wi-Fi Router
My Wi-Fi router is the Airtel Xtreme Fiber. I created two networks: one with a 5GHz frequency and another with 2.4GHz. I connected the ESP8266 to the 2.4GHz network because it only supports 2.4GHz connections.
Collect Data
Collect the MAC address of known devices and label it with the owner's name. this can be used to identify known device.
Step 3: How to Detect Connected Devices?
Using ARP (Address Resolution Protocol):
I get to know that the ARP (Address Resolution Protocol) command provides a list of IP addresses and their corresponding MAC addresses on your local network. This ARP table helps in mapping IP addresses to MAC addresses, which is useful for identifying connected devices.
using arp -a in the command in windows will give below list
Where dynamic entries represent devices that are currently connected
When I disconnected the device from the network, its entry still stayed in the ARP table for a while because ARP entries are cached for efficiency. I used the ping [disconnected IP] command to ping to the same IP. Then again run
arp -a
then entry is removed.
So, what I understand is that I need to loop through all the valid IP addresses, send a ping to each one ranging from 192.168.1.1 to 192.168.1.254 After pinging, I can use arp -a to list to get the updated connected devices.
The arp -a command works on computers with operating systems like Windows, Linux, and macOS. However, it won’t work on the ESP8266 because it’s a microcontroller, not a full operating system. So, we can’t use this command on the ESP8266 ❌
Pinging Home Network IPs for Active Devices:
I wrote a script to connect to the Wi-Fi router using esp8266 Wi-Fi module. Once connected, the script loops through all the IP addresses in a typical home network, from 192.168.1.1 to 192.168.1.254. By pinging each IP address, the script finds out which ones are currently in use, helping to see which devices are active on the network.
However, since IP addresses can change (they are dynamic), identifying specific people based on their IP address might be difficult.
We can’t find the Mac address of the device by doing the above method ❌ Another option is to use network scanning tools like nmap. But this requires running the tool on a device with enough capabilities to handle it ❌
What's Next?
Next, I considered connecting to the router's web interface or API. If an API was available, I could use an endpoint to check who is connected to the router. Many routers also provide an admin interface that displays connected devices, so if I could access this, I might be able to scrape the data directly from the web interface.
I decided to test this on my Airtel Xstream Fiber router. After exploring its interface, I found that I could indeed access the list of connected devices. To do this, I first needed to authenticate to the admin interface. Once authenticated, I discovered the API endpoint that the interface uses to display connected devices in the UI. I examined the response and found that it was in HTML format. I then wrote a script to parse the hostname, IP address, and MAC address from this data.
Step 4: Setup Telegram Bot
First, you’ll need to create a bot on Telegram itself.
Open Telegram and search for @BotFather (official bot that manages other bots). Start a chat with BotFather and use the command /newbot to create a new bot. Follow the instructions to give your bot a name and a unique username (it must end in "bot"). Once done, BotFather will provide you with a Bot Token. This is very important, as you’ll use it to connect your code to Telegram.
You need to install a couple of libraries to manage HTTP requests and JSON data:
Universal Telegram Bot library: Go to Sketch > Include Library > Manage Libraries. Search for Universal Telegram Bot and install it.
ArduinoJson library: Search for ArduinoJson in the Library Manager and install it.
Step 5: Conclusion
This setup is specific to my Airtel Xstream Fiber home router. If you'd like to create a similar solution for your own router, you'll need to invest some time in figuring out how to access and retrieve connected device information from your router’s interface, just like I did with mine.