Super Simple RGB WiFi Lamp

26,861

32

About: "The only difference between screwing around and science is writing it down" - Adam Savage, 2012

Intro:

This project started when my girlfriend was complaining about the large empty feature wall of our new apartment. Since we both decided to hang something up there, I knew I wanted to put something of my own design up there. I started researching for inspiration across the and ended up reading a lot of Instructables which are pretty amazing, with some unique and beautiful designs. But what I kept finding is that most require either expensive tools such as 3D printers and CNC routers, or items that are highly specific to their design like old lamp shades or car bumpers for example.

I have many of these great tools available to me since I am a development engineer in heavy industry. But I wanted to challenge myself and build the most Super Simple WiFi RGB LED Lamp that anyone can build. I wanted to create a design that anyone can not only replicate, but modify with ease with minimal tools and resources available to them. To do this there were a few criteria I wanted to meet;

- Use the minimal amount of tools to build, hopefully using only common household tools

- The materials must be sourced from a location that generally anyone can has access to, such as a generic big brand hardware stores and global online retailers

- Not require anyone to access, touch, or wire high voltage circuits

- Not know any code or have ever coded before, but are willing to get started

- Have the end result be as simple and intuitive to use as possible

- Use no cloud or external services like apps for website hosting and functionality

After a bit of head scratching and browsing a couple of websites for materials, I hand drew some simple sketches of what I manage to come up with. The result was a single piece of dressed timber with some LED's taped around it using by an ESP8266 as the light driver that I would then hang on a wall. For control I wanted to create a browser based website that would be available via a home network or directly through the ESP itself.

On paper, this design was perfect, as it had 3 parts to be purchased from the hardware store, a couple more from the electronics store, and a few from online. And coupling this with a hopefully clear Instructable, that makers are able to follow along and create their own!

Supplies:

The materials required for this build will be detailed later in this Instructable. But to start the tools required will be;

  • Drill - Used for drill some holes in the timber and aluminium. This is the only more exotic tool I couldn't avoid using. If you don't have one I'm sure you can borrow one from family, friends, or even a local school or club. It can just be a regular hand drill and does not have to be powerful at all.
  • Drill bits - For drilling through the timber and aluminium. If you don't have any, they are not expensive to purchase a really cheap set from your local hardware store. If you use the exact same ones as myself, you will need a 2.5mm, 5mm, and 7 mm bits.
  • Ruler (or measuring tape) - Used for measuring everything up of course.
  • Scissors - These will be used for cutting and stripping the wires. A pair of wire strippers would be handy also.
  • Screw Drivers - This will depend on the screws you buy or have lying around. You may need Allen keys if you choose to take that path.
  • Tape - Of the sticky variety.
  • Computer - Can be a laptop or desktop of any flavour. You will need to install the Arduino environment and some USB drivers on it, so admin rights are needed.
  • Micro USB cable - To connect your computer to your ESP8266.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Cementing the Design

After hand scribbling, it was time to design in a real CAD package; Fusion 360. This was the first time using Fusion as I usually use other traditional CAD packages, but wanted to branch my knowledge into a new one. At first it is a little unintuitive for someone with other CAD experience, but after using it for a couple of hours it is apparent how easy it is to knock up designs and take some pretty renders of them.

I wont detail the exact methods and measurements of everything I did in Fusion 360, as it would be pointless. I have however attached the final file if you would like to download and edit it yourself. The design also comes with a handy drawing detailing everything for you and what you can change, so be sure to have a read of that before modifying.

The basic design consists of only a couple of components in fusion 360 to get the lamps profile. These are;

  1. The timber at 1100 x 140 x 19mm (Based on what my hardware store has. More on this later).
  2. The aluminium strips at 20 x 20 x 1.5mm jointed on the rear of the timber. The upper one has mounting holes and the lower has the power entry. Both will have the LED's stuck to them.
  3. The ESP8266. I had a model i downloaded from somewhere in STL format from a previous project. Adding it gives a great scope of size. This is mounted on four 12mm standoffs.
  4. The faux terminal block positioned in the middle of the wood on the back
  5. A couple of simulated bolts. These are Allen cap bolts as that's all i could get from the add in.
  6. Lastly the WS2821b LED's i would be using. These i jointed to the aluminium and coloured with a rainbow all around for the render.

After I had drawn the design, I double checked that I could procure each of the parts by calling the individual stores and checking that all was in stock. Since this is a basic design I made sure to chose very commonly available items, but its always safe to check.

I finished the design by applying materials and appearances to each of the parts. For the timber I used the amazing 3D textures available in fusion 360. Specifically I used the 3D pine in it as this is the material i chose to build the light out of. Have a look how close it matches the final product, amazing!

For the LED's I used an emmisive appearance and changed the colour for red green and blue renders. I then painstakingly applied a different rainbow colour to each to create the rainbow renders.

Step 2: Procuring the Parts

With our design finalised and drawn, all of the bits and pieces for it can be procured from their various sources. Below is a list of the parts I purchased with the links to them for your info. In the brackets I have also included possibly where to get the materials with links for other shops in the USA and UK.

Electronics is always a hard one since most brick and mortar stores have shut in favour of online retailers. So if you are struggling on where to buy any of these have a look at this write up to find a shop that has what you need close to you. If all else fails there's always heaps on eBay, amazon, or your favourite online store I'm sure.

