ESP8266 Indoor location trilateration
I wanted to get into electronics and IoT devices. I was pointed to the ESP8266 chipset.
I’m really interested in indoor location services, which 5G is bringing about. I had an idea of creating an indoor location service for my house which could see where my phone was and could pipe that informational data into an amazon alexa or similar skill for location specific automatic execution of switching on lights etc.
IoT
I purchased a set of ESP8266 ESP-01S modules from amazon
So how to go about this? I would be using the ESP-01 to use promiscuous wifi scanning to pick up the surrounding wifi enabled devices. I would need multiple nodes to pick up the signal strength from the devices and calculate, through trilateration, the estimated location of the devices.
Why trilateration? The 802.11 protocol has an RSSI field which indicates signal strength. A node sampling a target device’s 802.11 packets can use the RSSI data as a rough indicator of how far away the target device is. By using multiple nodes to sample the targets signal strength to them , an estimate can be given based on the overlap of these different ranges on a 2d plane.
Circuits
These small ESP-01S modules don’t have much to them, to flash them I needed to create a flashing circuit. I prototyped it first then used a perf board to make something a bit longer lasting.
Implementation
Plan for collecting RSSI data:
- Listen and collect client RSSI information for random range between 15-60 seconds per node.
- Connect to MQTT network and publish client data, hopefully in this time the other nodes will sense this node so they can find each others location.
- Go back into monitor mode and continue collecting data.
My main source of reference for doing this is Ray Burnette’s Mini Sniff sketch. I tweaked it to pick up all wifi packet types rather than just data and QoS.
I used the Ardunio Client for MQTT for connecting to a Mosquitto service running on a raspberry pi
I want to be able to process and visualise the data to see if it is estimating locations correctly. To do this im using MQTT.js to create a browser based MQTT client and will be using P5.js to visualise the data.
I integrated the sniffing sketch with the publishing of data to MQTT and listened for the data on the browser client.
Sources:
https://www.hackster.io/rayburne/esp8266-mini-sniff-f6b93a https://www.hackster.io/kosme/esp8266-sniffer-9e4770 https://www.carvesystems.com/news/writing-a-simple-esp8266-based-sniffer/
https://www.instructables.com/id/MQTT-Bare-Minimum-Sketch/
https://learn.adafruit.com/diy-esp8266-home-security-with-lua-and-mqtt/configuring-mqtt-on-the-raspberry-pi