Welcome to Jason Brain’s Tech Blog, where over 30 years of hands-on experience in web development, DIY tech projects, and AI innovation come together. Explore real-world tutorials, GitHub workflows, smart tech hacks, and the future of digital creation. From building your own tools to mastering AI-powered solutions, find practical insights for developers and tech enthusiasts. Whether you're coding, tinkering, or exploring the latest in tech, dive into actionable content and stay ahead of the curv
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
Download Raspberry Pi OS Lite Go to the Raspberry Pi website and download the Lite version.
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.
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
Visit the WLED GitHub page and download the latest firmware for ESP32.
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:
JX42B Pull Switch (Retained for manual power control, placed after the fuse)
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:
Positive terminal to the buck converter and MOSFET regulator.
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
Preinstalled Resistors: The MOSFET board includes built-in resistors for stable operation. External resistors are unnecessary.
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.
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.
Flash WLED Firmware onto the ESP32 using the WLED installation guide. Recommended Firmware is MoonMod
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.
In the WLED settings, configure the GPIO pin (e.g., GPIO13) to control the LED strip with PWM White.
Set the strip type to PWM White (as you’re using a single color LED strip, not RGB).
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
Flash WLED on the ESP32: If you haven’t already, follow the steps in Step 4 to install the WLED firmware onto your ESP32.
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.
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
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.
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:
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