To start went to the hardware store as its one of my favourite places in town. Here I purchased just three things;

  • The Timber - (Possibly from Home Depot and B&Q) I went for a 140mm x 1200mm x 19mm piece of dressed pine. Being dressed means all of the hard work of making it pretty has been done for you by the store. When choosing a piece, you must look for warping of the timber, as well as knots. This, after all, is designed to be hung up. After choosing the perfect piece, almost all hardware stores will trim lengths down to what ever you need. For myself I got them to go from 1200mm to 1100mm.
  • The Aluminium - (Possibly from Home Depot and B&Q)To match the timber, I went for a 20mm x 20mm x 1.5mm right angle with a length of 1000mm. I opted for the thinnest piece as this design is not heavy at all, so does not need much strength for mounting. Hardware stores should also be able to cut these down for you. Don't forget you will need two of these.
  • Wood screws - (These will be available anywhere) To attach the aluminium to the wood I opted for some short 12mm wood screws with a phillips head. These will bite into the wood allowing for a solid connection to the timber. Be sure to get screws that are long enough for good support, but short enough so not to poke through your timber.

I then went to my local electronics store; Jaycar. I'm not sure what the chain brick and mortar versions are in the states or the UK, so i have used digikey and RS components for reference here. At Jaycar i got the following;

  • Terminal Connector - (Possibly from Digikey or RS Components) These come in all shapes and sizes, but the main thing you are looking for is to have three screw connections, one for power, ground, and signal. As for current, you will have to match that to the number of LED's (more on that later), but for safety 10 amps terminals and above will suit fine for most applications.
  • Jumper Wires - (Possibly from Digikey or RS Components) These are invaluable when playing with electronics. They have a single connection at each end either male or female for connecting bits together. For this project, we need the male to female connections.
  • Standoffs - (Possibly from Digikey or RS Components) These are to mount the ESP8266 off the timber to cool and allow for connecting the wires to it.
  • RIght Angle Header - (Possibly from Digikey or RS Components) These help angle the pins of the ESP8266 out away from the board for a better connection with the jumper wires. I did not manage to purchase one of these in time for the build (thanks Australian delivery times), but i would highly recommend these over bents pins.
  • Bolts - (These will be available anywhere, even the Digikey and RS Components) To mount the ESP8266 and terminal block i used M3 bolts. Any ESP8266 should also use M3 holes, but try purchase a Terminal connector with similar sized holes to suit. Otherwise simply buy bolts to suit your terminal block. I went for a length of 20mm as this would go through the standoffs and into the timber enough.
  • Power Supply - (Possibly from Digikey or RS Components) This will be addressed in the next section, but I purchased a power supply capable of running my lights. This is very important and will vary case to case due to the LED's, so I have suggested very large power supplies. If you know what you are doing, you can adjust the current output. If not the suggested power supplies will suit 66 LED's. But more on this in then next section.
  • (Optional) Very Large Capacitor - (Possibly from Digikey or RS Components) If you are having issues with your ESP8266 resetting all the time, chances are the LED's as stealing too much power instantaneously from the power supply. Putting this huge capacitor of 1000uF or more in will solve those issues. This is a very common solution to a very common problem with these micro controllers.

Now, since I live in Australia, our part stores are heinously expensive when it comes to electronics such as the ESP8266 and any strip LED's in particular. So I usually head to eBay or Amazon where there are stacks and stacks for very cheap. Heads up these are affiliate links, so thanks for the support.

  • The ESP8266 nodeMCU - This is a particular platform of the ESP8266 which is great for starting on. It has a USB connection for programming and power making it super easy to use (and fix when you upload a bad program... trust me). There are a couple of form factors for these, but since our design is flexible, you can purchase any of them.
  • The WS2812b LED's - I opted for a 3 meter roll of WS2812b's with 30 led's per meter with a sticky backing. This was to keep the power levels down and in turn the heat for these. If you want you can purchase more per meter, but keep in mind of the power requirements. If you have a look at the end result, its still amazing even with fewer LED's. You also don't have to go for WS2812b's, they are what i used, but there are many more out there as outlined in this fantastic write up. Just make sure that you get a strip with the wires already soldered on the end for you.

Step 3: A Note on Powering WS2812's

This has been said many times but needs to be reiterated; one thing that beginners (and experts for that matter) always ignore on most electronics projects is power. Power is almost always a cause of problems when starting a project as it is usually underestimated. This is especially true for applications requiring large numbers of LED's to be powered on and switched frequently like this project.

The WS2812b's are thirsty 5050 packaged LED's and require a fair amount of current to use. With Adafruit's estimate at at around 60mA per chip on full white. In this project the total number of LED's used is 66 which, when projected comes to 3960mA! Add the 300mA of overhead you need for the ESP8266 and you can see this is a huge amount of current and will blow up under specified power supplies.

To check the actual current consumption for my purchased LED's, I measured the current seen at full white when all 66 LED's were on (also each of the channels for reference). This came to 2.24 Amps instead of the 3.96 Amps predicted, which is was glad about to start with as this meant i could use a smaller power supply. But this is not always the case and will depend on your LED's.

