Introduction: Wifi Controlled Garden Light With ESP8266
I've got a bit of a thing for lights and being able to remotely control them. I particularly like this in the garden and even better if i can solar power them. I have some of the pound/dollar store stake lights but they are rather weak so i started to look around and found that the dollar/pound store also sold small pillar lights that i would be able to repurpose.
I then stripped it down and retro fitted three 1w LED's and a ESP8266 wifi micro controller which shall allow me to control the light remotely either manually or via timer/events. The board i purchased can take 5 but on working out the voltage i would need more than 12v to drive them at full brightness and i didn't want to have to setup up the voltage as that would require another component so i settled on 3 which works nicely, i bridged two of the LED positions as they are in series so leaving them connected wasn't an option.
I am using a dedicated Led driver board as these 1w led's must only be driven with 350ma of current, the beauty of this board is that it will increase the foward voltage if you increase extra LED's upto a maximum of 10. It must be noted however that each led shall take 3.3v so if you are planning on running 10 LED's then you shall require an input voltage of 33v, just below the units 35v rated maximum. As we are driving 3 LED's which require at least 9.9v which works great with out 12v supply. The other great feature of this board is that it has a pwm connection so that you can vary the brightness of the light by connecting it to a PWM pin on a microcontroller and sending the correct signal. This is excellent as it negates the need for any other hardware bar a step down converter to get 3.3v for the ESP 8266 board.
I've included two programs for the ESP8266. One allows you to connect to the IP address of the light with say a smart phone and the second is for integrating it into a home automation system such as Domoticz which is what i use at home. I take no credit for the coding as that is down to other people so many thanks to them :-)
Step 1: The Parts
For creating the light we shall be retrofitting an existing light with the following components
350ma LED driver board Ebay Link
5 LED board Ebay Link
Step down power converter Ebay Link
ESP8266-01 Ebay Link
Heat Sink Ebay Link
2x4pin socket Ebay Link
The eagle eye'd shall notice that my heat sink is not the full height. I realised that it be just too tall to fit inside the lid so i took a hacksaw and cut it in half. This will lessen the cooling potential but i'm not planning on driving them at %100 all of the time so i'm not too concerned.
A ESP8266 programmer. I would recommend a programmer as it can be used for many projects and to be honest it can be a right pain trying to program them otherwise. You can rig things up on a perfboard or similar but i honestly didn't have too much luck as the connection timing has to be very precise. 8266 Programmer link
Thermal Glue. I used thermal glue in between the heatsink and back of the led board as it has a metal back so it helps to get a good thermal transfer
Step 2: Disassembly
I used an existing light as a starting point as there is no way i would be able to produce a light shell/housing such as the one in the pictures for the cost of the light. Also for the cost i think it looks quite smart!
The light is extremely easy to take apart, just be careful not to lose the screws in the top section which houses the circuitry as you shall require them later. We are going to try and keep all the circuitry in the same housing but it shall be a tight fit!
To allow the new components i removed the lid and snipped off the solar panel wires as they were no longer required. I also had to cut a larger hole in the center so that the the heatsink could fit through. If you skipped the LED pcb and heatsink this wouldn't be necessary if you were just using a 1w LED which would probably still give off a good amount of light. Factoring in the cost of the other components though i went for three 1w LEDs so that it would be a usable amount of light.
Step 3: Assembling the Light With New Parts.
As we now effectively have a shell we need to try and wedge everything into the small housing at the top of the light. As there are only two screws but 4 screw posts i recommend to remove the unused screw posts to make space for the new parts.
I assembled the pcb board by soldering the LED's onto the board one by one. A tip is to use some flux if you have it to help the solder flow. Solder up one of the pads first then heat it and place the Led onto it so it is sitting flush, then flow solder onto the other pad. In doing it this way you have an easier time getting it to sit flush. If you flow solder onto both pads intially when you come to solder on the Led as you can only fit one side at a time one side shall be sticking up slightly.
As you can see from the photo's i tried to position everything on the outside so that it was as far as possible away from the center due to the heat from the heatsink potentially. I found it easiest to hotglue in the parts first and then solder the connections, in this way i could cut the wires to the correct length as space is limited. I soldered all connections directly except the ESP chip as i wanted to be able to remove the board and program it if required.
Step 4: Programming the ESP8266, This Can Be Tricky!
For coding the ESP 8266 itself you need to put it into bootloader mode ( using the programming tool if you purchased it) then once it's flashed with ESPFlasher you need to then upload the lua code using an application called ESPlorer. A kind gentleman named quindorian has detailed this process well as part of his LED dimmer strip project. He is using the ESP-01 and has designed his own small circuit using a mosfet to do the PWM, the LED driver board we are using has PWM builtin so in this instance we only need to borrow his code :-)
I recommend reading the following three blog posts of his which show the process in great detail.
I use the same code as quindorian except that i had to add a single line
I placed this directly below the line
LED1_target=tonumber(string.sub(payload, 29) )
I had to do this as the PWM is inverted on the LED driver board so you must supply a small current to lower the light level and set it to 1023 to turn it off.
If you wish to use it on it's own without home automation you only need program the ESP module, i've not tested it personally but something like this should work
Step 5: Testing As Part of Home Automation Software
I use software called Domoticz which runs on a Raspberry pi, they even have a pre-baked image i believe so pretty easy to get going. Doesn't have to be a Pi though and can run on most platforms.
As you can see from the video it's accessible from a web browser and allows you to control the devices which are on your network or connected via a gateway. In the example i'm turning off the light and adjusting the brightness as the light is dimable. The beauty is that you can also place timers or say get it to come on at sunset and it works that out based on your location and time of year so it's fully automated. I also like being able to control it away from the house.
I've got it hooked up to a small 12v battery. I plan to hook this up to my solar setup so it's lighting the garden but not costing me anything to do so. One word of warning as these are sitting outside and will inevitably get wet i would advise you to make sure you've a fused connection as if it shorts it's going to cause some damage to your setup or other devices in your setup.
Step 6: Finished Product Conclusion and Costs.
Annoyingly i had already written this part but it seems it lost it when i published :-(
I'm really happy with the light and all in i think it will be roughly £4.50 or so taking into account all the parts including the original light.
I'm really happy with the outcome and it's a really good light level now which is actually useful rather than just accent lighting. I don't feel the 12v is too much of a constraint since once you've ran the cabling your sorted.