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-controllerIn 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/SENSORS.md
# Sensor Guide
The board has three identical bare I²C sensor positions. Each position provides four connected plated holes on a 2.54 mm pitch. No header is fitted by JLCPCB. You can hand-solder a male header, female header, or wires directly. They all share the same four electrical connections:
```text
GND 3V3 SDA SCL
```
This is normal for I²C. The ESP8266 identifies each sensor by its address, so several different sensors can share SDA and SCL at the same time.
## Recommended sensor set
These three sensors use different addresses and can work together:
| Purpose | Recommended module | Typical address | What it can do |
| --- | --- | --- | --- |
| Temperature | BME280 | `0x76` or `0x77` | Temperature, humidity, and air pressure |
| Light | BH1750 | `0x23` or `0x5C` | Measures room brightness in lux |
| Motion/proximity | VL53L0X | `0x29` | Measures distance; software detects someone approaching or waving |
### Temperature, humidity, and pressure
- [Waveshare BME280 module at Robu](https://robu.in/product/waveshare-bme280-environmental-sensor-temperature-humidity-barometric-pressure)
- [Robu environmental-sensor selection](https://robu.in/product-category/environmental-sensor/)
- [Amazon India BME280 search](https://www.amazon.in/s?k=BME280+I2C+sensor+module)
Choose a BME280 breakout that supports I²C and 3.3 V. Be careful: cheaper BMP280 modules do not measure humidity.
Example ideas:
- Make the light warm orange when the room is cold.
- Change it to blue when the room becomes hot.
- Send temperature and humidity readings to your app.
### Ambient light
- [GY-302 BH1750 module at Robu](https://robu.in/product/gy-302-bh1750-light-intensity-module/)
- [Robu BH1750 light-sensor selection](https://robu.in/product-category/sensor-modules/light-color-sensor/)
- [Amazon India BH1750 search](https://www.amazon.in/s?k=BH1750+I2C+light+sensor+module)
Choose a GY-302 or GY-30 BH1750 module that supports 3.3 V. It reports brightness as lux, which is easier to use than a simple LDR value.
Example ideas:
- Keep the strip off during daylight.
- Turn it on automatically when the room becomes dark.
- Reduce brightness at night so the light is comfortable.
### Motion or proximity
- [M5Stack VL53L0X module at Robu](https://robu.in/product/m5stack-time-of-flight-distance-ranging-sensor-unit-vl53l0x/)
- [Robu VL53L0X and motion-sensor selection](https://robu.in/product-category/ir-and-pir-sensor/)
- [Amazon India VL53L0X search](https://www.amazon.in/s?k=VL53L0X+I2C+distance+sensor+module)
The VL53L0X is a distance sensor rather than a traditional room-wide PIR sensor. Your program can treat a large distance change as motion or detect a hand approaching the controller.
Example ideas:
- Turn on the light when a person approaches.
- Wave a hand near the sensor to toggle the light.
- Change brightness according to hand distance.
An [APDS9960 gesture/proximity module](https://robu.in/product-category/sensor-modules/light-color-sensor/) is another suitable 3.3 V I²C option. Its usual address is `0x39`.
## Connecting a sensor
Match the signal names, not the order or wire colors printed on the sensor module:
```text
Board holes/header Sensor module
GND -> GND
3V3 -> VIN, VCC, or 3V3
SDA -> SDA
SCL -> SCL
```
Sensor modules do not all arrange their pins in the same order. Do not push a module directly onto a fitted header unless its printed order exactly matches `GND 3V3 SDA SCL`. Use suitable jumper wires when the order differs.
Only use 3.3 V-compatible modules. Do not connect a sensor output or I²C pull-up to 5 V because the ESP8266 GPIO pins are 3.3 V only.
## Arduino libraries
Install these from Arduino IDE's Library Manager:
- `Adafruit BME280 Library` and `Adafruit Unified Sensor`
- `BH1750` by Christopher Laws
- `Adafruit VL53L0X`
The board already includes shared I²C pull-up resistors. Some sensor breakouts also include pull-ups; one or two typical breakout boards are usually fine, but too many parallel pull-ups can overload the bus.
## Starting I²C in firmware
The board uses GPIO4 for SDA and GPIO5 for SCL:
```cpp
#include <Wire.h>
void setup() {
Wire.begin(4, 5); // SDA, SCL
}
```
Start by connecting one sensor and running an I²C scanner. After its address appears, add the next sensor. The recommended BME280, BH1750, and VL53L0X addresses do not conflict.
## Example automation story
During the day, the BH1750 sees enough sunlight and keeps the RGB light off. In the evening, it becomes dark and the light turns on at low brightness. When the VL53L0X sees someone approach, the light becomes brighter. The BME280 can choose a warm color on a cold evening or a cooler color when the room is hot. You can try all of these rules first with the onboard RGB LED, then connect a strip when the behavior is ready. The ESP8266 can send all readings and the current light state to your Wi-Fi app.