If you cannot measure how much current your LED's will draw, the safest method is to over estimate the power supply current rating and buy something accordingly. In every project there is no harm in over specifying how much current the power supply should be able to supply. In this case, the only thing that thing that will be on fire may be your back pocket. But better that than your hard work.

If at this stage you think you should try find lower power LED's, there were two important reasons why I chose a strip of WS2812b's with 30 leds/m. The first is the small number per meter means less LED's and therefore less power required in total. The second is that the WS2812b's are essentially have on board constant current power supplies, which means as voltages fluctuate within optimal conditions they remain the same brightness. This takes a lot of work out of keeping the LED's around the strip the same brightness and colour.

The chips are also dimmable meaning that if you want to use less power, you can just set it to a lower brightness! However if you aim to use a smaller power supply with this is a method, it is bound to fail, as sooner or later the brightness may go above what you specified and things will blow up.

With this all stated, there is just one thing to keep in mind; over specify your power supplies current rating for your application and you will never run into issues.

Step 4: Attaching the Aluminium to the Timber

After procuring all of the parts, its now time for the fun part, Putting it all together. I started by cleaning up my work area making sure there was no dust or dirt that could stain the timber as it will be on display. I then took the following steps to mount the aluminium to the back of the timber;

  1. Start by laying out the aluminium, ESP8266, and terminal block onto the back of the timber. Position everything so that it looks good and try see if you have any clashes or height issues before continuing.
  2. Next, measure and mark out where everything should go. I started by marking where the corners of the aluminium strips will be from the corners of the timber. On my drawing this is 20mm down and 50mm in from the side edges, centred about the middle. The ESP8266 and Terminal block I just placed near the centre as the absolute position does not matter, and then put a pen through their holes to mark.
  3. Next, I drilled the holes through the aluminium for mounting the it to the timber using a 7mm drill bit. The diameter of the hole must be bigger that the screw used but smaller than its head to allow it to fasten correctly. These holes do not have to be marked out or precise as you will not see them. I did this over a bin to catch the shavings. Note that after drilling you may have to debur the hole. Do this by getting a larger drill bit and by hand turn and apply medium pressure on the hole to remove the sharp edge on both sides.
  4. I then drilled the holes for the power and wall mounting as outlined in the drawing. Using the same method as above i then deburred the holes to remove the sharp edges. This is very important for the power cable hole!
  5. After deburring, align the aluminium back up with the markings from earlier and tape it down on either end. Here, use the same drill size as you did to go through the aluminium (7mm here) to mark the timber where your holes are.
  6. After marking, I used a 2.5mm drill bit with some tape on it 10mm up from the tip (as in the pictures) to drill where I just marked. The bit should be smaller than the threads on your wood screws, but not to small such that the timber will crack when driving them in. The tape is to stop you from over drilling the depth through the timber. These holes will now allow you to mount you aluminium strips to the timber with the wood screws.
  7. Take the wood screws and the correct driver for them and drive them into the timber through your aluminium. Use enough force to drive it flush but not to much to break anything.

Step 5: Adding the Terminal Block and ESP8266

Now the aluminium is mounted, we can move onto mounting the terminal block and ESP8266. Before mounting the ESP8266 I had to bend the legs out on the power, ground, and D1 pin. This was because I did not have a right angle header available to me at the time of making this. Whilst this is not an elegant solution, it does work and provide a secure connection to the ESP. To mount it and the terminal I took the following steps to do so;

  1. Where I had marked my holes, I took my 2,5mm drill bit and tape, and drilled down to the tape on one marked point of the ESP8266 and terminal block.
  2. I then took one of the M3 bolts, and using the correct driver, forcefully twisted it into the new hole. This taps out the hole with a M3 thread with a good amount of bite force such that the ESP8266 and terminal will not come off.
  3. Next I undid the M3 bolt and mounted the terminal and ESP with it through just the one hole. Using the 2.5mm drill bit and tape, I drilled another hole using the terminal or ESP as a guide. By using the actual part as a guide the holes will be precise and allow easy mounting.
  4. After drilling the second hole, I pushed another M3 bolt into it. This secured both the ESP and terminal so that I could drill out the remaining two holes and once again, push the M3 bolts into them.
  5. After drilling and taping these holes. Undo all of the screws to clean the area of wood chips and debris. This will also allow you to inspect you handy work on the holes.
  6. Next I mounted the terminal block. This was as easy as all the holes lined up perfectly. It should feel nice and solid in place, if not it will be hard to use a good force on the terminal screws later on for mounting the wires. So if need be, redo the mounting holes now using the same method and maybe a smaller drill bit if your holes are not to standard.
  7. To mount the ESP8266, you will need tighten each corner with a M3 bolt through a 12mm spacer. Before mounting it, if you are smarter than I and have a right angle header as I suggest in the materials section, now is the time to put these on. If you want to follow what I have done, you should bend the legs now. Doing up the M3 bolts and spacers will be a bit fiddly with all the bits and lining it up, but produces the best result.

Step 6: Sticking the LED's On

Please note that the WS2812b's and other addressable LED's have a data direction. This will be labelled on the strip usually as IN for the input and OUT for the output of the data signals. Before attaching or cutting any strips or cables, please check the orientation of your LED's. You will want to connect the data IN to the terminal block in this project.

Now that you have mounted all of the difficult and time consuming hardware. We can get going on how to stick the LED's on. To do so I took these steps;

  1. I started by cleaning the aluminium with some soapy water. This will remove dirt, grease, and shaving from the hardware store and drilling process. This is critical for the sticky backing to adhere well.
  2. After, I pushed the power cables for the LED's through the power hole and aligned the first LED as close to the hole as possible. Using some masking tape I stuck it down in this position.
  3. I then unwound the rest of the 3 meter roll and wrapped it around the aluminium in a test fit to see where I needed to cut it. Through this process I also taped it in various section to hold it in place.
  4. With the roll unwound, I also aligned it where I had even numbers of LED's on the top and bottom as well as the two sides. This will be important for you to know later on as we will need to set this up in the code. In the end, I had a perfect 30 on the top and 30 on the bottom as well as 3 on each side for a total of 66 LED's. These also fit perfectly since I used 1 meter strips of aluminium and and spacing of 100mm between the tops of the them.
  5. When you are satisfied with how your LED's are aligned, you can cut the strip off where you need it and undo the holding tape. Usually it is a good idea to cut across the little copper terminals. However in my case to fit the strip in happily I cut the strip across the black portion. This is okay in our case as we cannot add any more LED's to the strip later anyway.
  6. Now for the fun part, start to unpeel the sticky backing on the LED's starting at the first led where your power cables are and stick the first led down where you had it. Continue along the strip in this fashion until you are all the way around. For the sides where i had no aluminium for this I simply cut a little bit of the sticky cover and put it back on. This is not necessary but will stop things from sticking to it.

Step 7: Wiring It All Together

That's it for sticking the LED's on. From here we can start to wire everything up. The steps I took to do so were as follows;

  1. Take the end of the power cable for the LED's and chop it off at the correct length to connect it to the terminal. You can use anything to chop this, but a pair of kitchen scissors work fine. With the wire cut you can strip approx 10mm of the plastic off the end for mounting using the scissors as well.
  2. Take the new stripped wire and screw it into the terminal block. For my terminal block I used left for power, middle for data, and right for ground. Be sure to always double check these connections when making them.
  3. Next take three of your jumper cables and plug the female end onto the 5V, GND, and D1 of you ESP8266. For identification, I used red for power, black for ground and green for data, but choose any colours you would like.
  4. We can now screw the male end of the jumper wires into the other side of the terminal block matching exactly what the power, ground and data terminals for the LED's are.
  5. Next we can prepare the power supply. Depending on what one you bought this step may be different. But if it has come with a moulded end use this step. In the end all we want are the bare wires in the terminal block. So start by chopping the end of the wire off to expose the inner wires of the power supply. You can then strip the insulation back to expose the bare wires allowing you to connect them to the terminal block. This is sometimes easiest to do with a knife on double layer insulation, just be careful.
  6. Depending on what model of power supply you have purchased, it will either be easy or difficult to determined the polarity of the wires. Most of the time you can tell from the colours of the internal wires being black and red, other times it may be harder. In these circumstances its easy to check with a multi-meter, but for this Instructable to be simple, the easiest method I can suggest is to use an led to check which way it lights up. If you find yourself in a place where you do not have a multi-meter and it is hard to tell which wire is what, there is a great discussion here on what you can do.
  7. After you know which way around your power supply polarity is, you can push the cable through the power cable hole on the aluminium and connect it to the terminal block. This is on the same side as the LED's so simply unscrew the power and ground terminals and add the wire of the power supply onto it. Tighten these firmly so that the connection is a good as possible. Give it a little tug to make sure its in tight.
  8. At this stage it is good to test if you got everything connected the right way, so go ahead and power on the power supply. If nothing blows up you have it connected correctly. The lights will not do anything, but the ESP8266's little blue light will flash just briefly. If not its time to debug, first, check all of your connections are correct twice, make sure all wires are tightened down nicely and that the header haven't fallen off. If all of that is okay, you may have a dud somewhere.

Step 8: Programming Your ESP8266

NOTE: When connecting to your ESP8266 via USB, ALWAYS disconnect the 5V lead from the pin on board. Failure to do so will either cause the LED's will draw power from the ESP8266 and blow up your board (or worse your computer) or fight with your power supply also blowing up your board and power supply rendering them useless. Leave the grounds connected as everything needs to be referenced to the same ground.

Before we turn on the light after connecting everything together, we need to program our ESP8266. This will require you to connect to the ESP8266 via USB and upload some code from the Arduino IDE. At this stage please don't have your power supply on when connecting via USB as this might blow up your ESP8266. Programming will involve a couple of step as the code I have written for a the sketch contains a few external libraries we need to install for it to compile. This is not hard at all, and following these steps we can get the code uploaded to the board easy.

To program the ESP8266, I like to use the Arduino IDE as it is nice and simple to get going. If this is your first micro controller project, the Arduino IDE and ESP8266 is a great gateway into the fantastic world of IoT. For this Instructable, I will be keeping this section concise so that I am not repeating what is already available on the internet in much better quality than I can write. I have of course suggest links for when you may get stuck.

First off though you must have the Arduino IDE installed and know how to use its basics. I will not go into great detail here as the Arduino website and various other sources have amazing tutorials on how to use it. To download it look on their downloads page for the correct version for you operating system.

