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/INSTRUCTION.md

# Light Controller Instructions

This board controls a simple RGB light strip through Wi-Fi. It also has an onboard RGB test LED, so a strip is not needed for the first test. USB-C supplies power only. Program the ESP8266 through J_UART with an external 3.3 V USB-to-UART adapter, then use the built-in browser page to change colors, brightness, effects, and the sleep timer.

For the low-cost assembly plan, see [`HAND_SOLDER.md`](./HAND_SOLDER.md).
For a section-by-section explanation of the board, see [`DETAILS.md`](./DETAILS.md).

## Which RGB strip should I buy?

The strip must have all four of these connections:

```text
+5V  R  G  B
```

Look for these words in the product description:

- 5 V DC
- four-pin or four-wire RGB
- non-addressable or analog RGB
- common anode/common positive
- 5050 RGB

### Suitable options

1. [Lumaz 5 V SMD 5050 RGB strip with four-pin plug](https://lumazlife.com/products/5v-smd-5050-rgb-led-strip-light-flexible-tape-light-waterproof-with-4pin-plug) — this is the clearest direct match. Select the 5 V, four-pin version and begin with a short piece.

2. [Banggood search for 5 V four-pin RGB strips](https://my.banggood.com/buy/5v-4-pin-rgb-led-strip.html) — look for the non-addressable 5050 version with `+5V, R, G, B` pads.

3. [Amazon India search for 5 V four-pin analog RGB strips](https://www.amazon.in/s?k=5v+4+pin+analog+rgb+led+strip) — check the photographs and description carefully before ordering.

For a very small test light, the [SunFounder four-LED RGB strip specification](https://docs.sunfounder.com/projects/galaxy-rvr/en/latest/hardware/cpn_rgb_strip.html) shows the exact compatible arrangement: 5 V common anode with separate R, G, and B connections.

Do not buy:

- A 12 V or 24 V strip
- A three-pin strip marked `5V, DATA, GND`
- WS2812B, WS2813, SK6812, NeoPixel, or other addressable strips
- An RGBW strip with five connections

## Connecting the strip

J2 is intentionally unpopulated. Hand-solder the four-pin screw terminal first, then connect the strip:

```text
Board J2       RGB strip
+5V       ->   +5V or V+
R         ->   R
G         ->   G
B         ->   B
```

Check the labels printed on the strip. Do not depend only on wire colors.

## Power

USB-C powers both the controller and the RGB strip. Use a good 5 V USB-C power adapter and cable.

Start with a short strip. Keep the total strip current around 1 to 1.5 A or less because the controller also needs power and the board has a 2 A fuse. Do not connect a full high-power reel without measuring its current.

## Programming the ESP8266

For a complete step-by-step guide, see [`HOW_TO_PROGRAM.md`](./HOW_TO_PROGRAM.md).

USB-C supplies power only on this low-cost version. Use an external **3.3 V USB-to-UART adapter** for programming.

J_UART is intentionally unpopulated. Hand-solder a three-pin header, or temporarily connect wires to its plated holes. Power the board through USB-C, then connect the adapter:

```text
Adapter TX  -> board RX
Adapter RX  -> board TX
Adapter GND -> board GND
```

Do not connect a 5 V UART signal to the ESP8266. Do not connect the adapter's power pin; the board is already powered by USB-C.

RESET and BOOT are momentary tactile buttons.

To enter programming mode:

1. Hold BOOT down.
2. Press and release RESET.
3. Release BOOT.
4. Start the upload through the USB-to-UART adapter.
5. Press RESET once after uploading if the program does not start automatically.

The RGB outputs used by the firmware are:

```text
Red   GPIO12
Green GPIO13
Blue  GPIO14
```

The firmware can connect the ESP8266 to Wi-Fi, receive colors from your app, and produce PWM signals for the three RGB channels. The onboard LED and external strip use the same three channels, so they show the same color.

### Sample Arduino program

Use [`SAMPLE_LIGHT_CONTROLLER.ino`](../firmware/SAMPLE_LIGHT_CONTROLLER/SAMPLE_LIGHT_CONTROLLER.ino) as a simple first demo. It connects the ESP8266 to your Wi-Fi and creates a small color-control page that works from a phone or computer on the same network.

1. Install the ESP8266 board package in Arduino IDE.
2. Open `SAMPLE_LIGHT_CONTROLLER.ino`.
3. Replace `YOUR_WIFI_NAME` and `YOUR_WIFI_PASSWORD` with your Wi-Fi details.
4. Select **Generic ESP8266 Module** and your external adapter's serial port.
5. Put the board into programming mode using the BOOT and RESET sequence above, then upload.
6. Open the Serial Monitor at **115200 baud**.
7. Copy the displayed IP address into a browser on a phone or computer connected to the same Wi-Fi.

At startup, the sample program briefly shows red, green, and blue on the onboard LED. The demo page then provides a color picker and an off button. It is intended for testing on a trusted local Wi-Fi network and does not include login security.

### Full Wi-Fi controller

For the polished controller, upload [`WIFI_LIGHT_CONTROLLER.ino`](../firmware/WIFI_LIGHT_CONTROLLER/WIFI_LIGHT_CONTROLLER.ino).

After uploading, connect your phone to:

```text
Wi-Fi name: Mohan Glow Studio
Password: makeitglow
Control page: http://192.168.4.1
```

The ESP8266 creates this local network itself, so internet access is not required. The page includes a draggable color wheel, quick colors, power, brightness, more than 20 animations, effect tuning, clap disco, and a sleep timer.

For the full experience, install [`Mohan-Glow-Studio-v2.apk`](../releases/Mohan-Glow-Studio-v2.apk) on an Android phone. Android may say the controller Wi-Fi has no internet; choose **Stay connected**. The app gives you scenes, saved colors, custom palettes, sound reactions, phone-sensor controls, camera color capture, and daily routines.

### Clap disco

Press **Start microphone**, allow microphone access, and adjust **Sensitivity**. Higher sensitivity reacts to quieter sounds. A strong clap or beat produces a random bright color; silence turns the LEDs off after about half a second.

The live meter helps you set the threshold. Raise sensitivity until claps and strong beats trigger reliably, but speech and background noise do not.

Most phone browsers require HTTPS before allowing microphone access. Since the ESP8266 page is served from local HTTP, use [`Mohan-Glow-Studio-v2.apk`](../releases/Mohan-Glow-Studio-v2.apk). Connect to `Mohan Glow Studio`, open the app, choose **Reactive**, and press **Start**.

### Phone sensor controls

Open **Sensors** and press **Enable**. You may independently turn on:

- Tilt left/right to choose a color.
- Tilt forward/back to change brightness.
- Shake to select a random scene.
- Dance mode to flash colors from strong movement.
- Place the phone face-down to turn the light off.
- Wave over the proximity sensor to toggle power.
- Match brightness to the room-light sensor.
- Flash on each detected step.
- Rotate the phone to change animation speed.
- Photograph an object and use its center color.

Sensor availability differs between Android phones. A missing sensor simply leaves that feature inactive.

## Optional addressable strip

Tail, chase, and per-LED animations require a three-wire addressable strip such as WS2812B or SK6812. It cannot be connected directly to J2. See [`ADDRESSABLE_STRIPS.md`](./ADDRESSABLE_STRIPS.md) before wiring one, because using the SDA hole for LED data prevents normal I²C sensor use at the same time.

## Sensor connections

All three sensor positions are bare, connected through-hole footprints. Hand-solder male or female 2.54 mm headers—or wires directly—as needed. Every position has:

```text
GND  3V3  SDA  SCL
```

The I²C pins are:

```text
SDA GPIO4
SCL GPIO5
```

Several I²C sensors can share these connections when every sensor uses a different I²C address. Use 3.3 V-compatible sensor modules.

See [`SENSORS.md`](./SENSORS.md) for compatible temperature, light, and motion/proximity sensor recommendations, shopping links, wiring details, Arduino libraries, and automation ideas.

## First test

1. Confirm that JLCPCB fitted both tactile buttons, the center RGB LED, its three 1 kΩ resistors, and the 10 µF `C_RGB_BULK` capacitor.
2. Power the board without the RGB strip.
3. Check approximately 5 V at `TP_5V` and 3.3 V at `TP_3V3` relative to `TP_GND`.
4. Upload the sample program and confirm that the center LED briefly shows red, green, and blue.
5. Connect to the board over Wi-Fi and test more colors using the web page.
6. When the onboard test works, connect a short piece of strip.
7. Test the strip at low brightness, then increase brightness slowly and check that the USB connector, fuse, MOSFETs, and wires do not become hot.