Remoteless Control: Auto-Muting TV Ads With AI & Raspberry Pi
by meeraaj in Circuits > Raspberry Pi
48 Views, 0 Favorites, 0 Comments
Remoteless Control: Auto-Muting TV Ads With AI & Raspberry Pi
At the start of this IPL cricket season, the sheer volume of television commercials finally broke my patience. I was tired of frantically diving for the TV remote every single over just to hit mute.
I decided to engineer a system to do it for me.
Remoteless-Control is an AI-powered hardware and software pipeline that watches a live match via your laptop webcam, detects when a commercial break starts (by looking for the "Ad" badge), and wirelessly commands a Raspberry Pi to physically mute the TV using an Infrared (IR) LED.
It bridges three distinct domains:
- The Brains (Computer Vision): A custom YOLOv8 model scanning the live feed.
- The Bridge (Local Wi-Fi): A Python script firing HTTP requests.
- The Brawn (Hardware): A Raspberry Pi executing raw IR hex codes.
For code reference
Here's the github link :https://github.com/meeraaj/Remoteless-Control
Let's build it!
Downloads
Supplies
Hardware:
- 1x Laptop (with a webcam)
- 1x Raspberry Pi (Any model with Wi-Fi and GPIO pins)
- 1x IR Receiver Module (e.g., TSOP38238) - For learning your remote's codes
- 1x IR LED (940nm) - For transmitting the mute signal
- 1x Resistor (e.g., a base resistor like 220Ω or 1kΩ to protect the transistor, or a low-value resistor for the LED current limiting).
- 1x Breadboard
- Jumper Wires (Male-to-Male and Female-to-Male)
Software:
- Python 3
- YOLOv8 (Ultralytics)
- Flask (For the Raspberry Pi server)
- LIRC (Linux Infrared Remote Control)
Train the AI to Find the Ads
The first step is teaching the AI what a commercial looks like.
The Challenge : Initially, I trained a YOLOv8 model on perfect, high-resolution digital screenshots of the Hotstar "Ad" badge. However, when I pointed a webcam at my physical TV, the AI went completely blind due to screen glare, pixelation, and compression.
The Solution:
- Aim your webcam at the TV and capture a new dataset of images showing the ad badge directly from the physical screen.
- Annotate these images (drawing boxes around the badge).
- Train your YOLOv8 model on this messy, real-world dataset.
- Once trained, save your best.pt weights file. This will be the "brain" of our operation.
Capture Your TV Remote's Codes
Before the Raspberry Pi can mute the TV, it needs to learn the exact infrared "language" of your specific TV remote.
- Wire up the IR Receiver (TSOP38238):
- VCC to Raspberry Pi 3.3V
- GND to Raspberry Pi Ground
- DAT/OUT to Raspberry Pi GPIO 18
- Edit your Pi's boot config (/boot/firmware/config.txt) and add: dtoverlay=gpio-ir,gpio_pin=18
- Reboot the Pi and run these commands to test the receiver:
- Bash
- Point your TV remote at the receiver and press "Mute". You will see raw pulse/space data print on the screen.
- Map these hex codes (e.g., 0xE0E0F00F) to a /etc/lirc/lircd.conf.d/your_tv.conf file.
Build the Transmitter Circuit
With the remote codes safely captured, it's time to build the transmitter circuit. Instead of using complex multi-component amplifier configurations, we are wiring the IR LED directly to the Raspberry Pi's GPIO rail using a single resistor to keep our hardware footprint minimal and safe.
Wiring the Circuit:
- Connect the long leg (Anode) of your IR LED to Raspberry Pi GPIO 17.
- Connect the short leg (Cathode) of the LED to one end of your current-limiting resistor.
- Connect the other end of the resistor to a GND (Ground) pin on the Pi.
- Update your boot configuration (/boot/firmware/config.txt) to enable transmission on that specific pin by adding: dtoverlay=gpio-ir-tx,gpio_pin=17
The resistor ensures that the IR LED doesn't draw too much current from the Pi, safely protecting the microchip architecture while maintaining enough signal strength to mute the TV across the room.
Write the Network Bridge (Flask & Python)
Now we need the Laptop (AI) to talk to the Raspberry Pi (Hardware) over your local Wi-Fi.
On the Raspberry Pi: Write a simple Python Flask server (rpi_server.py). This script will constantly listen for an HTTP request. When it receives one, it triggers a terminal command to fire LIRC, blasting the "Mute" IR code we saved in Step 2. Run this script in an SSH session and leave it running.
On the Laptop: Write the main AI script (live_ad_blocker.py).
- Load your YOLOv8 best.pt model.
- Open a video capture stream from the webcam.
- If the model detects the "Ad" badge, use the requests library to ping the Raspberry Pi's local IP address (e.g., http://192.168.x.x:5000).