Once installed we can get to the nitty gritty, installing the ESP8266 boards and required libraries. To install the ESP8266 into the Arduino environment, head over its GitHub page and find the "Installing with boards manager" part of the readme. By following the 4 simple steps over there by pasting the link into the "Preferences" (under the file menu) of the Arduino IDE will add the ESP8266 as a supported platform. After pasting it in, reboot the IDE to finish the process. If you get stuck on this step be sure to check out other literature such as Sparkfun's tutorial on how to get the ESP8266 running on the Arduino IDE.

To keep things super simple for this project I have collected all the necessary files and libraries and that work for the sketch of this project over at My GitHub project page. To get everything all together, click on "clone or download", then the "download as .zip". This will get you everything from the GitHub page in a .zip package. Unzip this downloaded folder to anywhere you want so you can access the content, remember where you have done this.

Included in this .zip folder are all the external libraries under "External Libraries" folder and the sketch to upload under "Super Simple RGB WiFi Lamp" folder. Head into the "Super Simple RGB WiFi Lamp" folder and click any of the the .ino files in there. This will open the Arduino IDE with the sketch. If you try to compile this, it will complain that there are missing libraries that need to be installed.

The external libraries are zipped up in the folder "External Libraries" and have code that allow the sketch to run. Luckily the Arduino IDE has an easy way of installing any library so long as it is a .zip package. The Arduino website has a great guide on how to install libraries from zip file for your operating system. So if you are unsure of how to do it head over to this link and check it out. All you need to do is install all the libraries via this method and the sketch should be able to compile. To do so click on the little tick in the top left corner.

If your sketch compiles congrats! Your IDE is all set and ready to upload to the ESP8266. To do this we need to have selected the "NodeMCU v1.0" under the "tools->board" menu, but we also need to set one option. Under the tools menu where it says "flash size:" it might have "4M (no SPIFFS)". We need to change that to "4M (1MB SPIFFS)"to get the full functionality of the sketch. Once selected you also need to select your serial port to your board under the "port:" option under tools. Now, click the upload button (top left, arrow next to the tick) and wait for the sketch to upload. You should see the ESP8266 blink its little blue led a couple of times in upload. If all went well you should open the Serial Monitor under the tools menu again to see what the ESP8266 is saying. There should be a bunch of debug there for you to read.

Next we will tune your light to make sure it outputs the light correctly!

Step 9: Setting Up the Sketch

Now that you have your IDE working, allowing you to upload new sketches to your ESP8266 on your lamp, we can go ahead and tune it. This is so that we can map the LED's on your light to what the sketch expects to output for the various modes. We can also setup your WiFi on the sketch the way you would like and a few other small variables that we need to set.

The first variable, if you have purchased WS2812b leds, is the data pin. In this example we use D1 on the board which in software is pin 5. This is confusing and to do with the way the board is labelled vs the actual pin used on the chip. Be careful of this as it has caught me out multiple times. In the sketch this is set to 5, and I suggest you keep it there as other pins sometimes don't work.

#define DATA_PIN 5

Next, we need to know how many LED's are on the light. At this stage it is handy to count them out and number them around so you know which is what. We need to set how many we have in the code so the script can work off that amount. This is done with the NUM_LEDS variable;

#define NUM_LEDS 66

Since the ESP8266 needs to sync its clock to the real world, it uses NTP to collect the UTC time. UTC is the time in England and not helpful if you are elsewhere in the world. To change this i have add an offset variable you can set to your timezone offset. For me here on the eastern seaboard of Australia this is +10. For New York for example, this would be -5;

#define UTC_OFFSET +10

The next thing we need to do is map the LED's so the code knows which is where. If you have a look at the uploaded image, I have written what number each LED is around the back of my lamp. Since I now know what LED is where, I can type this into the code and let the script know which LED's it needs to turn on when. I have split the groups of LED's into 4 sections; top, bottom, left, and right.

int topLeds[] = {18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47};<br>int bottomLeds[] = {14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51};
int leftLeds[] = {48, 49, 50};
int rightLeds[] = {15, 16, 17};

These are basic arrays that need you to put in the LED's in correct order. The easiest way to do this is to work clockwise from one corner of the light entering the LED's into the correct arrays. Have a look at the uploaded image again and what comes with the script should show how to do this correctly. Take note that the bottom LED's start at 14, go down to 0, back up to 65 and back down to 51. This is because the end of the LED strip is actually in the middle of the light. By typing these in in the correct order allows the script to work correctly. If you get this wrong when you turn it on, remember you can type it in and try again!

The last thing to set up which is optional, are your WiFi credentials. If you set these up the device will attempt to connect to your WiFi network. I recommend doing this as it is the easiest way of getting connected to your network, or if you choose not to, the device will start its own WiFi network you can connect with your phone or laptop! By careful when entering these values as they are case sensitive to the name of your WiFi network. Failure to get the case right on each character will result in the device not connecting.

String SSID = "Your Wifi Network Name Here";
String Password = "Your Wifi Password Here";

If you have to re upload the sketch to the board, i suggest setting the "Erase Flash" setting under tools to "All Flash Contents". By doing this, the save file of the config will be deleted allowing for new data such as newly typed in SSID's and Password to be set and stored correctly.

