Skip to content

jg3/internet-down-led-rpi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Internet Down LED - Raspberry Pi

A simple but practical hardware project that monitors internet connectivity and provides visual feedback via an LED indicator.

If the internet goes DOWN, the LED blinks rapidly. If the internet is UP the LED blinks and holds steady for a couple of seconds.

Overview

This project runs a continuous internet connectivity monitor on a Raspberry Pi that:

  • Tests internet connectivity every 2 seconds by pinging 8.8.8.8 (Google DNS)
  • Provides visual feedback via LED blinking patterns
  • Indicates connection status with a solid LED state
  • Automatically starts on system boot via systemd

Features

  • Visual Feedback: LED blinks to indicate test initiation (number of blinks = consecutive failures + 1)
  • Dual LED Support: Works with either the on-board ACT (green) LED or an external LED on GPIO 17
  • Auto-Recovery: Automatically restores LED to default behavior if service is disabled
  • Systemd Integration: Runs as a managed service with automatic startup and restart on failure
  • Comprehensive Logging: All events logged to /var/log/connectivity_monitor.log

Hardware Requirements

  • Raspberry Pi 4 (or Pi 3)
  • External LED (optional - can use on-board ACT LED)
  • 220Ω resistor (if using external LED)
  • Jumper wires
  • Breadboard (optional)

LED Behavior

When Internet is UP (Connected)

  1. LED starts OFF
  2. Blink pattern: 1 blink (100ms ON, 100ms OFF)
  3. Ping test runs
  4. LED turns ON and stays ON for ~2.3 seconds (assuming PING_INTERVAL is the default 3 seconds)
  5. Repeat every 2 seconds

When Internet is DOWN (After 3 consecutive failed pings)

  1. LED starts OFF
  2. Blink pattern: N blinks (where N = consecutive failures + 1, max 4)
  3. Ping test runs
  4. LED stays OFF for ~2.3 seconds
  5. Repeat every 2 seconds

Wiring (External GPIO 17 LED)

GPIO 17 → 220Ω Resistor → LED Positive (long leg) → LED Negative (short leg) → GND

Or more explicitly:

  • GPIO 17 pin → Resistor (first end)
  • Resistor (second end) → LED positive leg (longer)
  • LED negative leg (shorter) → Ground (GND pin)

Installation

1. Clone the Repository

cd ~
git clone https://github.com/jg3/internet-down-led-rpi.git
cd internet-down-led-rpi

2. Set Up Log File Permissions

sudo touch /var/log/connectivity_monitor.log
sudo chown pi:pi /var/log/connectivity_monitor.log
sudo chmod 644 /var/log/connectivity_monitor.log

3. Install Systemd Service

sudo cp connectivity-monitor.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable connectivity-monitor.service
sudo systemctl start connectivity-monitor.service

4. Verify Installation

sudo systemctl status connectivity-monitor.service
sudo journalctl -u connectivity-monitor.service -n 20

Configuration

Edit connectivity_monitor.py to customize behavior:

LED_TYPE = "GPIO17"             # "ACT" for on-board LED or "GPIO17" for external
PING_TARGET = "8.8.8.8"         # Server to ping for connectivity check
PING_INTERVAL = 2               # Seconds between connectivity tests
CONSECUTIVE_FAILURES = 3        # Failed pings before marking internet as DOWN

# Blink timing (in milliseconds)
BLINK_ON_MS = 200               # Duration LED is ON during blink
BLINK_OFF_MS = 100              # Duration LED is OFF between blinks

Project History

This project was developed over a couple of fireside evenings with the assistance of Claude AI. It serves as a simple but practical demonstration of:

  • Raspberry Pi GPIO control
  • Python subprocess management
  • Systemd service integration
  • Hardware interfacing with LEDs

Troubleshooting

LED not turning on/off

Check wiring: Verify GPIO 17 → Resistor → LED → GND connection Verify resistor value: Should be 220Ω or 330Ω Check GPIO pin: Ensure you're using GPIO 17 (pin 11 on RPi board) LED polarity: Long leg (positive) should connect to resistor, short leg (negative) to GND

License

This project is open source and available for personal use and modification. I would love to hear about if and how you use it, but that's not an obligation.

About

A Raspberry Pi app that indicates Internet failure by lighting an LED.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages