Tuesday, December 31, 2024

Pi-hole: Pi Zero 2W for Ad-Free Browsing

Step-by-Step: Setting Up Pi-hole on Your Raspberry Pi Zero 2 W

Pi-hole is a network-wide ad blocker that acts as a DNS sinkhole. It improves browsing speed and security by blocking unwanted content before it reaches your devices. This guide will walk you through setting up Pi-hole on a Raspberry Pi Zero 2 W.

What You’ll Need

  • Raspberry Pi Zero 2 W
  • MicroSD card (8GB or larger)
  • MicroSD card reader
  • Micro-USB power supply
  • USB-to-Ethernet adapter or a stable Wi-Fi connection
  • Case for your Raspberry Pi (optional)
  • A computer with internet access

Step 1: Prepare the MicroSD Card

  1. Download Raspberry Pi OS Lite
    Go to the Raspberry Pi website and download the Lite version.
  2. Flash the OS
    Use software like Raspberry Pi Imager or balenaEtcher to flash the OS onto your MicroSD card.
  3. Enable SSH (Optional)
    After flashing, create a file named ssh (no extension) in the /boot directory of the MicroSD card to enable SSH.
  4. Configure Wi-Fi (Optional)
    Create a file named wpa_supplicant.conf in the /boot directory and add the following:

    country=US
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    network={
        ssid="Your_WiFi_SSID"
        psk="Your_WiFi_Password"
    }

    Replace Your_WiFi_SSID and Your_WiFi_Password with your network credentials.

Step 2: Boot the Raspberry Pi

  1. Insert the MicroSD card into your Pi Zero 2 W and power it on.
  2. Connect to the Raspberry Pi via SSH using its IP address. On a Linux/Mac terminal or Windows PowerShell, type:
    ssh pi@<IP_ADDRESS>

    The default username is pi, and the password is raspberry.

Step 3: Update the System

Run the following commands to update your system:

sudo apt update && sudo apt upgrade -y

Step 4: Install Pi-hole

  1. Install Pi-hole using the one-step automated script:
    curl -sSL https://install.pi-hole.net | bash
  2. Follow the prompts:
    • Select your preferred upstream DNS provider (e.g., Google, OpenDNS).
    • Set a static IP address for the Pi-hole.
    • Enable or disable the web interface and logs as needed.
  3. Note the admin interface password displayed at the end of the installation.

Step 5: Configure Router DNS

  1. Log in to your router’s admin interface.
  2. Set the Raspberry Pi’s IP address as the primary DNS server.

Step 6: Access Pi-hole Dashboard

Open a browser and navigate to http://<Pi_IP_Address>/admin. Log in with the admin password.

Step 7: Optimize Pi-hole

  1. Add blocklists for better ad blocking. Go to Settings > Blocklists and add more lists like The Big Blocklist Collection.
  2. Use the Pi-hole Query Log to whitelist/blacklist domains as needed.

Optional: Add a Pi-hole Monitor

Use a small OLED display to monitor Pi-hole statistics directly on the Pi Zero 2 W. A guide for this could be a follow-up project!

Conclusion

Your Raspberry Pi Zero 2 W is now a dedicated ad-blocking powerhouse! Enjoy faster browsing and enhanced privacy across your entire network.

Friday, December 27, 2024

Hyperion: DIY Ambilight with WS2812B, ESP32

 


Create Your Own Ambilight System: Step-by-Step Guide with WS2812B LEDs and ESP32

This guide provides step-by-step instructions to create an Ambilight system for your TV using WS2812B LEDs, an ESP32, and Hyperion. Follow these steps to enjoy immersive lighting synchronized with your screen.


Materials Required


Step 1: Assemble the Hardware