If you have set up you sketch correctly its time to click upload. Go ahead and click the upload button and wait for the sketch to boot. The best way to check if the device is working is by opening the serial monitor in the Arduino IDE. Here you can see all of output the device is spitting out.

Step 10: First Light!

If all has gone correctly you should see the device say it is connected to your network. This should now tell you where you can find your device on the network with either an IP address or the mDNS name. The most reliable way to access the web page is through the IP address that the ESP8266 says its connected to. Just copy and paste the link from the serial monitor into a web browser.

If you decided not to put in your WiFi credentials in the last step, the device will start its own network you can connect to with your phone. Simply go into your WiFi settings on your phone and connect there. Then when promoted to sign in on Android or iPhone click that to open the web page. If you decided not to put in your WiFi credentials, and want to connect it to your network later, or if you want to change network, you can do this on the inbuilt website!

If you get a response from either method and the website loads fantastic, that's it! Hopefully after pressing a few things you get the same as what I show in the video. Only without the weird flickering I think due to the camera trying to adjust in the low light. Go ahead and play around with the inbuilt mode that I have programmed into the lamp. these include;

  • Straight Colour
  • Bell Curve
  • Rainbow
  • Clock
  • Night Rider

These are more detailed over on the projects GitHub page on how to use as well as how talk to the device itself if you are interested. Since it is a WebSocket server talking JSON, you can connect it with something like Node-Red really easily. If this is something you would like me to detail, let me know in the comments.

Thanks for reading, and even more if you gave this a go! I'm happy to keep support going for Modes and updates on the code when I can. But I'd love to hear what kinda of Modes you would like and maybe like to see implemented. Happy Making!

Indoor Lighting Contest

