Introduction: Bed Room Lamp Ws2812

Hi all,

I decided to rebuild existing bed room lamp to be able control it from smartphone or any device with browser and integrate than to Apple Home.

The targets are:

1. Use WS2812b led strip to control brightness, color or animation/effects

2. Use normal lamp 220v controlled by relay to keep normal behaviour

3. Use LDR to automatic control brightness depends on room light

4. Integrated/built-in web site to control via any devices within browser

5. Integrate all of them to Apple Home kit , if existing

6. Internal scheduler to define rules, timing rules switch off and on independs from the Apple Home

Step 1: Part List

1. Any traditional lamp 900-1000 mm height

2. Plastic pipe 20-40 mm diameter and 900-1000 mm height. I have used cheap canalization pipe

3. WS2812 led strip 30-60 LEDs per meter. 2-3 meter lenght

4. ESP8266 or ESP32 device. I have used ESP8266 dev board

5. Power supply AC/DC 5V 2-3 A. (calculation is like 1A for 50 LEDs plus minus)

6. LDR

7. Relay module to control 220v lamp

8. Resistors: 1x 200 Ohm, 1x 10k Ohm

9. Some wires

Step 2: Wiring

Now is time to wiring all components together.

Step 3: Assembling

1. Wrap LEDs strip around plastic pipe

2. Put ESP8266 into any plastic box

3. Put relay module into another plastic box

4. Wire according diagrams

5. Attach boxes on the lamp bottom. I have used plastic Glue

6. Put LDR on the top of the lamp and hide wires inside of the plastic pipe

Step 4: Software

For this project I have used universal software, developed by myself

Please have a look github page https://github.com/Yurik72/ESPHomeController

This contain full instruction how to compile and setup

Exactly for this project I have used following configuration files

1. Configuration config.json

2. Services services.json

3.Triggers triggers.json

What you need check and change:

1. Services.json - adjust "numleds": xxx, where xxx number of your actual LEDs, after strip cutting

2. config.json - set proper host name for your device "localhost":<your host name>

3. config.json - set proper values for your mqtt connection: "mqtt_host","mqtt_port":,"mqtt_user","mqtt_pass".

, if mqtt_host is empty, device will not try to connect to mqtt

Step 5: Integration to Apple Home (optional)

Please have a look wiki , how to do integration

https://github.com/Yurik72/ESPHomeController/wiki/...

Please have a look attached part of configuration for Homekit2MQTT.

If you do not want to add everything manually, just replace all or part of the file (config.json) in Homekit2MQTT configuration.

Step 6: Enjoy

Now, when everything is done you can

  1. Using any device manage your light via browser
    • Switch on/off RGB LEDs
    • Switch on/off lamp bulb
    • Manage color, brightness and more than 40 built in effects for the WS2812
    • Setup simple timing scheduler for all functions described above
  2. Using Apple Home kit
    • Switch on/off RGB LEDs

    • Switch on/off lamp bulb

    • Manage color and brightness of RGB Leds

    • Using Home kit automation script setup scheduler

    • Using siri for voice control of your lamp