1. Plan Your Layout

  • Measure the perimeter of your TV and cut the WS2812B LED strip to the required length (if necessary).
  • Place the strip around the back edges of the TV, ensuring the LED direction matches your planned wiring.
  • Choose a starting point for the LED strip (e.g., bottom center, bottom left) based on ease of cable management and software configuration. The starting position can influence both physical setup and how effects are displayed, so ensure this is set correctly in the software later. – Measure the perimeter of your TV and cut the WS2812B LED strip to the required length (if necessary).
  • Place the strip around the back edges of the TV, ensuring the LED direction matches your planned wiring.

2. Wire the Components

  • Power: Connect the LED strip’s +5V and GND to the 5V power supply. Ensure your power supply can handle the strip’s current requirements (each LED draws up to 60mA at full brightness).
  • Logic Level Shifter:
    • Connect the ESP32 GPIO pin (e.g., GPIO 2) to the logic level shifter’s 3.3V input.
    • Connect the 5V output of the logic level shifter to the LED strip’s DI (data input) pin.
  • Resistor: Solder a 330-470 ohm resistor in series with the data line to protect the LEDs and improve signal stability.
  • Capacitor: Place a 1000 µF capacitor across the +5V and GND terminals near the start of the LED strip to smooth power fluctuations.
  • Grounding: Ensure all components share a common ground (ESP32, power supply, and LED strip).

Step 2: Flash WLED on the ESP32

1. Download WLED Firmware

2. Flash the Firmware

3. Initial Configuration

  • Connect to the WLED Wi-Fi network (SSID: WLED-AP).
  • Access the WLED setup page at http://4.3.2.1.
  • Configure your home Wi-Fi network and save settings.

4. Set Up LED Strip in WLED

  • Enter the number of LEDs in your strip.
  • Set the GPIO pin for data (e.g., GPIO 2).
  • Configure the starting point of the LED strip to match its physical placement (e.g., bottom center, bottom left) to ensure effects align properly.
  • Save the settings.
  • Enter the number of LEDs in your strip.
  • Set the GPIO pin for data (e.g., GPIO 2).
  • Save the settings.

Step 3: Install and Configure Hyperion

1. Install Hyperion

  • Download and install Hyperion from hyperion-project.org on a device capable of running it (e.g., Raspberry Pi, Windows PC, or macOS).

2. Set Up Screen Capture

  • If using a USB HDMI capture device:
    • Connect the capture device to your source (e.g., TV’s HDMI output).
    • Configure the device in Hyperion to grab the screen feed.
  • Alternatively, set up software-based screen grabbing if supported by your system.

3. Configure Hyperion to Control WLED

  • In Hyperion’s LED Hardware Configuration:
    • Select WLED as the LED device.
    • Enter the IP address of the ESP32 running WLED.
    • Set the LED layout to match the strip placement on your TV.

Step 4: Fine-Tune and Test

1. Adjust Settings in Hyperion

  • Configure brightness, colors, and zone mapping to align with your TV dimensions.

2. Test the Setup

  • Play colorful videos or a movie to verify the Ambilight effects.

3. Optimize for Performance

  • Ensure minimal lag by tweaking Hyperion settings.
  • Keep firmware for WLED and Hyperion updated for the latest features.

Troubleshooting Tips

  • No Lights: Check power connections and ensure the ESP32 is outputting a signal.
  • Flickering LEDs: Verify the resistor is in place on the data line and the capacitor is installed across the power supply.
  • Wi-Fi Issues: Ensure the ESP32 is connected to the same network as your Hyperion device.

WLED: DIY Shop Smart Lighting with ESP32, 12V LED Strips

 



Repair and Smart Shop Lighting: Build a Customizable System with ESP32, 12 V LED Strips, and WLED

My Noma Shop lights (from Canadian Tire) lasted about 2 years then they stopped illuminating. I decided to repair them by replacing and adding components to the lighting chassis.

Are you looking to upgrade your shop lighting with a smart, energy-efficient system? This guide will show you how to use an ESP32 microcontroller, BTF LED strips, and WLED firmware to create a customizable and intelligent lighting solution. By the end of this tutorial, you’ll have a lighting system that you can control from your smartphone or adjust manually using a rotary encoder.


