lørdag 7. april 2018

RGB Sword - IoT Smart Lamp Controller

Introduction

This will be the information page for the RGB Sword - Smart ESP8266 Controller app. The page will constantly be updated to add new and relevant information, about both the application itself and the whole project the app is connected to.

So the basics are: First download this app which connects to your WiFi. You now have the ability to send control signals to a WiFi enabled micro controller. This will in turn act on the information you just sent! While there are many  projects that does exactly this and something similar. This solution is meant to be easy for beginners and more experienced hobbyist to get immediate results. You follow this guide on parts and circuitry, I provide the finished micro controller code. And before you know it you've got a sweet taste of the smart home of the future!
    I'm using it to control the color and intensity of an RGB LED strip.

Here you can see the results after I installed the RGB LED strip in my brothers room.

Let's get started!


The arduino is connected to the internet using an inexpensive WiFi module, the ESP8266. To make everything even easier I've provide links to a product named NodeMCU. This is both an arduino compatible micro controller and ESP8266 chip in one solder friendly package.
After uploading the code I've provided on this page the arduino will start to listen for incoming requests. The arduino acts as its own server and thus we can direct traffic to it like any other server on the internet! It can receive requests from any browser like device, and most importantly, from your new application.
    What happens behind the scenes when you push a button is a new HTTP client is started. This sends a good old GET request to the arduino/nodeMCU. This request contains the information about color values. After the information is received, the arduino responds with an all clear signal before setting the light values to what you just sent.


You can choose between five different pre-set colors as well as choose your very own custom color by using three sliders. This means you can choose between 16.581.375 different colors! There's also a neat function that slowly and softly fades between all available colors. Absolutely perfect as an ambient light!

Click here to download the app and get started.

Parts and Tools

You are going to need the following parts for the smart lam

To put everything together you will need these tools
  • Soldering iron
  • Solder
  • Wire cutters
  • Wire strippers
  • USB cable that goes between your computer and micro controller

Circuit 



The schematic is all made in the gerber files. Which you can download here.



Arduino Code

You can download the arduino code by clicking here. if you don't already have the arduino IDE installed you can find it by going here.

After everything is downloaded and you have opened the code perform an ipconfig on your computer. This is how to do it if you're on a Windows PC: Open the start menu. Type cmd and press enter. In this window type in ipconfig and press enter. Note the information from the image below.

Green text on black background. That's how you know I'm a real hacker.

Now you can enter this information into the arduino code and make it your own. Write the Subnet Mask on line 10 and the Default Gateway on line 9. Look at the IPv4 Address and modify the last number (in my case 4) to a free address on your network (I chose 63). Write this new IP address on line 8 in the arduino code.
    You can verify that the address is free by typing this in your command window ping 192.168.0.63. Where you substitute with your free address. If you don't get a reply or the reply is that the destination host is unreachable, that means the address is free and you can use it for your micro controller.

Now you're almost ready to upload the code. Just make sure you've installed the ESP8266 library. Sparkfun has a terrific guide on doing just that which you can find here. Now you're finally ready to connect the nodeMCU to your computer with an USB cable and push UPLOAD in the arduino IDE!

Troubleshooting

If you've soldered the circuit, uploaded the code, and downloaded the app - congratulations! Now if it has previously worked, but suddenly stopped lets look trough a few common problems, and how to solve them.
  • Make sure WiFi is turned on
  • Double check the IP address saved in the settings page in the application is the same as the IP address you've given to the arduino
  • Connect the phone to the same network as the arduino. The ESP8266 can only connect to 2.4GHz networks. However it still works if your phone is on the corresponding 5GHz network. So that shouldn't be a problem.
  • If you get a error message in the app that says Connection refused this means the static IP you've given to the arduino is already taken. Upload your code with a new, and available, IP address.

Further Development

So this is the current state of the development of both the application and arduino code. However it's always under development. I have a lot of ideas and I plan of rolling these out gradually when I implement them. This page will be updated whenever there are significant changes to the functionality.

If you do some cool changes to the arduino code, or have requests for new features, be sure and let me know at sverd.industries@gmail.com

So here's what's in the pipeline and what I really want to add.
Notification control
I plan on adding the ability for the app to see other applications incoming notifications. It would be really cool if the LED strip gave a quick flash whenever you got a new notification. And it would be cooler still to match the RGB LED color to that of the incoming notification! This is in development.