Over 10 years professional experience on electric fireplaces & home lighting products

wake-up ceiling light

by:Longjian     2020-04-09
I like the idea of waking up
Turn on the lights, simulate the sunrise in the morning and wake up in a gentle way.
For this reason, there are many commercial products, usually with the shape of the bracket
Separate bedside lamp
I think it would actually work better if the whole concept was integrated into the main ceiling lighting in our bedroom, so I decided to build it.
I start with the following requirements: requirements (2)
This means that the solution must be able to track time and alarm settings via poweroff.
I have selected NTP server sync for Time Sync, and I have selected EEPROM storage for alarm settings. Requirements (1)and (3)
This means that there must be some wireless way to configure alerts.
I chose an html 5 mobile app provided by lamp to do this.
This project is modified from the normal ceiling light.
It must be an LED
Lamp based on 12 V power module and internal LED unit. This set-
Up allows you to connect your own electronics between the power supply and the LED unit.
Of course, the lamps also need to provide enough physical spare space for our electronic equipment. about 8. 0 x 5. 0 x 3. 0 cm (or 3. 1 x 2. 0 x 1. 2 inch).
The super friendly person from my local Hubo hardware store asked me to open the box to find the right box and I ended up with an Eglo LED GIRON 13493.
This is a 24-Watt, 12-watt LED model.
This photo shows the lamp in an unmodified form and the lid is removed.
If you want to build this project with bigger lights, it is absolutely possible --
The circuit we will use can handle larger currents.
The price of this ceiling lamp is 40 euros (about US$ 44).
I used the following electronic components in this project: the MOSFET type does not matter.
It just needs an N-
Channel Power MOSFET-
220 package with low on resistance-
Many other types will do the same.
The following connectors, etc.
Used to build the circuit: the total cost of the component is very different from the supplier.
I think I paid 15 euros. about US$ 16. 50)
For everything, but it should be possible to get a better deal through DX or AliExpress.
You need the following tools and devices to build it: the core of the micro-controller circuit is the ESP8266-based ESP-
01 wifi micro controller module.
The basic idea is to program this thing by sending a PWM signal to the MOSFET switch to hold the time, serve the web page, trigger the alarm and control the dimmer. The ESP-
01 board cheap, small, there\'s a simple-to-use 2. 54mm / 0.
1 \'\'spacing connector.
The downside is that you can only get 2 universal inputs/outputs (GPIO)
Pins: GPIO0 and gpio2.
Also, both need to be pulled up in order for the correct micro-controller to start up
After startup, they are driven by the boot loader for a period of timeup (
Can be seen in two attached scope screenshots).
If we drive the lights directly from any of these pins, these things cause noticeable flickering.
Looking at the range measurement again, we can see that even during the start-up process, there is no time to drive both GPIO0 and gpo2 to a low level at the same time.
We will take advantage of this by building the circuit so that the light will only be turned on if both GPIO0 and gpo2 are driven low
Effectively place NOR gate between io 0/2 and MOSFET.
Will be used (inverted)
The PWM and gpo2 will be a \"enable\" pin. This set-
Up provides us with complete control to avoid flickering.
The op amp and moset input the output of GPIO0 and GPIO2 into the reverse input of the op amp through R4 and r2. The non-
The reverse input of the op amp gets a reference voltage of about 0.
5 v created by R6/d1.
This will set up the required NOR functionality.
By supplying 12 V to the op amp, it also provides the necessary boost from 3.
3 v logic of ESP-
01 to 10 v required to fully drive the MOSFET.
We drive the MOSFET from the op amp output via r7.
While this is certainly not an ideal MOSFET driver, it is definitely good (fast)
This app is enough.
When building the circuit on the breadboard, I noticed some voltage spikes and ringing, which may have something to do with the self-perception of the wires between the MOSFET and the LED unit. I (
Rough but effective)
Suppress this by placing C2 on the source and drain.
The power supply part of our circuit needs about 12 V, and the other part needs about 3 V.
3 V, we have an existing 12 v power supply available from.
We are actually \"stealing\" energy from existing designs and hopefully we will not get more than the safety margin of existing lights
That means we have to keep the power low.
According to this study, we should work at 215 mA of the current ESP,01.
Using a linear regulator (like an LD1117)
Not a good choice.
This means that we will also extract 215 mA from the original power supply rated 1A-
So 215 mA will be very important.
In addition, the regulator will dissipate about 1.
9 W so a radiator is needed.
So I use the switch power module.
This special LM2596-
The module-based can be adjusted to the required 3.
3 V by adjusting the trimpot.
Assuming a conversion efficiency of 85%, it will extract 70 mA from the original power supply and consume 125 mW-
This is acceptable.
I built everything on a prototype PCB board.
For personal preference, I used the type of copper strip connecting 3 holes.
I start by drilling 4 holes in the corner so that I can install the circuit board later and then weld the ESP-
01, then everything else.
Including the chart of this PCB and photos with and without ESP
01 module plug in.
These should provide all the information needed together.
To connect the PCB, I used the screw terminals connected by the power supply and the LED unit, as well as a male print head to expose the ESP-serial port01.
The latter is not required, but it is highly recommended to debug if needed.
If you want to use this software
Without any modifications and without care how it was made, the process is simple: Download and decompress the attached \"wakeuplight _ esp01 \".
Open in Arduino IDE.
Modify the settings in configuration. h\'.
It needs your Wifi SSID and password, IP address information, name of NTP server (
You can probably stay the same)
And time zone information-
Your standard offset is in minutes with UTC and any daylight time rules.
After making the appropriate changes, just upload the sketch to ESP-01.
If you want to make some changes to the software, or just be interested in how it works, here are some more detailed information.
In general, the initial version of my software is pure C and is organically developed from experiments.
It works at some point (kinda)
But this is a complete mess.
Then I decided to refactor and switch to C to create a class for each individual function (
Consists of.
H file that defines the class and.
Cpp file with implementation.
The class is instantiated in the main module.
Most courses, of course, depend on other courses.
The main module injects these dependencies through the constructor of the dependent class.
The following classes exist: more detailed information is provided in the source file.
Dimmers and web server modules are special in the sense that they use the generated code in part.
The \'wakeuplight _ java_helpers.
The Zip file contains an Eclipse Java project that performs the generation.
We will zoom in below.
Wake-up at Wake merthe-
Up light is a gradual increase in the light intensity that human beings perceive.
The PWM mechanism gives us linear control over the intensity of light, but human perception is more or less logarithmic (the Weber-Fechner law).
If we don\'t compensate for this, just let the PWM duty cycle increase from 0 to 100% in step 1000, and the result will be early in the wake-up --
Cycle up, with the obvious jump, the light intensity will grow too fast, reach a high level ahead of time, and then rise very slowly from high to full for the rest of the cycle.
This is obviously not what we want.
We need to change the intensity of light exponentially rather than linearly in time to give a sense of time linear increase.
ESP8266 PWM is also not perfect.
It has some jitter that is obvious in very small work cycles and causes a noticeable flash in the lights.
Therefore, the light can be completely extinguished or the lowest stable value can be reached, but we should avoid being in.
This problem becomes less serious if the PWM frequency is low
That\'s why I only chose 100Hz.
File \"dutycycle \".
Java \'calculates the function from the steps required to perceive the light intensity (
Scale from 0 to 1800)
And PWM value (
In size of 0 to 20000).
The \'convertdutycycletoesp.
The Java program calculates this function and writes it
H file to include in Arduino project.
The dimmer code in Arduino is only looked up on this generated table.
I want to control this project with my smartphone.
Because I have more experience in online writing.
I decided to use the mobile app other than the local mobile appfriendly web-app approach. The web-App is single-
Page HTML5/jQuery application, send Ajax POST request when the user presses the button (
And periodically retrieve status updates).
This page instructs the browser to get jQuery from the jsDelivr CDN, with all JavaScript and CSS code in the HTML, as well as images using the data url.
Therefore, loading the page only needs to be done to ESP-
Keep everything simple and fast.
By including \'move-web-app-
\"Apple\" and \"Apple\"mobile-web-app-
The smartphone can add this web page to the home screen with links to tags and shortcut icons.
After that, it can start in the same way as the application (
Will start in full screen browser)
, Largely obscures the fact that it is not a native app.
Sketch must be uploaded to ESP-
01 every time you test a small change in a web page, it is not a good development cycle.
So I developed this in the Java web project with the \'light servlet.
Response of Java simulation ESP
01 to Ajax POST request.
The \'convertwebpagetoesp.
Index of Java conversion web project.
Html for \"Web server _ home page.
A file containing a web page as a string constant.
Built-in PCB and upload software to ESP-
01, it\'s time to put everything together.
Of course, to install the PCB in the fixture, you need to drill some holes in it.
Before that, I removed the power supply and LED units to avoid damaging them by drilling vibration.
After that, PCB can be installed using gasket.
I removed the original connecting lines from the power supply and instead connected them to the PCB.
I connect the PCB to the power supply with a double line.
After that, the lights can be installed on the ceiling!
When turning on the light with a wall switch, the light should be fully turned on as usual, but the delay is very short (
Less than a second, but obviously).
Now you should be able to point your mobile browser to the IP address of the lamp and view the web page.
With the add to home screen option, you can add an icon to the home screen to the real app (
Tested this on Android but should also work on iOS).
Now you can configure wake-up-
And enable it.
Don\'t turn off the wall switch when you want to sleep, because of course the whole device will be powered off.
Instead, press the \"close\" button in the app.
The next morning, you will be gently woken up at the configured time.
Custom message
Chat Online 编辑模式下无法使用
Chat Online inputting...