mohan-bee/light-controller

This code defines the hardware sections and symbols for a PCB involving USB power, voltage regulation, ESP12F module, RGB outputs, I2C sensors, and debug points, along with rendering labels for test points.

Version
1.0.30
License
unset
Stars
2

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone mohan-bee/light-controller  # download the package files into ./light-controller
tsci add mohan-bee/light-controller    # add it to your project as @tsci/mohan-bee.light-controller

In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.

docs/DETAILS.md

# Light Controller Board — How It Works

## What this board does

This board controls a 5 V analog RGB LED strip over Wi-Fi.

USB-C supplies power. To reduce component and assembly cost, programming uses an external 3.3 V USB-to-UART adapter connected to the UART holes. The ESP8266 can connect to Wi-Fi, read optional sensors, and change the red, green, and blue brightness independently.

The main flow is:

```text
USB-C power → protection → 5 V system power → RGB strip
                                  ↓
                           3.3 V regulator
                                  ↓
                              ESP-12F + sensors

External USB-UART adapter → UART holes → ESP-12F

ESP PWM signals → gate resistors → MOSFETs → onboard RGB LED + strip channels
```

## Main electrical connections

The board uses a few shared connections, called nets:

- `VBUS_5V` is the raw 5 V arriving from USB-C.
- `V5_SYS` is the protected 5 V after the fuse.
- `V3_3` is the regulated 3.3 V used by the ESP and sensors.
- `GND` is the common return connection for the whole board.
- `ESP_TX` and `ESP_RX` carry programming and serial data.
- `I2C_SDA` and `I2C_SCL` carry sensor data and the sensor clock.
- `RGB_RED_PWM`, `RGB_GREEN_PWM`, and `RGB_BLUE_PWM` are the ESP brightness-control signals.

## 1. USB-C power input

### J1 — USB-C connector

J1 is a power-only USB-C connector in this low-cost version.

- Both USB-C VBUS pins join `VBUS_5V` so the board receives 5 V in either plug orientation.
- D+ and D− are intentionally unused.
- Both connector ground pins and all four shell pins connect to `GND`.

The connector is placed at the right edge so the cable can plug in without touching other parts.

### R_CC1 and R_CC2 — 5.1 kΩ USB-C resistors

Each USB-C CC pin connects to ground through its own 5.1 kΩ resistor. These resistors tell a USB-C source that this board is a power consumer and wants normal 5 V power.

They are close to J1 because they belong directly to the connector.

The USB data converter, USB data ESD device, and their capacitors were removed to reduce cost. A USB cable therefore cannot upload firmware directly.

## 2. Power section

### F1 — resettable 2 A fuse

F1 connects raw `VBUS_5V` to protected `V5_SYS`.

If the board or LED strip draws too much current, the fuse heats up and greatly reduces the current. After power is removed and the fault is fixed, it can recover.

It is placed close to the USB-C power entry so most of the board is behind the protection.

### U_REG — ME6211C33M5G-N 3.3 V regulator

The ESP8266 and sensors cannot run directly from USB's 5 V. U_REG changes `V5_SYS` into `V3_3`.

- `VIN` connects to `V5_SYS`.
- `EN` is tied to `VIN`, so the regulator turns on whenever USB power is present.
- `VOUT` creates `V3_3`.
- `GND` connects to the common ground.

The regulator is placed between the 5 V power area and the ESP area so the 3.3 V connection to the ESP can remain short.

### C_REG_IN_BULK and C_REG_IN_HF — regulator input capacitors

- The 10 µF capacitor handles slower power changes.
- The 100 nF capacitor handles fast electrical noise.

Both connect from `V5_SYS` to `GND` and are placed close to the regulator input.

### C_REG_OUT_BULK and C_REG_OUT_HF — regulator output capacitors

- The 10 µF capacitor helps keep 3.3 V steady when the load changes.
- The 100 nF capacitor removes higher-frequency noise.

Both connect from `V3_3` to `GND` and are placed close to the regulator output.

## 3. ESP-12F controller

### U_MCU — ESP-12F / ESP8266

This is the brain of the board. It runs the program, joins Wi-Fi, reads sensors, and creates the three RGB brightness signals.

Important pin use:

| ESP pin | Purpose |
|---|---|
| GPIO12 | Red PWM |
| GPIO13 | Green PWM |
| GPIO14 | Blue PWM |
| GPIO4 | I2C SDA |
| GPIO5 | I2C SCL |
| TXD0 | Serial data sent by ESP |
| RXD0 | Serial data received by ESP |
| GPIO0 | Boot-mode control |
| RST | Reset control |
| EN | Enables the ESP |

The ESP module is placed at the left board edge so its PCB antenna faces away from the other circuitry. The marked keepout under the antenna blocks components and copper on both layers. This helps Wi-Fi performance.