Second Prize in the
Indoor Lighting Contest

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    32 Discussions

    None
    bradlewis86

    Question 6 days ago

    Nice project man.. Supernoob here.. Just trying to great a super simple standalone lamp without logging into a current wifi system. Just log into the esp2866 and pick a color that sends it to the ws2812b led strip. I have used your code to the tee but it only stays connect for a couple of seconds. I have used all the the settings in your github. Every time I browse to the web page I get about 30 seconds of connection. It will say Mode: WS Closed!....

    6 answers
    None
    thebigpotatoebradlewis86

    Answer 5 days ago

    Sorry to hear this. I can say that the access point version of the website was very painful to program. This was due to the numerous ways that different devices attempt to access a webpage without internet connectivity. So depending on what device you are using, weather it be iOS, android, windows, etc. the actual request pattern going to the esp8266 changes.

    To help understand a bit better I need you to tell me how you are trying to access the webpage; wether its on a phone, which type of phone/computer, os. As much info as you can give.

    I can say that overall when I was playing with accessing the webpage via the softAP that android was the most useless, and actually required me to turn off mobile data to use the page. If you are using android I'd suggest trying this first.

    None
    bradlewis86thebigpotatoe

    Reply 4 days ago

    Awesome thanks for the response. So I originally uploaded the code and connected to it through my andriod device. The web page did not render and it was just hyperlinks. So then I opened it from my computer (windows 10). It renders the web page and everything looks great until you attempt to change a setting. I tried eliminating some of the code to keep the design as basic as possible. I just want a stand along webpage to go through a color pallet but cant figure it out.

    None
    thebigpotatoebradlewis86

    Reply 4 days ago

    The lack of styling on your android was just a lack of loading the bootstrap themeing without internet. This wont affect the functionality of the website, just the looks.

    As for using it from a windows device, you do need to wait for the websocket's to connect, this will be stated at the top of the page as to what state they are in. As you have not mentioned any new info i assume this may be the issue? You can also see what the webpage is trying to do by opening dev tools in chrome if you have it with F12.

    Removing code as well may lead to undesired results depending on what you have done. I have written it such that all the components play well together in the best possible way. But like you said, you have tried to make this simple as possible which is always better if you get it right.

    I am happy to help you get to the bottom of this, but i really will need more info on exactly how you are using the code if you can post an overview of any modifications to the code.

    None
    bradlewis86thebigpotatoe

    Reply 3 days ago

    Thanks for the response. I have not made any config changes to the code from your project. I simply followed the tutorial (which was great). Everything complied just like you said it would. The only issue is when I access through a any browser there is no usability. Every time I click it just states "WS connection closed". So I started over with just implementing a standalone server like https://randomnerdtutorials.com/esp8266-web-server/. That one worked fine on all browsers and held a steady connection.

    #include <ESP8266WiFi.h>
    #include <ESP8266WebServer.h>
    /* Put your SSID & Password */
    const char* ssid = "test"; // Enter SSID here
    const char* password = "test"; //Enter Password here
    /* Put IP Address details */
    IPAddress local_ip(192,168,1,1);
    IPAddress gateway(192,168,1,1);
    IPAddress subnet(255,255,255,0);
    ESP8266WebServer server(80);
    uint8_t LED1pin = D7;
    bool LED1status = LOW;
    uint8_t LED2pin = D6;
    bool LED2status = LOW;
    void setup() {
    Serial.begin(115200);
    pinMode(LED1pin, OUTPUT);
    pinMode(LED2pin, OUTPUT);
    WiFi.softAP(ssid, password);
    WiFi.softAPConfig(local_ip, gateway, subnet);
    delay(100);
    server.on("/", handle_OnConnect);
    server.on("/led1on", handle_led1on);
    server.on("/led1off", handle_led1off);
    server.on("/led2on", handle_led2on);
    server.on("/led2off", handle_led2off);
    server.onNotFound(handle_NotFound);
    server.begin();
    Serial.println("HTTP server started");
    }
    void loop() {
    server.handleClient();
    if(LED1status)
    {digitalWrite(LED1pin, HIGH);}
    else
    {digitalWrite(LED1pin, LOW);}
    if(LED2status)
    {digitalWrite(LED2pin, HIGH);}
    else
    {digitalWrite(LED2pin, LOW);}
    }
    void handle_OnConnect() {
    LED1status = LOW;
    LED2status = LOW;
    Serial.println("GPIO7 Status: OFF | GPIO6 Status: OFF");
    server.send(200, "text/html", SendHTML(LED1status,LED2status));
    }
    void handle_led1on() {
    LED1status = HIGH;
    Serial.println("GPIO7 Status: ON");
    server.send(200, "text/html", SendHTML(true,LED2status));
    }
    void handle_led1off() {
    LED1status = LOW;
    Serial.println("GPIO7 Status: OFF");
    server.send(200, "text/html", SendHTML(false,LED2status));
    }
    void handle_led2on() {
    LED2status = HIGH;
    Serial.println("GPIO6 Status: ON");
    server.send(200, "text/html", SendHTML(LED1status,true));
    }
    void handle_led2off() {
    LED2status = LOW;
    Serial.println("GPIO6 Status: OFF");
    server.send(200, "text/html", SendHTML(LED1status,false));
    }
    void handle_NotFound(){
    server.send(404, "text/plain", "Not found");
    }
    String SendHTML(uint8_t led1stat,uint8_t led2stat){
    String ptr = "<!DOCTYPE html> <html>\n";
    ptr +="<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n";
    ptr +="<title>LED Control</title>\n";
    ptr +="<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n";
    ptr +="body{margin-top: 50px;} h1 {color: #444444;margin: 50px auto 30px;} h3 {color: #444444;margin-bottom: 50px;}\n";
    ptr +=".button {display: block;width: 80px;background-color: #1abc9c;border: none;color: white;padding: 13px 30px;text-decoration: none;font-size: 25px;margin: 0px auto 35px;cursor: pointer;border-radius: 4px;}\n";
    ptr +=".button-on {background-color: #1abc9c;}\n";
    ptr +=".button-on:active {background-color: #16a085;}\n";
    ptr +=".button-off {background-color: #34495e;}\n";
    ptr +=".button-off:active {background-color: #2c3e50;}\n";
    ptr +="p {font-size: 14px;color: #888;margin-bottom: 10px;}\n";
    ptr +="</style>\n";
    ptr +="</head>\n";
    ptr +="<body>\n";
    ptr +="<h1>ESP8266 Web Server</h1>\n";
    ptr +="<h3>Using Access Point(AP) Mode</h3>\n";
    if(led1stat)
    {ptr +="<p>LED1 Status: ON</p><a class=\"button button-off\" href=\"/led1off\">OFF</a>\n";}
    else
    {ptr +="<p>LED1 Status: OFF</p><a class=\"button button-on\" href=\"/led1on\">ON</a>\n";}
    if(led2stat)
    {ptr +="<p>LED2 Status: ON</p><a class=\"button button-off\" href=\"/led2off\">OFF</a>\n";}
    else
    {ptr +="<p>LED2 Status: OFF</p><a class=\"button button-on\" href=\"/led2on\">ON</a>\n";}
    ptr +="</body>\n";
    ptr +="</html>\n";
    return ptr;
    }

    I would like to add the options from your code, like to be able to adjust the color but have the stability to just login and browse to the IP address. I think I am making this way more difficult then it should be but I am terrible at website design.. Any help is greatly appreciated

    None
    thebigpotatoebradlewis86

    Reply 2 days ago

    I went back over my code and had a look to see if I missed something and realized I had a bunch of website functionality (like jQuery and the color picker) coming from external sources. I was toying at one stage about keeping this on the device and so forgot that I left them as an external source. This means they will not load into the web page when using the ESP in soft AP mode since there is no internet connection. In order to use my web page, the external sources will need to be cached into your browser before use to have full functionality when using the softAP mode.

    What this means in simple speak is the softAP mode will not work unless you have visited the web page on your home WiFi before. This was an oversight on my behalf and I will look into possible remedies, but since I wanted the functionality and style you see in the regular station mode this is the way I decided to design the website, and I stand by it.

    The example you linked is fundamentally different to my design. It uses very simple HTTP requests between your browser and the ESP to serve updated static data (like how you would use PHP almost). Meaning there is no link between you and the ESP once the web page has loaded. Any click you make on that web page loads and new static web page to generate new data. This is very basic design and is very slow, but since it is so basic is much less error prone and easy to understand.

    My design on the other hand serves one generic static web page with some fancy libraries and uses a web-socket server to then send messages to and from the ESP and your browser. This design keeps a permanent link open between the ESP and the browser to allow sending very fast messages, which therefore allows fast and live updates on every programmed variable. This method also allows me to maintain and debug the advanced features on the web page much easier than the example code as I can use a proper HTML editor and debug suite.

    So at the end of this basic description of how the web page works, to help you possibly fix this you will need to visit the website first, either on mobile or laptop of your choice, then connect to the ESP access point. Luckily the web page is downloaded with the zip file from GitHub if you have cloned it from there. So simply open the Website.html file included in the top level folder, then connect to your esp8266 access point. If all goes well it should start working.

    I don't have an ESP near me now, so I will test this method when I get home, then look into some potential fixes as this will be critical for a few other future projects of mine, so I appreciate the feedback on this.

    As of today as well, I have uploaded a revision of the code which also aims at fixing a few other bits of web socket stability. So head on over to the GitHub page and download the code for the updates before trying what I state above.

    None
    bradlewis86thebigpotatoe

    Reply 18 hours ago

    Just complied it last night and it works like a charm!! Great job and thanks for the detailed correspondance. I am still working on a way to get a stand alone version for an adriod device with the same usabilty as the one you created but its going to take a lot more getting smart on my end. Thanks again

    None
    Yash2112

    8 days ago

    Hey there, everything goes as expected but after uploading sketch I couldn't operate via browser.
    There is nothing I couldn't do after upload the sketch.
    Please help me for finding issue.

    1 reply
    None
    thebigpotatoeYash2112

    Reply 7 days ago

    Ill need a little bit more information about what and how you are using this project to be able to truely help here. But ill start with a few simple things;

    If you manage to load the webpage, it will then need to connect via websockets. the status of the websockets is show at the top of the page as the mode if it is not connected. If it is connected, then it will show the current mode. The sockets do take some time to connect, so give it about 30 seconds, and if it does not connect then there is an issue.

    If you are connecting through the software access point, i did have some issues more so with android phones that laptops and iOS. Not sure why, but just did. Trying to balance all the other parts of the code with the softAP is hard to keep stable, again not sure why, but i would suggest connecting to your home wifi over the softAP for reliability.

    To help futher, ill need to know;
    - Have you made any modifications to the code
    - what device are you using to connect to the ESP8266
    - are you using teh softAP or connecting the ESP8266 to your home network
    - how many LED's are you trying to use

    Lets start with this, and see how you go

    None
    rojulec

    17 days ago

    Hi, This is a great project and I'm gradually obtaining the parts to give it a go.
    May I suggest a mode for the lights to react to sound or music? I reckon it would look good if you could get the brightness and the colours changing to the beat of music. Sort of like a musicolour from old times :-)
    Cheers, Ron, Hobart Tasmania.

    6 replies
    None
    rojulecthebigpotatoe

    Reply 11 days ago

    Wow! That looks excellent. I can't think of any particular features at the moment.
    I'm looking forward to my parts arriving so I can give it a go.
    Well done :-)

    None
    rojulecrojulec

    Reply 10 days ago

    I'm still waiting for the LED strip to arrive however the ESP's arrived today :-)
    I have successfully compiled and uploaded the code and verify that the web page works etc.
    I congratulate you on such a well worded and simple to follow instructions. It all went perfectly.

    None
    thebigpotatoerojulec

    Reply 9 days ago

    Awesome. That's good to hear. When you have the LED'S and hook them up be sure to come back here and share some pics

    None
    rojulecthebigpotatoe

    Reply 9 days ago

    Hi, I do have a question for you. You will see in the attached photo that our lounge wall is quite busy and there is not a lot of room for a board.
    Rather than moving stuff around, I was thinking of attaching a strip of corner moulding facing upwards near the top of the wall (see red line). I think the effect of the light shining off the roof will give a great effect.
    Off course, I will need to change the LED numbering around in your code to accommodate a straight line rather than a loop. I'm not sure how to deal with the left and right LED's in your code though.
    What is your opinion on this idea?
    I think this layout will be good for people who have pelmets over their curtains.
    I also have to work out how to attach the corner moulding to the wall.
    Cheers.

    lounge.jpgrounded corner.jpg
    None
    thebigpotatoerojulec

    Reply 16 days ago

    Glad you like it! I had the exact thoughts for the continuation of this project. Making a visualiser would compliment the whole design and make it more fun I think. The only issue is implementing a way of listening to sound. From what I have seen other achieve, this was either very complete or too basic, so I will have to do some research first.

    To let you know, I have be looking into doing this and have actually built a some visualisers based on the Arduino nano a couple of times, but I omitted from this instructable originally to keep this simple.

    However, I think I will be designing it in a sequel to this instructable of sorts with updated code. But what I want to do is again make it simple for people with no electronics experience to be able to easily make, modify, and use.

    So keep an eye out, as I will hopefully be designing this up soonish.

    None
    donvukovic

    15 days ago

    Love it and I have all the parts to build it, thanks.
    Also, whats the skyline out your window ?

    1 reply
    None
    thebigpotatoedonvukovic

    Reply 14 days ago

    Thanks! Let us know back here how yours turned out. Would be awesome to see some others. If you have any issues as well, feel free to comment here on on GitHub if its the code.

    ​My skyline in frame is Chatswood here in Sydney, and just to the left out of frame is the city.