Non destructive cheap USB lamp PWM hack
Posted: Wed Dec 28, 2016 5:48 pm
My son uses this cheap USB LED lamp as a nightlight. Unfortunately, its pretty bright and he tends to position it about 3 inches from his face. Most nights he's still reading as I come upstairs.
So, this non destructive hack uses a 5V 2A PSU to drive a USB socket and a WEMOS D1 MINI PRO. There's plenty of power for both, but the ground to the USB socket is connected via a MOSFET, which I can PWM with the D1.
The case will feature an ON/OFF button which will really just provide a momentary signal telling the D1 to change state (if LED is powered, depower it, and vice versa).
Of course, being an ESP8266, I'll also be able to turn the lamp off remotely, and have an NTP lookup inform a schedule of times that the light will be OFF (after he's left for school), ON (bedtime cue), and the PWM level (which will slope slowly 100% down to 10% after bedtime is reached.)
Here's the proof of concept.
So, this non destructive hack uses a 5V 2A PSU to drive a USB socket and a WEMOS D1 MINI PRO. There's plenty of power for both, but the ground to the USB socket is connected via a MOSFET, which I can PWM with the D1.
The case will feature an ON/OFF button which will really just provide a momentary signal telling the D1 to change state (if LED is powered, depower it, and vice versa).
Of course, being an ESP8266, I'll also be able to turn the lamp off remotely, and have an NTP lookup inform a schedule of times that the light will be OFF (after he's left for school), ON (bedtime cue), and the PWM level (which will slope slowly 100% down to 10% after bedtime is reached.)
Here's the proof of concept.