Software Setup
Install Dependencies
sudo apt update
sudo apt install rtl-sdr git
sudo pip install pyrtlsdr
sudo pip install rpi_ws281x adafruit-circuitpython-neopixel
sudo pip install numpy scipy
Battery Monitoring Script
import time
import board
import neopixel
from rtlsdr import RtlSdr
import numpy as np
# LED Configuration
LED_COUNT = 60
LED_PIN = board.D18
LED_BRIGHTNESS = 0.3
pixels = neopixel.NeoPixel(LED_PIN, LED_COUNT,
brightness=LED_BRIGHTNESS,
auto_write=False)
# SDR Configuration
sdr = RtlSdr()
sdr.sample_rate = 2.048e6 # 2.048 MHz
sdr.center_freq = 915e6 # 915 MHz (US)
sdr.gain = 40 # Adjust as needed
# Battery monitoring function
def get_battery_level():
# This would need to be implemented based on your specific
# battery monitoring hardware (ADC, voltage divider, etc.)
# For now, return a simulated value
return 0.7 # 70% charged
def process_samples(samples):
# FFT to find signal strength
fft = np.fft.fft(samples)
power = np.abs(fft)**2
return np.mean(power)
def update_leds(signal_strength, battery_level):
# Map signal strength to LED colors
intensity = min(1.0, signal_strength / 1000)
# Add battery indicator to first 5 LEDs
battery_leds = int(battery_level * 5)
for i in range(LED_COUNT):
if i < battery_leds:
# Green for battery level
pixels[i] = (0, 255, 0)
else:
# Create pulsing effect for signal strength
pulse = (np.sin(time.time() * 2 + i * 0.1) + 1) / 2
r = int(255 * intensity * pulse)
g = int(100 * intensity * (1-pulse))
b = int(50 * intensity)
pixels[i] = (r, g, b)
pixels.show()
try:
while True:
samples = sdr.read_samples(256*1024)
strength = process_samples(samples)
battery = get_battery_level()
update_leds(strength, battery)
finally:
sdr.close()
Important Considerations
⚠️ Battery Safety: Li-ion batteries can be dangerous if mishandled. Always use a protection circuit and never leave charging unattended.
⚠️ Power Efficiency: Monitor battery life carefully. The Pi Zero 2 W and LED strip can drain the battery quickly.
💡 Battery Life: With a 9900mAh battery, expect approximately 4-6 hours of runtime depending on LED usage.
- Boost Converter: Use a high-efficiency (90%+) boost converter to maximize battery life
- Power Management: Consider implementing sleep modes or reducing LED brightness to extend battery life
- Battery Monitoring: Add a voltage divider and ADC to monitor battery level in software
- Charging: The TP4056 module provides safe charging with overcharge protection
- Heat Management: The boost converter and Pi may generate heat; ensure adequate ventilation
- Frequency: Smart meters use different frequencies by region (915MHz US, 868MHz EU)
- Antenna: Use a properly tuned 900MHz antenna for best reception
- Legal: Check local regulations for radio reception