Application for scanning radio bands (FM, AM, AIR, CB and more) using RTL-SDR v4 on Raspberry Pi. Ghost Box Pi enables automatic switching between radio stations with adjustable speed, volume and advanced noise control.
- Raspberry Pi 5 (recommended) or Raspberry Pi 4
- RTL-SDR v4 (USB dongle) - ORIGINAL ONLY!
⚠️ - Official power supply Raspberry Pi 5 (5V/5A USB-C)
- Speaker/headphones (HDMI, 3.5mm Jack or Bluetooth)
- USB 3.0 port (blue) - recommended for RTL-SDR
VERY IMPORTANT: There are many fake RTL-SDR devices on the market that may not work!
Official stores:
- 🔗 List of authorized sellers: https://www.rtl-sdr.com/buy-rtl-sdr-dvb-t-dongles/
How to recognize original RTL-SDR Blog v4:
- ✅ Metal case (blue or silver)
- ✅ "RTL-SDR Blog" logo on the case
- ✅ SMA connector (screw-on antenna)
- ✅ Price around $35-45 USD
Signs of a fake:
- ❌ No "RTL-SDR Blog" logo
- ❌ Plastic case
- ❌ Price below $25 USD
- ❌ Seller not listed on official website
- Operating System: Raspberry Pi OS (64-bit) - latest version
- Python: 3.7 or newer
- System libraries:
- RTL-SDR v4 drivers
- PortAudio
- USB libraries
Open terminal and execute the following commands:
sudo apt update
sudo apt upgrade -yRTL-SDR v4 requires special drivers compiled from source.
Remove old drivers:
sudo apt purge -y ^librtlsdr* ^rtl-sdr*Remove remnants manually (copy the entire line exactly!):
sudo rm -rvf /usr/lib/librtlsdr* /usr/include/rtl-sdr* /usr/local/lib/librtlsdr* /usr/local/include/rtl-sdr* /usr/local/include/rtl_* /usr/local/bin/rtl_*Install build tools:
sudo apt-get install libusb-1.0-0-dev git cmake pkg-config build-essentialGet the source code:
git clone https://github.com/rtlsdrblog/rtl-sdr-blog
cd rtl-sdr-blog/Build and compile:
mkdir build
cd build
cmake ../ -DINSTALL_UDEV_RULES=ON
makeInstall the drivers:
sudo make install
sudo cp ../rtl-sdr.rules /etc/udev/rules.d/
sudo ldconfigBlock default DVB driver:
echo 'blacklist dvb_usb_rtl28xxu' | sudo tee /etc/modprobe.d/blacklist-rtl-sdr.confSystem restart:
sudo rebootAfter restart, connect RTL-SDR v4 to USB port and run test:
rtl_test -tExpected result: You should see device information (e.g. "RTL-SDR Blog V4") and successfully completed test.
sudo apt install -y python3-pipsudo apt install -y libportaudio2 portaudio19-devChoose library set depending on which version you want to run.
pip install pyrtlsdr sounddevice numpy scipy --break-system-packagesThis command installs everything you need: customtkinter for UI and soundfile for recording.
pip install pyrtlsdr sounddevice numpy scipy customtkinter soundfile --break-system-packagesInstalled libraries:
pyrtlsdr- RTL-SDR communicationsounddevice- audio playbacknumpy- numerical operationsscipy- signal processingcustomtkinter- (V4 ONLY) modern graphical interfacesoundfile- (V4 ONLY) saving .wav audio files
# Return to home directory
cd ~
# Clone repository
git clone https://github.com/gazda12345kamil-dotcom/ghost-box-pi.git
cd ghost-box-piOr download code manually and save as ghostbox_fm.py (basic), ghostbox_fm_V2.py (advanced) or ghostbox_pi_PRO_v4.py (PRO) on desktop.
python3 ghostbox_fm.pypython3 ghostbox_fm_V2.pypython3 ghostbox_pi_PRO_v4.pySolution:
- Check USB connection - use USB 3.0 port (blue)
- Verify in system:
lsusb- look for ID0bda:2838 - Check power - use official 5V/5A power supply
- Check if you have original: https://www.rtl-sdr.com/buy-rtl-sdr-dvb-t-dongles/
- Disconnect and reconnect dongle
- Check blacklist:
cat /etc/modprobe.d/blacklist-rtl-sdr.conf
Solution:
-
Select audio output:
- Right-click speaker icon in taskbar
- Select appropriate device (HDMI, Headphones, Bluetooth)
-
Check system volume:
- Left-click speaker icon
- Make sure volume is not muted
-
Test sounddevice:
python3 >>> import sounddevice as sd >>> import numpy as np >>> fs = 48000 >>> t = np.arange(fs * 3) >>> audio = 0.5 * np.sin(2 * np.pi * 440 * t / fs) >>> sd.play(audio.astype(np.float32), fs) >>> sd.wait() >>> exit()
Solution:
- Make sure all system dependencies are installed (Step 2 and 5)
- Check internet connection
- Update pip:
pip install --upgrade pip --break-system-packages
- Retry library installation (Step 6)
Solution:
- Close all SDR programs (SDR++, GQRX, CubicSDR)
- Disconnect and reconnect dongle
- As last resort:
sudo reboot
Solution:
- Check Squelch slider - if set too high, may mute all signals
- Set Squelch to 0 (fully left) to disable function
- Gradually increase value until noise between stations stops
Solution:
You haven't installed the interface library. Execute command:
pip install customtkinter --break-system-packagesSolution:
You haven't installed the audio recording library. Execute command:
pip install soundfile --break-system-packages- ✅ Full FM band scanning (87.5-108 MHz)
- ✅ Adjustable scanning speed (50-500 ms)
- ✅ Real-time volume control
- ✅ FM demodulation with automatic audio normalization
- ✅ Graphical interface (Tkinter)
- ✅ Event logging system
- ✅ Squelch - noise suppression on FM
- ✅ Mix Mode (Random) - random FM scanning
- ✅ Better sound quality control
- ✅ Modern Interface (CustomTkinter)
- ✅ Multi-Band Scanning (WBFM, AM, NBFM)
- ✅ Full Band Mixing (checkbox selection)
- ✅ Advanced DSP Filtering for each mode
- ✅ Precise Squelch based on signal power
- ✅ Audio session recording (REC) - save to .wav files
- ✅ Signal strength indicator (S-Meter) - signal power visualization
- ✅ Settings save and load - automatic configuration memory
Parameters can be adjusted directly in .py files.
# FM frequency range
FM_START_FREQ = 87.5e6
FM_END_FREQ = 108.0e6
FM_STEP = 0.1e6 # Scanning step
# SDR parameters
SDR_SAMPLE_RATE = 1.024e6
SDR_GAIN = 'auto'
AUDIO_SAMPLE_RATE = 48000# Band Definitions (WBFM, AM, NBFM)
BANDS_CONFIG = {
"FM": {'name': "FM", 'start': 87.5e6, 'end': 108.0e6, 'step': 0.1e6, 'mode': "WBFM"},
"AIR": {'name': "AIR", 'start': 108.1e6, 'end': 137.0e6, 'step': 0.025e6, 'mode': "AM"},
"CB": {'name': "CB", 'start': 26.965e6,'end': 27.405e6,'step': 0.01e6, 'mode': "AM"},
"AM": {'name': "AM", 'start': 531e3, 'end': 1701e3, 'step': 9e3, 'mode': "AM"},
"WX": {'name': "WX", 'start': 162.400e6,'end': 162.550e6,'step': 0.025e6,'mode': "NBFM"},
"2M-HAM": {'name': "2M-HAM",'start': 144.0e6, 'end': 146.0e6, 'step': 0.025e6,'mode': "NBFM"}
}
# SDR parameters
SDR_SAMPLE_RATE = 1.024e6
SDR_GAIN = 'auto'
AUDIO_SAMPLE_RATE = 48000PRO Version (v4) automatically creates ghostbox_config.json file in the same folder. It stores:
- Last slider positions (volume, speed, squelch)
- Band checkbox states
- Random mode (Mix)
To reset settings to default values, simply delete the ghostbox_config.json file.
tkinter- (for v1, v2) graphical interface (built into Python)pyrtlsdr- RTL-SDR interfacesounddevice- audio playbacknumpy- numerical calculationsscipy- signal processingcustomtkinter- (for v4) modern graphical interfacesoundfile- (for v4) saving .wav audio files
librtlsdr- RTL-SDR v4 driverslibportaudio2- audio librarylibusb-1.0-0- USB communication
Open Source - This project is free software. Everyone can use it, modify and distribute without restrictions. Code is publicly available for educational and community purposes.
Bug reports, suggestions and pull requests are welcome! The project is open to everyone who wants to help with its development.
- Application is intended for educational and experimental purposes
- Follow local regulations regarding radio device usage
- Do not illegally listen to radio transmissions
- Author is not responsible for misuse of the application
For questions or problems, open an Issue on GitHub.
🔗 More information about RTL-SDR: https://www.rtl-sdr.com
Built with ❤️ for the Raspberry Pi and SDR community