# WiFi-Controlled RGB Power Lamp

This repository documents the design and implementation of a WiFi-controlled RGB lamp using discrete power electronics and embedded systems. The lamp is based on 3× 5W LEDs (RGB), driven by LM3404 constant-current drivers, monitored by INA226 current sensors, and controlled by an ESP8266 microcontroller via a custom web interface.

---

## Overview

- **Microcontroller**: ESP8266 (ESP-12E)
- **LED Drivers**: LM3404, one per color channel
- **Current Sensors**: INA226 (I²C), one per channel
- **Power Supply**: 24V DC input, regulated to 5V and 3.3V
- **User Interface**: Web application hosted on ESP8266 for RGB control and power monitoring

---

## System Architecture


**Block Diagram:**

![Block Diagram](assets/block_diagram.png)

---

## Web Interface

- RGB control using Vue-based color picker
- Adjustable brightness slider (mapped to PWM)
- Real-time current monitoring (INA226)
- Basic animation mode (rainbow sequence)

**Web UI Screenshot:**

![Web UI](assets/web_ui.png)

---

## PCB Design

- 2-layer FR4 PCB with thermal copper pours and via stitching
- Test points for PWM, switch nodes, and sense lines
- FFC interface for external programmer
- Custom CH340C programming board (USB → UART)

**Top View:**

![PCB Top](assets/pcb_top.png)

**Bottom View:**

![PCB Bottom](assets/pcb_bottom.png)

**3D Render:**

![3D PCB Render](assets/pcb_render.png)

---

## Testing and Analysis

### Thermal Imaging

- Thermal images captured using Fluke thermal camera
- Red LED remains coolest; green and blue require better cooling
- Thermal deviation from calculated values due to PCB/slug bonding

**Thermal Measurement Example:**

![Thermal Image](assets/thermal_camera.png)

### Oscilloscope Measurements

- Switching ripple observed and confirmed within expected range
- DCM ringing noted at switch nodes; no impact on operation

**PWM and Switching Signals:**

![Scope PWM](assets/scope_pwm.png)

---

## Known Issues & Improvements

- **DIM Pin Fix**: Initial circuit caused full brightness during MCU boot. Fixed with pulldown resistor.
- **I²C Line Reversal**: SDA/SCL reversed in layout; resolved via software GPIO reassignment.
- **Thermal Solution**: Future revisions should consider external heatsink or aluminum-core PCB.

---

## Project Files

- `/hardware/` – KiCad PCB and schematics
- `/firmware/` – ESP8266 Arduino code
- `/docs/` – Original PDF report
- `/assets/` – Images and diagrams

---

## Full Report

All design calculations, schematics, measurements, and references are available in the final report:

[📄 Project_RubenSchoonbaert.pdf](docs/Project_RubenSchoonbaert.pdf)

---

