Using a Raspberry Pi, you can track your phone, tablet, laptop, and other wireless devices.
Using a Raspberry Pi, keep track of your phone, tablet, laptop, and other wireless devices! The more Raspberry Pis you have, the better you'll be able to monitor your house for gadget movement. Send the data from all the Pi's to an IoT platform to record and visualize your home as well as the positions of all your wireless gadgets!
Make sure you're at the source of the problem.
$ sudo su
Make a directory switch.
$ cd /usr/local/src
Download the most recent Re4son kernel version.
$ wget -O re4son-kernel_current.tar.xz https://re4son-kernel.com/download/re4son-kernel-current/
To extract the file, use the tar command.
$ tar -xJf re4son-kernel_current.tar.xz
Rename the folders
$ cd re4son-kernel_4*
Install the firmware.
$ ./install.sh
Step 2: Examine Monitor Mode:- Make sure you're in root once more.
$ sudo iw phy phy0 interface add mon0 type monitor
Create an interface for monitor mode.
$ iw dev
Make sure the interface exists.
$ ifconfig mon0 up
Step 3: Install the most recent scapy version:
- Clone the scapy repository into a new folder.
$ git clone https://github.com/secdev/scapy.git
Rename the directory
$ cd scapy
Setup the setup.py script.
$ sudo python3 setup.py install
After you've performed these three steps, you should be able to run the code without issue!
First, we must import all of the required libraries.
from scapy.all import *
import json
import threading
import http.client
After that, you'll need to enter your uBeac Gateway URL, which we'll go over later. Set the interval for how often you want your device to deliver data and give it a nice name.
UBEAC_URL = 'hub.ubeac.io'
GATEWAY_URL = 'http://INSERT GATEWAY URL HERE'
DEVICE_FRIENDLY_NAME = 'RPi detector 4'
SENT_INTERVAL = 10 # Sent data interval in second
You'll need to know the MAC address of your own devices in order to track them. In the devices dictionary, type them in.
devices = {"00:00:00:00:00:00" : "DEVICE 1",
"00:00:00:00:00:00" : "DEVICE 2",
"00:00:00:00:00:00" : "DEVICE 3"}
Data is written to the uBeac sensor format using the get sensor function.
def get_sensor(id, value, type=None, unit=None, prefix=None, dt=None):
sensor = {
'id': id,
'data': value
}
return sensor
The PacketHandler function keeps track of the Wi-Fi packets that your wireless devices send out.
def PacketHandler(pkt):
if pkt.haslayer(Dot11):
dot11_layer = pkt.getlayer(Dot11)
if dot11_layer.addr2 and (dot11_layer.addr2 in devices) and (dot11_layer.addr2 not in check_devices):
check_devices.add(dot11_layer.addr2)
sensors_dbm.append(get_sensor(devices[dot11_layer.addr2], {"dBm Signal" : pkt[RadioTap].dBm_AntSignal}))
The main method delivers the data from the PacketHandler to uBeac's IoT service. It will reset every 10 seconds by default, but you may modify this.
def main():
threading.Timer(SENT_INTERVAL, main).start()
sniff(iface = "mon0", prn = PacketHandler, timeout = SENT_INTERVAL)
device = [{
'id': DEVICE_FRIENDLY_NAME,
'sensors': sensors_dbm
}]
connection = http.client.HTTPSConnection(UBEAC_URL)
connection.request('POST', GATEWAY_URL, json.dumps(device))
response = connection.getresponse()
print(response.read().decode())
sensors_dbm.clear()
check_devices.clear()
Configure uBeacSimply follow this lesson on OS monitoring for an introduction to uBeac. You'll learn how to acquire your uBeac Gateway URL, check sure your devices are providing data, and create a dashboard in this lesson!
To receive the floor plan with the devices laid out on it, go to the Buildings module and build a Building by typing in an address, selecting it on a map, and giving it a name. After that, you must construct a floor for your structure. To access the Floor modules and build a new floor, select the Floor tab. Insert a floor plan, whether it's your own or one you found on the internet.
Go to the Devices module, choose your individual device, and select settings to add it to the floor layout. Select your building and floor from the buildings tab. Drag your device to the appropriate location on the floor layout. Once you've made changes to your device's icon picture, size, and colour, click submit.
You should see all of your new devices and their data if you go to the Dashboard module, create a dashboard, and enter the floor widget! An example of such a dashboard is shown below.
Note that signal strength, which is a negative value, is used to calculate the distance between the RaspberryPi and the wireless device. As a result, the closer an item is, the narrower the bar on the bar graph.
Create a free uBeac accounthere.
Codefrom scapy.all import *
import json
import threading
import http.client
# Configuration section
UBEAC_URL = 'hub.ubeac.io'
GATEWAY_URL = 'http://INSERT GATEWAY URL HERE'
DEVICE_FRIENDLY_NAME = 'RPi detector #'
SENT_INTERVAL = 10 # Sent data interval in second
sensors_dbm = []
check_devices = set()
devices = {"00:00:00:00:00:00" : "DEVICE",
"00:00:00:00:00:00" : "DEVICE",
"00:00:00:00:00:00" : "DEVICE"}
def get_sensor(id, value, type=None, unit=None, prefix=None, dt=None):
sensor = {
'id': id,
'data': value
}
return sensor
def PacketHandler(pkt):
if pkt.haslayer(Dot11):
dot11_layer = pkt.getlayer(Dot11)
if dot11_layer.addr2 and (dot11_layer.addr2 in devices) and (dot11_layer.addr2 not in check_devices):
check_devices.add(dot11_layer.addr2)
sensors_dbm.append(get_sensor(devices[dot11_layer.addr2], {"dBm Signal" : pkt[RadioTap].dBm_AntSignal}))
def main():
threading.Timer(SENT_INTERVAL, main).start()
sniff(iface = "mon0", prn = PacketHandler, timeout = SENT_INTERVAL)
device = [{
'id': DEVICE_FRIENDLY_NAME,
'sensors': sensors_dbm
}]
connection = http.client.HTTPSConnection(UBEAC_URL)
connection.request('POST', GATEWAY_URL, json.dumps(device))
response = connection.getresponse()
print(response.read().decode())
sensors_dbm.clear()
check_devices.clear()
main()
from scapy.all import *
import json
import threading
import http.client
# Configuration section
UBEAC_URL = 'hub.ubeac.io'
GATEWAY_URL = 'http://INSERT GATEWAY URL HERE'
DEVICE_FRIENDLY_NAME = 'RPi detector #'
SENT_INTERVAL = 10 # Sent data interval in second
sensors_dbm = []
check_devices = set()
devices = {"00:00:00:00:00:00" : "DEVICE",
"00:00:00:00:00:00" : "DEVICE",
"00:00:00:00:00:00" : "DEVICE"}
def get_sensor(id, value, type=None, unit=None, prefix=None, dt=None):
sensor = {
'id': id,
'data': value
}
return sensor
def PacketHandler(pkt):
if pkt.haslayer(Dot11):
dot11_layer = pkt.getlayer(Dot11)
if dot11_layer.addr2 and (dot11_layer.addr2 in devices) and (dot11_layer.addr2 not in check_devices):
check_devices.add(dot11_layer.addr2)
sensors_dbm.append(get_sensor(devices[dot11_layer.addr2], {"dBm Signal" : pkt[RadioTap].dBm_AntSignal}))
def main():
threading.Timer(SENT_INTERVAL, main).start()
sniff(iface = "mon0", prn = PacketHandler, timeout = SENT_INTERVAL)
device = [{
'id': DEVICE_FRIENDLY_NAME,
'sensors': sensors_dbm
}]
connection = http.client.HTTPSConnection(UBEAC_URL)
connection.request('POST', GATEWAY_URL, json.dumps(device))
response = connection.getresponse()
print(response.read().decode())
sensors_dbm.clear()
check_devices.clear()
main()
from scapy.all import *
import json
import threading
import http.client
# Configuration section
UBEAC_URL = 'hub.ubeac.io'
GATEWAY_URL = 'http://INSERT GATEWAY URL HERE'
DEVICE_FRIENDLY_NAME = 'RPi detector #'
SENT_INTERVAL = 10 # Sent data interval in second
sensors_dbm = []
check_devices = set()
devices = {"00:00:00:00:00:00" : "DEVICE",
"00:00:00:00:00:00" : "DEVICE",
"00:00:00:00:00:00" : "DEVICE"}
def get_sensor(id, value, type=None, unit=None, prefix=None, dt=None):
sensor = {
'id': id,
'data': value
}
return sensor
def PacketHandler(pkt):
if pkt.haslayer(Dot11):
dot11_layer = pkt.getlayer(Dot11)
if dot11_layer.addr2 and (dot11_layer.addr2 in devices) and (dot11_layer.addr2 not in check_devices):
check_devices.add(dot11_layer.addr2)
sensors_dbm.append(get_sensor(devices[dot11_layer.addr2], {"dBm Signal" : pkt[RadioTap].dBm_AntSignal}))
def main():
threading.Timer(SENT_INTERVAL, main).start()
sniff(iface = "mon0", prn = PacketHandler, timeout = SENT_INTERVAL)
device = [{
'id': DEVICE_FRIENDLY_NAME,
'sensors': sensors_dbm
}]
connection = http.client.HTTPSConnection(UBEAC_URL)
connection.request('POST', GATEWAY_URL, json.dumps(device))
response = connection.getresponse()
print(response.read().decode())
sensors_dbm.clear()
check_devices.clear()
main()
Read Next:- Make your own Raspberry Pi Image from scratch
- How to Send phone notifications Using Raspberry Pi Pico?
- Raspberry Pi Pico 4G/2G Expansion : Expectations vs. Reality
- Quick Example to Drive Servo Using Programmable I/O
- How to Use a USB SSD or Flash Drive to Boot a Raspberry Pi 4 / Pi 400
- Filter Ads by your Raspberry Pi Before they Reach your Devices
- A Raspberry Pi 4 Model A Launch 2022 - Eben Upton
- First-Ever 2G Expansion Board for Raspberry Pi Pico has Launched on Kickstarter
- Learn IoT "Internet of Things" with 24 lessons for Teachers and Students
- Quick Guide for Raspberry Pi Users: Raspberry Pi Terminal Commands
- Windows 11 on Raspberry Pi Devices in Easy Installation Guide
- Get Your Project Done by Raspberry Pi Approved Design Partners
- PiRelay 8 Smart Relay Board for Raspberry Pi - Kickstarter
- Tiny Round/Circular LCD Display Launched!
- Issue Fixed! USB Boot Ubuntu Server 20.04 on Raspberry Pi 4
- HC-SR04 Sensor with micro-ROS on the Raspberry Pi Pico
- Raspberry Pi Pico: ADC Sampling and FFT
- Using CircuitPython for RP2040
- How to Setup Pico RP2040 on Windows
- Using micro-ROS on the Raspberry Pi Pico
- LED Tricks Using The Raspberry Pi Pico
- The RP2040 Raspberry Pi Pico Meets LoRa
- Pico supports SD cards and FatFS
- How to connect a Raspberry Pi Pico to LoRaWAN
- 50 Raspberry Pi Hacks & Tips You Should Know
- How to Install Wi-Fi and Internet on a Raspberry Pi Pico
Comments