Core Components

Before we dive into the wiring and setup, here’s a list of the key components you’ll need for this project:




Step 1: Wiring the Power System

The power system setup is the backbone of this project. Here’s how to wire the 12V power supply, MOSFET regulator, and buck converter:

Connect the 12V Power Supply Output:

  1. Positive terminal to the buck converter and MOSFET regulator.
  2. Negative terminal to the common ground (GND) of all components.

Current Calculation for a 1-Meter LED Strip

  • Power Draw: 14W/m
  • Current: Power (W) / Voltage (V) = 14W / 12V = 1.2A
  • Ensure the power supply can handle the LED strip’s current draw with a safe margin (2A is sufficient for this project).

MOSFET Regulator & ESP32 Power:

  • The MOSFET Regulator will handle the current required for the LED strip.
  • The ESP32 requires 5V, supplied by the buck converter stepping down the 12V input.
  • Connect the buck converter’s 5V output to the ESP32 VIN pin, ensuring it’s well-regulated.

Fuse and Pull Switch:

  • Add a panel mount fuse (3A–6A slow-blow) on the positive 12V line between the power supply and MOSFET input.
  • Retain the JX42B pull switch after the fuse for manual power control.

Step 2: LED Strip Control

The MOSFET Regulator controls the power to the LED strip. Here’s how to wire this part of the system:


MOSFET Board

MOSFET Pin ESP32 Pin (GPIO) Board Pin (P) Description
DC+ Input 12V Power Supply Connect to the positive terminal of the power supply
DC- Input GND Connect to the ground terminal of the power supply
DC+ Output To LED Strip (+) Positive terminal to the LED strip
DC- Output To LED Strip (-) Negative terminal to the LED strip
GND GND GND Ground connection for the control circuit
PWM Input Signal GPIO13 P13 PWM signal to control brightness from the ESP32

Additional Notes

  1. Preinstalled Resistors: The MOSFET board includes built-in resistors for stable operation. External resistors are unnecessary.
  2. Power Supply and LED Strip Connections:
    • Connect the 12V power supply to the DC+ Input and DC- Input pins.
    • The LED strip’s positive terminal connects to DC+ Output, and the negative terminal connects to DC- Output.
  3. The PWM Input Signal pin receives a pulse-width modulation signal from the ESP32, allowing brightness control.

Step 3: Manual Control with Rotary Encoder

To manually adjust the brightness, you’ll integrate a rotary encoder into the system:

Connect the Rotary Encoder:

  • GND to ESP32 GND.
  • CLK and DT pins to ESP32 GPIO pins (e.g., GPIO12 and GPIO27).
  • SW (push button) to another GPIO pin (e.g., GPIO33).

The rotary encoder will allow you to adjust brightness levels, adding flexibility in case smartphone control isn’t convenient.

Typical Connections

Here’s how you can connect the rotary encoder to the ESP32:

Component Pin Connections

Rotary Encoder

Encoder Pin ESP32 Pin (GPIO) Board Pin (P) Description
SW GPIO33 P33 Switch pin (button press)
GND GND GND Ground connection
Out A (CLK) GPIO27 P27 Clock signal from encoder
Out B (DT) GPIO12 P12 Data signal from encoder
GND GND GND Ground connection (shared with SW)

Step 4: Configure WLED Firmware for Smart Control

Once your hardware is set up, it’s time to install and configure the WLED firmware on the ESP32. This step enables smart lighting control via your smartphone or web interface.

  1. Flash WLED Firmware onto the ESP32 using the WLED installation guide. Recommended Firmware is MoonMod
  2. Open your browser and go to the IP address of your ESP32 (you’ll find this in your router’s connected devices list or using a network scanning tool), or use a WiFi device to connect to the access point WLED-AP using the default password wled1234.
  3. In the WLED settings, configure the GPIO pin (e.g., GPIO13) to control the LED strip with PWM White.
  4. Set the strip type to PWM White (as you’re using a single color LED strip, not RGB).
  5. Set the state when power returns if lost, to run 250, as this is the saved last state.