### C_ESP_BULK and C_ESP_HF — ESP power support

The ESP can draw short bursts of current while using Wi-Fi.

- The 10 µF capacitor supplies energy during those bursts.
- The 100 nF capacitor removes fast noise.

Both connect from `V3_3` to `GND` and are kept close to the ESP power pins.

### ESP boot resistors

These resistors give important ESP pins a safe default state at startup:

- `R_EN_PU`: pulls EN up to 3.3 V so the ESP is enabled.
- `R_RST_PU`: pulls RST up so the ESP normally runs.
- `R_GPIO0_PU`: pulls GPIO0 up for normal boot.
- `R_GPIO2_PU`: pulls GPIO2 up, as required for normal boot.
- `R_GPIO15_PD`: pulls GPIO15 down, as required for normal boot.

Without these default states, the ESP might start in the wrong mode or fail to boot.

They are placed near the ESP because they control its startup pins directly.

### SW_RESET and SW_BOOT

- SW_RESET connects `ESP_RST` to ground.
- SW_BOOT connects `ESP_GPIO0` to ground.

For programming, GPIO0 must be held low while the ESP resets. With the current parts, the basic sequence is:

1. Connect a 3.3 V USB-to-UART adapter to J_UART.
2. Hold BOOT so GPIO0 is connected to ground.
3. Press and release RESET.
4. Release BOOT and upload the program through the adapter.
5. Reset again to start the new program normally if needed.

The selected JLCPCB `C55200589` parts are momentary tactile buttons, so they release when you stop pressing them. They are included in JLCPCB assembly.

The switches are near the lower-left edge so they are easy to reach and remain close to the ESP boot circuitry.

## 4. Sensor connections

### J_SENSOR_1, J_SENSOR_2, and J_SENSOR_3

These are three identical unpopulated I2C sensor positions. Each position has four plated holes on a 2.54 mm pitch. Male or female headers can be hand-soldered later. Every position has:

```text
Pin 1: GND
Pin 2: 3.3 V
Pin 3: SDA
Pin 4: SCL
```

All three positions share the same SDA and SCL wires. This is normal for I2C: several sensors can communicate over the same two signal wires.

Each I2C sensor has an address. The ESP selects a sensor by sending that address before reading or writing data. A temperature sensor, light sensor, and motion sensor can share these connections if:

- Each sensor works at 3.3 V.
- Each sensor uses I2C.
- Their I2C addresses are different.

Two sensors with the same fixed address cannot normally share the bus. In that case, change an address using the sensor's address pin when supported, or use an I2C multiplexer.

The three hole groups are placed closely together to make the sensor area easy to find and keep their shared connections compact.

### R_SDA_PU and R_SCL_PU — I2C pull-up resistors

I2C devices pull SDA and SCL low but do not drive them high. These two 4.7 kΩ resistors gently pull both signals back to 3.3 V.

- R_SDA_PU connects SDA to `V3_3`.
- R_SCL_PU connects SCL to `V3_3`.

They are placed close to the sensor holes because they support the shared sensor bus.

Some sensor modules already contain pull-up resistors. Too many modules with their own pull-ups can make the combined resistance too low. Check the sensor modules if many are connected at once.

### J_UART — serial programming holes

J_UART exposes:

```text
RX, TX, GND
```

This is the programming and debugging connection for an external 3.3 V USB-to-UART adapter. Connect adapter TX to board RX, adapter RX to board TX, and ground to ground. The board itself is powered through USB-C.

No header is assembled at J_UART. Its three plated holes are placed beside the sensor connections so all expansion wiring is together. You can hand-solder a header or temporary wires.

## 5. RGB LED output

### LED_RGB_TEST — onboard RGB test LED

The small LED in the center of the board is a common-anode RGB LED assembled by JLCPCB. Its common pin connects to protected 5 V. Its red, green, and blue pins connect through separate 1 kΩ resistors to the same three switched color channels used by the strip.

This means the onboard LED and the strip always show the same color. You can upload firmware, test red, green, blue, color mixing, Wi-Fi control, and sensor rules without fitting J2 or connecting a strip. The three resistors keep the LED current low and safe.

The selected part is `C2827321` (`S4-3528RGBTA-A`), a 3528 common-anode RGB LED. It is placed near the center so it is easy to see while testing.

### J2 — LED-strip connector

J2 is the four-pin output for a 5 V common-anode analog RGB strip:

```text
Pin 1: +5 V
Pin 2: Red
Pin 3: Green
Pin 4: Blue
```

The strip's common +5 V wire receives `V5_SYS`. The three color wires are switched toward ground by the MOSFETs.

J2 is placed at the top edge so the LED-strip cable can leave the board cleanly.

