Raspberry Pi.. An Electrician's Tool?
- CyberSpeak Labs

- Jun 1, 2025
- 8 min read
Author: Peter Guadiomonte

You can find more details on the original project, here.
PROJECT OVERVIEW
n this project, I turned a Raspberry Pi 4B+ into a Wi-Fi access point that lets me stream live video to any device; no internet, router, or external infrastructure required.
Instead of remoting into the Pi and starting the script, I added a physical trigger, using the GPIO pins and an old doorbell button to start the web app. Whether you’re under a crawlspace or out in the field, this is the perfect offline monitoring tool.
WHAT YOU'LL NEED
Raspberry Pi 4 running Raspberry Pi OS (Bookworm or similar)
USB webcam or Pi Camera Module
Python3 + Flask for streaming (stream.py)
hostapd + dnsmasq for wireless AP and DHCP
Breadboard switch, jumper wires, or just touch two GPIO wires together
A phone or laptop to view the stream
Instead of buying brand new, there are so many useful parts on old PCBs destined for the trash. Buttons, switches, antennas. GoodWill (second-hand store) always has old routers, or electronics for cheap. Desolder.
STEP-BY-STEP SETUP
Instead of connecting the Pi to a hotspot or a local network, I used HOSTAPD to use the Pi’s wireless interface as an access point. I also installed and configured a DHCP server on the Pi so my cellphone or whatever device can be used to view the stream. Using an obscure subnet of 10.0.0.96/28, I made sure that collisions with common networks are highly unlikely. If plugged into another network, there is a very low probability its static or DHCP server can cause any issues.
Sorry guys, I’ve been studying for the CCNA and I have eating, breathing and sleeping subnetting.. it’s really not as bad when you get a hang of it.
Subnet Information
10.0.0.96/28 255.255.255.240
11111111.11111111.11111111.11110000
256-240 = 16 address block size
10.0.0.96 - Network Id
10.0.0.111 - Broadcast Address
10.0.0.97 - 10.0.0.110 = 14 Usable AddressesBefore starting any project I like to update my device. Then I installed flask, opencv, hostapd, and dnsmasq.
pi@streamer:~ $ sudo apt update
pi@streamer:~ $ sudo apt install python3-flask python3-opencv hostapd nsmasq -ypython3-flask
What it is: Flask is a lightweight, micro web framework for Python, designed for building web applications quickly and with minimal overhead. It uses Python 3 (python3-flask is the Debian/Ubuntu package for Flask).
python3-opencv
What it is: OpenCV (Open Source Computer Vision Library) is a powerful open-source library for computer vision, image processing, and machine learning, with Python 3 bindings (python3-opencv is the Debian/Ubuntu package).
hostapd
What it is: hostapd (Host Access Point Daemon) is a user-space daemon for creating and managing Wi-Fi access points (APs) on Linux systems.
dnsmasq
What it is: dnsmasq is a lightweight, easy-to-configure DNS forwarder, DHCP server, and router advertisement tool.
There are so many other uses for these tools, especially inside a home lab, IoT, micro-network for malware analysis or a DIY security system. I am using it as a tool to help me with my duties as an electrician. Boring, I know! well.. not for me but future posts will be much more entertaining.. I will give additional project ideas at the end.
Let’s do this!
STEP 2: ASSIGN WLAN0 TO A STATIC IP
pi@streamer:~ $ sudo systemctl stop hostapd
pi@streamer:~ $ sudo systemctl stop dnsmasq
pi@streamer:~ $ sudo vim /etc/dhcpcd.conf
###Navigate to the end of dhcpcd.conf and add these lines. ###interface wlan0 #This will be our static IP for the AP
static ip_address=10.0.0.97/28
nohook wpa_supplicant
interface eth0 #This is for future access.
static ip_address=10.0.0.98/28I added the Pi’s eth0 interface so later on I can add a switch into the mix and this will turn the Pi and any other devices into a small, isolated wired network.
STEP 3: CONFIGURE DHCP WITH DSNMASQ
Now it’s time to set up the DHCP server, so my phone or my laptop or any device with Wi-Fi and a browser can view the stream.
pi@streamer:~ $sudo vim /etc/dnsmasq.confFive ip addresses in this small subnet is enough for now.
#wlano(wirelessclients)(5addrs)
interface=wlan0
dhcp-range=10.0.0.99,10.0.0.104,255.255.255.240,24h
#dhcp-option=6,10.0.0.101
#eth0(wiredclients)(5addrs)
interface=eth0
dhcp-range=10.0.0.105,10.0.0.110,255.255.255.240,24h
#dhcp-option=6,10.0.0.101
#Disregard dhcp-options=6,.. this is used to denote what DNS server each interface
#will use. This is for a future project using a Pi-hole to inspect suspicious
#dns requests.
~
~
~Now, any device that connects to the Pi’s Wi-Fi will automatically get an IP address from the DHCP server.
STEP 4: CONFIGURE HOSTAPD TO BROADCAST THE WI-FI
Create
/etc/hostapd/hostapd.confpi@streamer:~ $ sudo vim /etc/hostapd/hostapd.confinterface=wlan0 #which network interface will broadcast the Wi-Fi signal
driver=nl80211 #Tells hostapd which driver to use for the wireless interface
ssid=PiStreamAP #Sets the name of the Wi-Fi network (SSID)
hw_mode=g #Sets the Wi-Fi mode. #g = 2.4 GHz (802.11g)
channel=7 #Specifies the Wi-Fi channel to broadcast on
auth_algs=1 #Sets allowed authentication algorithm (open)(not secure)
wmm_enabled=0 #Wi-Fi Multimedia. It's a QoS (Quality of Service) feature for prioritizing traffic (like video or voice).I am sure you can figure out how to update the configuration for secure authentication like WPA2.
Unmask(if needed), enable and start the service:
pi@streamer:~ $ sudo systemctl unmask hostapd
pi@streamer:~ $ sudo systemctl enable hostapd
pi@streamer:~ $ sudo systemctl start hostapdAfter any configuration changes, restart hostapd and dnsmasq:
pi@streamer:~ $ sudo systemctl restart hostapdpi@streamer:~ $ sudo systemctl restart dnsmasq###This can be applied to most configuration changes, restarting the service###pushes the changes into effect. 
We are now broadcasting PiStreamAP — its open and there is no route to the internet, it is all local. I want to get it to a point where I can update the time from my cellphone since it cannot reach any NTP servers. Be prepare to see time keeping is not synced. That will be for another day.
**If you look at the screenshot of the feed via the browser, you will notice the time in the application is correct since it is getting it from the JavaScript running on the browser of my phone, not the Pi..
Now, it is time to set up the web app that will be hosted on the Pi. All of this will be done with Python. I am still a novice python user, so I had a bit of help from AI. Here is the python script to bring up a webserver and serve the video captured from the connected webcam.
pi@streamer:~ $ sudo vim /home/pi/Desktop/stream.pyfrom flask import Flask, Response
import cv2
import threading
import time
app = Flask(__name__)
camera = None
output_frame = None
lock = threading.Lock()
def get_camera():
return cv2.VideoCapture(0) # 0 is typically the default camera
def generate_frames():
global output_frame, camera
if camera is None:
camera = get_camera()
time.sleep(2.0)
while True:
with lock:
if output_frame is None:
continue
(flag, encoded_image) = cv2.imencode(".jpg", output_frame)
if not flag:
continue
yield(b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' +
bytearray(encoded_image) + b'\r\n')
def camera_stream():
global output_frame, camera
if camera is None:
camera = get_camera()
time.sleep(2.0)
while True:
success, frame = camera.read()
if not success:
print("Failed to grab frame")
time.sleep(1)
camera = get_camera()
continue
with lock:
output_frame = frame.copy()
time.sleep(0.01)
@app.route('/')
def index():
return """
<html>
<head>
<title>Peter's Raspberry Pi Camera Stream</title>
<style>
body { font-family: Arial; text-align: center; margin-top: 50px; background-color:black; color: white; }
img { max-width: 100%; border: 2px solid white; }
</style>
</head>
<body>
<h1>Peter's Raspberry Pi Camera Stream</h1>
<img src="/video_feed">
<h2>Prototype 2.0 HTTP</h2>
<h2>Electrician's buddy</h2>
<script>const options = { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: '2-digit', hour12: true }; document.write(new Date().toLocaleString('en-US', options).replace(',', ' -'));</script>
</body>
</html>
"""
@app.route('/video_feed')
def video_feed():
return Response(generate_frames(),
mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
t = threading.Thread(target=camera_stream)
t.daemon = True
t.start()
app.run(host='0.0.0.0', port=8000, debug=False, threaded=True)There are probably 10 different way to set up a web server and serve up the video stream but for this project, I had already used Flask in the original project.
I choose Flask because it’s lightweight and flexible, making it perfect for quickly building a simple video streaming app without unnecessary overhead. Its simplicity and easy integration with Python libraries make it ideal for this kind of small, self-contained project.
LIVE VIDEO STREAM WITH FLASK
Now lets test stream.pyThe way it is configured it should serve the camera stream via port 8000.
To run this manually, run the following:
pi@streamer:~ $ python3 /home/pi/Desktop/stream.pyI can now visit http://10.0.0.97:8000 on my phone or any device with a browser that is connected to the open Wi-fi SSID: PiStreamAP

My last iteration of this project, linked at top of the page, I was required to SSH into the Pi to run the script directly. I managed to get familiar with the GPIO pins and connect an extra doorbell I had lying around. When the button is pushed, it runs the script that starts the web app.
Also, the program runs in the background so if need be I can access the shell and run other commands. Previous copy the server ran in the foreground and I had to CNTRL + C to stop it.
I had to create a listener script which basically listens for the button push. The script runs at boot and when GPIO pin 17 and pin 6 (GRND) make contact (button is pressed or I can just touch the two wires together), /home/pi/Desktop/stream.py is ran.
pi@streamer:~ $ sudo vim /home/pi/Desktop/button_trigger.py
#creating a listener script nowfrom gpiozero import Button
import subprocess
button = Button(17)
def start_stream():
subprocess.Popen(["python3", "/home/pi/Desktop/stream.py"])
button.when_pressed = start_stream
pause() I just threw this on the Desktop with the stream.py and created a crontab to run the listening script at boot.
pi@streamer:~ $ crontab -eAdd the follow code to the bottom of the file
@reboot python3 /home/pi/Desktop/button_trigger.py &Regarding crontab, this just means every time we reboot, run this command. Specifically, in the the background.
BONUS: ETHERNET EXPANSION
We can also connect the Pi’s eth0 interface to a switch and give it its own DHCP range using a second dnsmasq instance (/etc/dhcpcd.conf). With this set up, you can have a small segregated network to sniff traffic or play around with DNS. Sky’s the limit. I created a small network to sniff some traffic from an Android Tv box known to contain some malicious applications. That’s a whole ‘nother article, though!
Project Ideas Using HOSTAPD, DHCP, DNS, and Flask on Raspberry Pi
Once you’ve set up your Raspberry Pi with hostapd, DHCP, DNS, or Flask capabilities, you can explore dozens of creative and practical applications. Here are just a few ideas:
Local Doorbell Cam - Trigger a video stream when the doorbell is pressed and view it from any connected device.
Offline Baby Monitor - Use a webcam and Flask to stream video/audio over a private Wi-Fi AP.
Portable Dashcam - Record and stream footage to connected devices while driving or parking.
Smart Home Controller - Run a private dashboard to manage relays, lights, or sensors.
File Drop or Photo Booth - Let others connect and upload/download files in an offline environment.
Offline Media Server - Host movies or music and stream them to phones via local Wi-Fi.
Capture-the-Flag Lab - Create a mini pentesting environment with rogue APs or DNS spoofing.
Presence Detection System -Log devices as they connect and trigger actions (e.g., lights or alarms).
Coding Classroom Hotspot - Let students code and test websites without needing internet.
These projects combine Flask, hostapd, dnsmasq, GPIO, and networking fundamentals to unlock a wide range of DIY solutions, from fun experiments to real-world tools.
FINAL THOUGHTS
This upgraded Raspberry Pi project gives you a private, offline, button-activated camera stream, powered by open-source tools and GPIO pins. I guess you can say I made a doorbell cam..
No router
No cloud
No subscription
No nonsense
Just power it on, press the button, and start streaming to your phone over an access point you created.




Comments