Six components work together to manage and debug your SIMCOM SIM7600G-H cellular modem on Raspberry Pi:
- cellular-config.sh - Centralized configuration file (edit this to change carriers)
- connect-cellular-robust.sh - Production connection script with modem state management (runs on Pi)
- connect-cellular-dynamic.sh - Alternative connection script with manual IP configuration (runs on Pi)
- auto-recover.sh - Continuous monitoring daemon for connection stability (runs on Pi)
- setup-dns-routes.sh - DNS and route configuration helper (runs on Pi)
- cellular-debug.sh - Debugging and diagnostics (runs on Pi)
From your local machine:
cd Pi-Cellular
chmod +x *.sh
./cellular-remote-deploy.sh pi@192.168.1.100Replace 192.168.1.100 with your Pi's IP address or hostname.
ssh pi@192.168.1.100sudo /opt/cellular/cellular-debug.sh status# Recommended: Use robust script for production
sudo /opt/cellular/connect-cellular-robust.sh
# Alternative: Use dynamic script for manual configuration inspection
sudo /opt/cellular/connect-cellular-dynamic.shexport CELLULAR_LOG_DIR=/var/log/cellular
sudo -E nohup /opt/cellular/auto-recover.sh 30 &sudo /opt/cellular/cellular-debug.sh testAll carrier-specific settings are in cellular-config.sh. This file is sourced by all scripts, making the system carrier-agnostic.
Key variables:
# Carrier APN (change this for your carrier)
CELLULAR_APN="ereseller"
# IP type
CELLULAR_IP_TYPE="ipv4v6"
# Interface name
CELLULAR_INTERFACE="wwan0"
# Route metric (higher = lower priority, allows WiFi preference)
CELLULAR_ROUTE_METRIC="700"
# MTU size
CELLULAR_MTU="1430"To change carriers:
- Edit
cellular-config.sh - Update
CELLULAR_APNto your carrier's APN - All scripts automatically use the new value
Common APNs:
ereseller- Current configurationverizon- Verizoniot.1nce.net- 1NCEm2m.vodafone.com- Vodafonelte-m.vodafone.de- Vodafone LTE-M
Purpose: Connect cellular modem with robust modem state management
Features:
- Handles various modem states (disabled, searching, registered, connected)
- Disconnects existing bearers before creating new ones
- Automatic interface management (brings wwan0 up if needed)
- Delegates DNS/routes configuration to
setup-dns-routes.sh - Comprehensive error handling and logging
- Colored output for easy reading
- Automatic connectivity verification
- Designed to work with
auto-recover.shdaemon
Usage:
sudo /opt/cellular/connect-cellular-robust.shWhen to use:
- Production deployments
- Automated/daemon usage
- When you want modular configuration (DNS/routes handled separately)
- For use with
auto-recover.shmonitoring
Purpose: Connect cellular modem with manual IP configuration
Features:
- Manually extracts and configures IP addresses from modem
- Works reliably after each reboot
- Comprehensive error handling
- Colored output for easy reading
- Automatic connectivity verification
- Detailed debugging output for configuration extraction
Usage:
sudo /opt/cellular/connect-cellular-dynamic.shOutput Example:
[INFO] Starting cellular connection setup...
[INFO] Step 1: Enabling modem 0...
[INFO] Modem enabled successfully
[INFO] Step 2: Creating bearer with APN=ereseller, IP-Type=ipv4v6...
[INFO] Bearer created successfully
...
[INFO] Cellular connection established!
==========================================
Interface: wwan0
IP Address: 10.19.145.184/28
Gateway: 10.19.145.185
DNS: 172.26.38.2
MTU: 1430
==========================================
Note: The APN and IP-Type are read from cellular-config.sh. To use a different carrier, edit that file.
Troubleshooting:
- If it fails, check modem status first:
sudo cellular-debug.sh status - If "Failed to retrieve IP configuration", increase sleep time in script
- If connectivity test fails, check carrier restrictions with
cellular-debug.sh test
When to use:
- Troubleshooting and detailed inspection of configuration
- When you want to see exact IP addresses extracted from modem
- For understanding network configuration details
Purpose: Continuously monitor and recover cellular connection
Features:
- Runs as a background daemon (every 30 seconds by default)
- Checks routes, DNS, IP connectivity, and DNS resolution
- Automatically reconfigures if any check fails
- Detects and fixes connection loss automatically
- Comprehensive logging for debugging
- Configurable check interval
Usage:
# Start daemon with 30-second interval
export CELLULAR_LOG_DIR=/var/log/cellular
sudo -E nohup /opt/cellular/auto-recover.sh 30 &
# Monitor daemon output
tail -f /var/log/cellular/auto-recover.log
# Stop daemon
sudo pkill -f auto-recover.shWhat it checks:
- Routes exist and are correct
- DNS is configured
- IP connectivity (ping 8.8.8.8)
- DNS resolution (nslookup google.com)
When to use:
- Production deployments requiring high availability
- Long-running systems where connection stability is critical
- Paired with
connect-cellular-robust.shfor automated recovery
Purpose: Configure DNS and routes for cellular connection
Features:
- Handles both systemd-resolved and /etc/resolv.conf
- Calculates correct subnet routes for any prefix length (/24 to /32)
- Configures DNS servers automatically
- Fallback to 8.8.8.8 if modem doesn't provide DNS
- Comprehensive error handling
Usage:
# Standalone usage
sudo /opt/cellular/setup-dns-routes.sh
# Called automatically by connect-cellular-robust.shWhen to use:
- Called automatically by
connect-cellular-robust.sh - Manual reconfiguration of routes/DNS if needed
- Troubleshooting DNS or routing issues
Purpose: Diagnose and troubleshoot modem issues
Commands:
sudo /opt/cellular/cellular-debug.sh statusShows modem details, bearer status, interface configuration, and routes.
sudo /opt/cellular/cellular-debug.sh testTests:
- IPv4 address assignment
- Default route configuration
- DNS resolution
- ICMP ping to 8.8.8.8
- HTTP connectivity
sudo /opt/cellular/cellular-debug.sh signalShows signal quality and detailed signal statistics.
sudo /opt/cellular/cellular-debug.sh simShows SIM information and PIN status.
sudo /opt/cellular/cellular-debug.sh networkShows registered network and available networks.
sudo /opt/cellular/cellular-debug.sh connectManually connect modem (useful for testing).
sudo /opt/cellular/cellular-debug.sh disconnectSafely disconnect the modem.
sudo /opt/cellular/cellular-debug.sh resetPerform a full modem reset (disconnect and reconnect).
sudo /opt/cellular/cellular-debug.sh logsShows recent ModemManager and cellular connection logs.
sudo /opt/cellular/cellular-debug.sh helpPurpose: Deploy scripts from local machine to remote Pi
Usage:
./cellular-remote-deploy.sh [user@host]Examples:
./cellular-remote-deploy.sh pi@192.168.1.100
./cellular-remote-deploy.sh pi@192.168.1.50
./cellular-remote-deploy.sh pi@10.19.145.184What it does:
- Tests SSH connection to remote Pi
- Creates remote directory
- Copies all scripts and documentation
- Makes scripts executable
- Verifies deployment
Requirements:
- SSH access to remote Pi
scpcommand available (usually included with SSH)- Remote user has sudo access
# SSH to Pi
ssh pi@192.168.1.100
# Check modem status
sudo /opt/cellular/cellular-debug.sh status
# Connect using robust script
sudo /opt/cellular/connect-cellular-robust.sh
# Verify connectivity
sudo /opt/cellular/cellular-debug.sh test
# Start auto-recovery daemon (recommended)
export CELLULAR_LOG_DIR=/var/log/cellular
sudo -E nohup /opt/cellular/auto-recover.sh 30 &# SSH to Pi
ssh pi@192.168.1.100
# Check modem status
sudo /opt/cellular/cellular-debug.sh status
# Connect using dynamic script for detailed inspection
sudo /opt/cellular/connect-cellular-dynamic.sh
# Verify connectivity
sudo /opt/cellular/cellular-debug.sh test# SSH to Pi
ssh pi@192.168.1.100
# Check status
sudo /opt/cellular/cellular-debug.sh status
# If disconnected, reconnect (auto-recover daemon should handle this)
sudo /opt/cellular/connect-cellular-robust.sh
# Verify connectivity
sudo /opt/cellular/cellular-debug.sh test# Monitor daemon logs
tail -f /var/log/cellular/auto-recover.log
# Check if daemon is running
ps aux | grep auto-recover.sh
# Stop daemon if needed
sudo pkill -f auto-recover.sh# Check signal strength
sudo /opt/cellular/cellular-debug.sh signal
# Check SIM status
sudo /opt/cellular/cellular-debug.sh sim
# View recent logs
sudo /opt/cellular/cellular-debug.sh logs
# Reset modem
sudo /opt/cellular/cellular-debug.sh reset
# Manual connectivity test
sudo /opt/cellular/cellular-debug.sh test
# Emergency modem reset (if stuck)
sudo bash /opt/cellular/reset-modem.shOn the remote Pi, create /etc/systemd/system/cellular-connect.service:
[Unit]
Description=Cellular Modem Connection
After=network.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/opt/cellular/connect-cellular-robust.sh
RemainAfterExit=yes
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.targetCreate /etc/systemd/system/cellular-auto-recover.service:
[Unit]
Description=Cellular Auto-Recovery Daemon
After=cellular-connect.service
Wants=cellular-connect.service
[Service]
Type=simple
ExecStart=/bin/bash -c 'exec /opt/cellular/auto-recover.sh 30'
Environment="CELLULAR_LOG_DIR=/var/log/cellular"
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.targetThen enable both:
sudo systemctl daemon-reload
sudo systemctl enable cellular-connect.service cellular-auto-recover.service
sudo systemctl start cellular-connect.service cellular-auto-recover.serviceCheck status:
sudo systemctl status cellular-connect.service
sudo systemctl status cellular-auto-recover.service
sudo journalctl -u cellular-connect.service -f
sudo journalctl -u cellular-auto-recover.service -fAdd to /etc/rc.local before exit 0:
/opt/cellular/connect-cellular-robust.sh >> /var/log/cellular-connect.log 2>&1 &
sleep 5
nohup /opt/cellular/auto-recover.sh 30 >> /var/log/cellular-auto-recover.log 2>&1 &Solution:
- Verify Pi is on network:
ping 192.168.1.100 - Check SSH is enabled:
sudo systemctl status ssh - Verify username: try
ssh pi@...orssh ubuntu@... - Check firewall: ensure port 22 is open
Solution:
- Check modem is connected:
sudo cellular-debug.sh status - Increase sleep time in script (modem may be slow to connect)
- Check bearer is connected:
mmcli -b 1
Solution:
- This is often normal for cellular carriers (they may block external traffic)
- Test with your actual server instead
- Check DNS resolution:
nslookup google.com
Solution:
sudo systemctl start ModemManager
sudo systemctl enable ModemManagerSolution:
- Check modem is enabled:
mmcli -m 0 - Check bearer is created:
mmcli -b 1 - Restart ModemManager:
sudo systemctl restart ModemManager
# Watch modem status
watch -n 1 'sudo mmcli -m 0 | grep -E "(State|Signal|Network)"'
# Watch interface status
watch -n 1 'ip addr show wwan0'
# Watch logs
sudo journalctl -u cellular-connect.service -f# Create a cron job to check connectivity every 5 minutes
# Edit crontab:
crontab -e
# Add this line:
*/5 * * * * /opt/cellular/cellular-debug.sh test >> /tmp/cellular-test.log 2>&1After deployment, scripts are located at:
/opt/cellular/
├── cellular-config.sh # Configuration file (EDIT THIS for carrier changes)
├── connect-cellular-robust.sh # Production connection script (recommended)
├── connect-cellular-dynamic.sh # Alternative connection script
├── auto-recover.sh # Continuous monitoring daemon
├── setup-dns-routes.sh # DNS and route configuration helper
├── reset-modem.sh # Emergency modem reset
├── cellular-debug.sh # Debugging and diagnostics
└── CELLULAR_SCRIPTS_README.md # This file
For detailed technical information, see CELLULAR_SETUP_GUIDE.md.
For quick help on any script:
sudo /opt/cellular/cellular-debug.sh help| Feature | Dynamic | Robust | Auto-Recover |
|---|---|---|---|
| IP Configuration | Manual extraction | Delegated to helper | N/A |
| Modem State Management | Basic | Advanced | N/A |
| Bearer Cleanup | No | Yes | N/A |
| DNS/Routes | Manual | Delegated | Monitors |
| Continuous Monitoring | No | No | Yes |
| Connection Recovery | Manual | Manual | Automatic |
| Best For | Troubleshooting | Production | High Availability |
For Production Deployments:
- Use
connect-cellular-robust.shfor initial connection - Run
auto-recover.shdaemon for continuous monitoring - Set up systemd services for automatic startup
For Troubleshooting:
- Use
connect-cellular-dynamic.shto see detailed configuration - Use
cellular-debug.shfor diagnostics - Check logs with
journalctlor tail auto-recover.log
- SSH to Pi:
ssh pi@<ip> - Check status:
sudo /opt/cellular/cellular-debug.sh status - Connect:
sudo /opt/cellular/connect-cellular-robust.sh - Test:
sudo /opt/cellular/cellular-debug.sh test - Start daemon:
export CELLULAR_LOG_DIR=/var/log/cellular && sudo -E nohup /opt/cellular/auto-recover.sh 30 & - Set up automation (optional): Create systemd services