Do not connect an addressable strip such as WS2812B directly to this connector. This output is for a four-wire analog RGB strip. An addressable strip can instead use separate 5 V, GND, and GPIO wiring as described in `ADDRESSABLE_STRIPS.md`.

### Q_RED, Q_GREEN, and Q_BLUE — color switches

The ESP cannot safely power an LED strip directly. Each AO3400A N-channel MOSFET acts as a fast electronic switch:

- Q_RED switches the red channel to ground.
- Q_GREEN switches the green channel to ground.
- Q_BLUE switches the blue channel to ground.

The ESP rapidly turns each MOSFET on and off using PWM. More on-time makes that color brighter; less on-time makes it dimmer. Mixing the three brightness values creates different colors.

The MOSFETs are placed directly below the RGB connector. This keeps the higher-current color paths short.

### R_RED_GATE, R_GREEN_GATE, and R_BLUE_GATE — 100 Ω gate resistors

Each 100 Ω resistor sits between an ESP PWM pin and a MOSFET gate. It limits the short current pulse needed when the gate changes state and helps reduce ringing and electrical noise.

They are placed close to the MOSFET gates.

### R_RED_PD, R_GREEN_PD, and R_BLUE_PD — 100 kΩ gate pulldowns

Each 100 kΩ resistor connects a MOSFET gate to ground. It keeps that MOSFET off while the ESP is starting, resetting, or unpowered.

Without these resistors, a floating gate could make the LED strip flash unexpectedly.

### C_RGB_BULK and C_RGB_HF — LED power support

- C_RGB_BULK is a 10 µF 0805 capacitor. It provides local LED-supply decoupling without placing a large 470 µF load directly on USB power, and it is included in JLCPCB assembly.
- C_RGB_HF is a 100 nF capacitor that absorbs fast switching noise.

Both connect between `V5_SYS` and `GND` and are placed near the RGB output area.

## 6. Test points

The bottom row of pads makes important signals easy to measure or connect during development:

| Test point | Signal |
|---|---|
| TP_5V | Protected 5 V power |
| TP_3V3 | Regulated 3.3 V power |
| TP_GND | Ground |
| TP_TX | ESP transmit data |
| TP_RX | ESP receive data |
| TP_GPIO0 | Boot-mode signal |
| TP_RST | Reset signal |

They are aligned along one board edge so probes and temporary wires can reach them without crossing the main components.

## 7. Board shape and mechanical parts

The compact board is a 60 mm × 44 mm rectangle with 3 mm rounded corners. USB-C is on the left edge and the RGB output connector is directly opposite on the right edge, giving the board a simple horizontal power-to-light flow. The ESP sits along the top edge with its antenna facing outward, while the sensor, UART, buttons, and test connections remain accessible below it.

Four 3.2 mm mounting holes sit near the corners. They are intended for M3-size mounting hardware and are kept away from the main circuitry.

The board uses two copper layers. A ground pour on the bottom layer gives ground current a broad return path and helps reduce electrical noise. The ESP antenna keepout remains empty on both layers.

The decorative bottom silkscreen does not carry electricity. It only gives the board a finished appearance.

## 8. How the complete board behaves

When USB-C is connected:

1. USB provides 5 V through J1.
2. F1 protects the board and creates `V5_SYS`.
3. `V5_SYS` powers the LED-strip connector.
4. The ME6211 creates 3.3 V for the ESP and sensors.
5. The ESP boots using the states set by its boot resistors.
6. Firmware is loaded with an external 3.3 V USB-to-UART adapter when needed.
7. The ESP joins Wi-Fi and runs the light-controller program.
8. The ESP can read attached I2C sensors.
9. The ESP changes three PWM outputs according to the app, automation, or sensor readings.
10. The MOSFETs control the red, green, and blue channels for both the onboard test LED and the strip.

For example, a light sensor could make the strip dim during the day, a motion sensor could turn it on when somebody enters, and a temperature sensor could change its color from blue to red as the room becomes warmer.

## Practical limits

- Use only a 5 V, four-wire, common-anode analog RGB strip.
- The strip and board share the current available from the USB-C supply.
- A normal computer USB port may not safely provide enough current for a long strip.
- Use a suitable 5 V USB supply and keep the LED-strip length/current within the board, connector, fuse, copper, and MOSFET limits.
- Connect only 3.3 V-compatible I2C sensors to the sensor holes.
- Flashing requires an external 3.3 V USB-to-UART adapter and manual BOOT/RESET operation.

## Cost-down assembly plan

These parts are marked `doNotPlace` and are soldered by hand:

- J2 RGB screw terminal
- J_UART pin header
- Any required J_SENSOR male or female headers

All three J_SENSOR positions are bare plated holes. Fit only the headers or wires needed for the project. The RESET/BOOT buttons, `C_RGB_BULK`, onboard RGB LED, and its three resistors are not DNP; JLCPCB assembles them.