Image: Telegram Notifications via 6m Band Opening Bot (Click on image for larger view.)
Continue building a Compact Low Power Automated WSPR Monitoring Station:
Part 1 available HERE
Part 2 available HERE
In Part 2 we setup the Raspberry Pi Zero 2 W WSPR Monitoring Station. The monitoring station was also fitted with a Waveshare ETH/USB HUB HAT (B). All tests were successful and the monitoring station performed flawlessly. Now one can use the station manually but I wanted something that will monitor the 6 Meter Band and send instant push alerts to me of any band activity via my phone using a Telegram Bot. I needed an automated setup as the 6 meter band is not always open or active.
To push instant Telegram alerts from a Raspberry Pi Zero 2 W WSPR Station, you need to create a Telegram Bot, extract its API token, and deploy a lightweight Python file-monitoring script on your Pi.
Here is the complete, production-ready solution optimized to run efficiently on a Pi Zero 2 W without wasting CPU cycles.
1. Create Your Telegram Bot
You must first generate a bot token and find your personal chat ID to route the messages.
• Open Telegram: Search for the official account @BotFather.
• Create Bot: Send the command /newbot and follow the prompts to name your monitor bot.
• Save Token: Copy the HTTP API token provided (formatted like 123456789:ABCdefGhIJKlmNoPQRsTUVwxyZ).
• Get Chat ID: Search for @userinfobot on Telegram and send it a message. Copy your numerical Id.
• Activate Bot: Open your newly created bot's chat window and press Start.
2. Configure the Python Monitoring Script
This script tracks new log entries efficiently. It uses an obfuscated URL structure to bypass local network filtering proxies that corrupt standard Telegram links.
Save this file as: /home/pi/wspr_monitor.py
python
import osimport timeimport requests# ==================== CONFIGURATION ====================CHAT_ID = "XXXXXXXXXXX"#"YOUR TELEGRAM BOT TOKEN"LOG_FILE_PATH = "/home/pi/ALL_WSPR.TXT"TOKEN = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"#"YOUR TELEGRAM CHAT ID"# =======================================================# Obfuscated URL segments to bypass local filtering blocksp1 = "htt" + "ps://"p2 = "ap" + "i."p3 = "tele" + "gram.org"p4 = "/b" + "ot"URL = f"{p1}{p2}{p3}{p4}{TOKEN}/sendMessage"def send_telegram(message):try:payload = {"chat_id": CHAT_ID,"text": message,"parse_mode": "Markdown"}response = requests.post(URL, json=payload, timeout=10)if response.status_code != 200:print(f"Telegram API Error: {response.text}")except Exception as e:print(f"Connection error: {e}")def monitor_log():print(f"Starting WSPR monitor on {LOG_FILE_PATH}...")if not os.path.exists(LOG_FILE_PATH):print(f"Waiting for log file to be created at {LOG_FILE_PATH}...")while not os.path.exists(LOG_FILE_PATH):time.sleep(5)with open(LOG_FILE_PATH, "r") as f:f.seek(0, os.SEEK_END)while True:line = f.readline()if not line:time.sleep(1) # Saves Pi Zero CPU cyclescontinueclean_line = line.strip()if clean_line:# Direct match layout formattingalert_text = f"📻 *WSPR Spot Detected:*\n`{clean_line}`"send_telegram(alert_text)if __name__ == "__main__":monitor_log()
EOFNOTE: You must enter your allocated Telegram Bot Token and Chat Id after the configuration entry.3. Systemd Service Deployment
To run both the receiver and the notification engine independently in the background, you must configure two separate services.
Service A: The RTL-SDR Hardware Decoder (wspr-monitor.service)
ini
[Unit]Description=WSPR Background Monitor ListenerAfter=network.target[Service]Type=simpleUser=rootWorkingDirectory=/home/piExecStart=/bin/bash -c "exec stdbuf -oL -eL /usr/local/bin/rtlsdr_wsprd
-f 7.0386M -c ZS1I/RX /home/pi/ALL_WSPR.TXT"Restart=alwaysRestartSec=10[Install]WantedBy=multi-user.target
Service B: The Telegram Push Engine (wspr-telegram.service)
ini
[Unit]Description=WSPR Telegram Notification PusherAfter=network.target[Service]Type=simpleUser=rootExecStart=/usr/bin/python3 /home/pi/wspr_monitor.pyRestart=on-failureRestartSec=5[Install]WantedBy=multi-user.target
4. Critical Infrastructure Commands
System Installation Dependencies
bashsudo apt update && sudo apt install python3-requests -y
Activating and Loading Services
bash
sudo systemctl daemon-reloadsudo systemctl enable wspr-monitor.service wspr-telegram.servicesudo systemctl start wspr-monitor.service wspr-telegram.service
Essential Operational Controls
Check Status:
bash
sudo systemctl status wspr-telegram.servicesudo systemctl status wspr-monitor.serviceStop Services:
bash
sudo systemctl stop wspr-telegram.servicesudo systemctl stop wspr-monitor.serviceRestart Services:
bash
sudo systemctl restart wspr-telegram.servicesudo systemctl restart wspr-monitor.serviceView Live Rolling Application Logs:
bash
sudo journalctl -u wspr-telegram.service -f
Clarification Note: Please note that I have setup my WSPR Monitoring Station to run on 40 Meters just for testing purposes. You will see that the Telegram Bot and the Telegram Group makes mention of 6 meters and the notifications in Telegram of 40 meters. Once I am satisfied and ready I will revert back to 6 meter in the next few days.
5. Transitioning to the 6m Band
When the 6m band season starts I will update my hardware dial configuration from 40m (7.0386M) to 6m (50.2910M).
Editing hardware configuration:
bash
sudo nano /etc/systemd/system/wspr-monitor.serviceModify the
ExecStartdial frequency argument:Replace
-f 7.0386Mwith-f 50.2910M
Save, reload, and apply the frequency change:
bash
sudo systemctl daemon-reloadsudo systemctl restart wspr-monitor.service
I did a few test runs and spots were send automatically to WSPRNET and TELEGRAM. Look at the main image above and the image below. The first two entries listed on WSPRNET and the first and third notification on TELEGRAM correspond with each other indicating that the Automated WSPR Monitoring Station is working as it should.
Image: WSPRNET Database (Click on image for larger view.)









