Packet Sniffer
Introduction
This project delivers a network monitoring appliance that passively observes and visualizes Wi-Fi traffic in real time. By combining a Raspberry Pi configured as both a hotspot and uplink bridge to the LAN's router, with an ESP32-driven TFT display, the system can:
Serve as a portable Wi-Fi AP for client devices
Forward upstream traffic through an external USB Wi-Fi adapter to the main router
Gather uplink metrics (throughput, client list, CPU temperature, signal quality, memory) on the Pi
Stream these statistics over UDP to the ESP32
Render intuitive graphs and status screens on a 1.44″ ST7735S LCD
This standalone solution is ideal for home network troubleshooting.
General Description
The overall architecture comprises two collaborating units:
* Raspberry Pi Zero 2 W
Built-in Wi-Fi in AP mode (SSID “PiAP”) for local devices
USB Wi-Fi adapter in station mode to uplink traffic to the main router
Passive capture of 802.11 frames and system telemetry
Computes per-second uplink throughput, active client list (IP+MAC), CPU temperature, signal strength, free memory
Sends a compact JSON payload via UDP to the ESP32 every second
* ESP32 + TFT LCD
Joins the Pi’s hotspot as a station client
Listens on UDP port 4000 for incoming JSON metrics
Maintains a 128-sample circular buffer for RX/TX history
Dynamically autoscale graphs to current network load
Offers three UI modes toggled by a push-button:
Hardware Design
Eagle Schematic
BOM
Component | Qty | Cost(€) | Datasheet |
Raspberry Pi Zero 2 W | 1 | 15 | link |
ESP32 Dev Board | 1 | 7 | link |
1.44″ ST7735S TFT LCD | 1 | 8 | link |
RGB LED | 1 | 0.40 | link |
Push-button | 1 | 0.30 | N/A |
TL-WN722N Wi-Fi Adapter | 1 | 10 | link |
Software Design
GitHub Repository
Development Environments
Dependencies & Libraries
* ESP32 Side
Core networking: `WiFi.h`, `WiFiUdp.h`
JSON handling: ArduinoJson v6
Display driver: TFT_eSPI (ST7735S)
ESP IDF SOC register macros: `soc/gpio_reg.h`, `soc/ledc_struct.h`, etc.
* Raspberry Pi Side
Python stdlib: `socket`, `time`, `pathlib`, `signal`, `sys`, `subprocess`
System tools:
`iw dev <iface> station dump` → associated MAC addresses
`/proc/net/arp` → ARP cache for MAC→IP
Sysfs: network stats & temperature
Core Data Structures & Algorithms
* Circular buffer (size 128 i.e. max width of the LCD)
Stores the latest second-by-second RX/TX values
Overwrites oldest sample when full, mapping one pixel per sample
* Graph autoscaling
* Bare-metal PWM feedback
* Debounced button input
Software Workflow
1. Boot & Initialization
Configure serial debug UART
Initialize GPIO pins and PWM registers directly
Setup TFT display and show splash screen
Connect as Wi-Fi station to Pi’s AP (SSID=“PiAP”)
Open UDP listener on port 4000
2. Data Acquisition (Pi Script)
Each second:
Read `/sys/class/net/<uplink>/statistics/{rx,tx}_bytes` → compute bits/sec
List associated stations via `iw station dump`
Lookup each MAC in `/proc/net/arp` for its IP
Read CPU temp and free memory from sysfs
Query link RSSI via `iw dev <uplink> link`
Send JSON packet to ESP32
3. ESP32 Main Loop
Wait for UDP packet → parse JSON
Push new RX/TX into circular buffer
Update LED PWM based on current throughput
Renders selected view:
Graph: dynamic RX/TX curves + scale/peak labels
Clients: IP & MAC of each connected device
Info: CPU temperature, RSSI, available RAM
4. Mode Switching
Pics