Key Features Using WLED:

  • Smartphone Control: Control brightness and effects from the WLED app or web interface.
  • Manual Overrides: Use the rotary encoder for dimming when app control isn’t practical.
  • Presets: Program lighting scenes, such as full brightness for work and dimmed for ambiance.
  • Expandability: WLED supports integration with smart home platforms like Home Assistant, Alexa, or Google Home.

Step 5: Add Safety with a Panel Mount Fuse

For added protection, install a Panel Mount Fuse in your circuit:

Fuse Rating:

  • The 1-meter LED strip draws 1.17A at 12V, so we recommend using a 3A to 6A slow-blow fuse. This will handle inrush currents when powering up without tripping immediately.

Fuse Installation:

  • Place the fuse on the positive 12V line between the power supply and the MOSFET input. This ensures the fuse will blow if the system exceeds the rated current, preventing damage to your components.

Step 6: Configure the Rotary Encoder in WLED

  1. Flash WLED on the ESP32: If you haven’t already, follow the steps in Step 4 to install the WLED firmware onto your ESP32.
  2. Access the WLED Web Interface:
    • Open your browser and go to the IP address of your ESP32 (you’ll find this in your router’s connected devices list or using a network scanning tool), or use a WiFi device to connect to the access point WLED-AP using the default password wled1234.
  3. Configure GPIO Pins for the Rotary Encoder:
    • Navigate to Settings > GPIO settings.
    • For Rotary Encoder setup, you’ll need to configure the following pins:
      • Encoder CLK Pin: This is the pin connected to the CLK pin on the rotary encoder.
      • Encoder DT Pin: This is the pin connected to the DT pin.
      • If the rotation is reversed, then swich pins between CLK and DT.
      • Encoder Button Pin (optional): This is the pin connected to the SW (push button) on the encoder, if you want to use it for switching modes or toggling brightness.

Example GPIO assignments:

  • CLK pin: GPIO 12
  • DT pin: GPIO 27
  • SW pin: GPIO 33 can alternatively be set in LED Preferences > Button 0 GPI0 to 33
  1. Enable Rotary Encoder Functionality:
    • After assigning the pins, scroll down to Rotary Encoder settings.
    • Enable the Rotary Encoder feature by checking the box for Enable Rotary Encoder.
    • You can configure whether the encoder controls the brightness or other settings like effects.
  2. Test the Rotary Encoder:
    • Once you’ve configured it, go to the WLED web interface or app and test turning the encoder.
    • The rotary encoder should now control the brightness or the selected parameter.

WLED Settings for Rotary Encoder Control:

  • Brightness Control: By default, the rotary encoder can be set to control the brightness. This is often the most common setting.
  • Fast Control: Some versions of WLED allow you to adjust how fast the encoder changes settings. You can fine-tune this in the settings if needed.

Safety Considerations

Ensure all connections are insulated to avoid short circuits.

Use a panel mount fuse (3A slow-blow recommended) in the positive 12V line between the power supply and the MOSFET.

Retain the JX42B pull switch for manual power control, placing it directly after the fuse.

Step 7: Project Box



I have designed a project box and posted it on Printables. Here is the Link for this project:

Final Thoughts

By following this guide, you can easily upgrade your shop lighting with a customizable, smart system. The ESP32 and WLED firmware give you full control over your lighting, while the MOSFET Regulator and rotary encoder offer seamless manual control. Whether you’re looking for energy efficiency or advanced features like remote control, this system has it all. With the retained JX42B pull switch and the added safety of a panel mount

Building BlueMountainDJ.com: A Modern Wedding DJ Website with Tailwind CSS and JavaScript

Building BlueMountainDJ.com: A Modern Wedding DJ Website with Tailwind CSS and JavaScript As a web developer, I recently had the opportunit...