Control: LED Strip Control Software Windows
LED Strip Control
Software Windows:
Hey guys Matt here from MKSmartHouse.com and in this video I am going to show you how to setup the software for the LED Strip Control using Windows.
So in the last video we left off with the LED Strip Control Device being fully built so all it needs is firmware and to be connected to the home automation server. Many of you have been asking what to do if you were to connect more than 1 of any of my devices. So in this video I am going to show you how to connect 2 LED Strips to openhab, you can repeat the steps for the second one to add even 20 LED Strips.
So let's start off with the firmware. I recommend having my website open up so that way you have all the steps and commands ready, and so you do not have to type in everything you can just copy and paste. I know this is the software video but, there are some hardware things that we need besides a computer. We are going to need an arduino of some kind preferably a UNO or a MEGA equivalent with its usb cable of course and male to male dupont jumper cables. Links to these items will be in the description or on the website. On my website you will also find my shop where you can find the kit, and pcb to make this device.
1. The first thing we are going to do is grab the arduino and put a jumper cable from RES to GND.
2. Then grab the LED Strip Control and connect all the pins to their corresponding spots so, TX to TX, RX to RX, GND to GND, and 3.3V to 3.3V.
Before we continue, check to make sure the 2 pin jumper is above PGM. Please note that in this video I will not go over how to setup the arduino IDE and will assume that it is set up and you know how to connect an arduino to it. If you do not know how to set it up or it is not setup then go check out my Door sensor software video where I go in detail of the entire process.
Recently people have been telling me that they cannot compile the arduino code I have written. That is because your Arduino IDE is not setup, so if you are having this issue please go watch my door sensor software video I show exactly how to set it up.
3. Next we are going to head over to my site, the link is in the description to the exact page and press the download LED Strip Control Firmware.
4. On the new page press download.Then go to your file explorer and downloads folder and double click on MK-LEDStripControl.ino. A pop up will come up asking if you want to put it in a folder, click OK. It should bring up the code for the LED Strip Control, and there are only a few things we have to change.
5. The first thing is the wifi settings which are the ssid and password so change those according to your network. Please keep in mind that the esp8266 only works on 2.4ghz so type in your 2.4ghz wifi ssid and password not your 5ghz. Also when adding the information only change what is inside the quotation marks.
6. Next set of parameters are the Web Updater settings. The devices I designed are great because I implemented a web user interface for each individual device so that way if you ever have to flash new firmware you just go to its web address. The web address information is found at that top of the code in the giant comment block.
7. The first parameter is the hostname of the device, usually I only change the last digit but since this is the first LED Strip Control I will keep it as it is.
8. Next is the update path and personally I don’t change that. After that is the web user interface username and password, these are the credentials you use to access the webpage because each device is protected.
9. The next set of parameters are for mqtt. The first one is the subscribeTopic and this is the topic for which the device listens for commands or messages from the server.
10. The next one is the MQTT Server Ip address and this is simply the IP address of your home automation or openhab server.
11. The last one is the Unique device ID and this simply differentiates each device on the MQTT side, I usually just change the last digit for every single device. That is it the code is ready to be flashed.
12. So go to tools and make sure the Board: is Generic ESP8266 Module and the port is COM and a number. Once those are good press the upload button, it is the one with an arrow pointing to the right. When it is uploading you should see dots moving at the bottom and some percents. After it is done uploading you should see it say 100% and Done uploading.
13. Great now unplug the Arduino and the dupont wires from the first LED Strip and make sure the jumper is over PGM on the second LED Strip and connect the dupont wires to their corresponding spots.
14. Now let's make some changes for the second LED Strip so connect the arduino again. First change the number in the host from a 1 to a 2. Second in the subscribe topic change the 1 to a 2. Lastly, increment the device ID.
15. Now upload the code the same way you did the first one. Once it finished uploading unplug the arduino as well as the dupont wires.
16. Then move the jumpers on each device to run. Let’s Test them!
17. Take the power adapters and plug the devices into the wall. To confirm that it flashed correctly and is working you can fire up MQTT.fx, connect to the server and in the subscribe section type in # and press subscribe.
If you do not have MQTT.fx then check out my Home Automation Server Setup Guide.
18. Then click on the publish tab.
19. In the topic bar type in the subscribeTopic that we wrote in the first LED Strip Control device code that we flashed.
20. Next in the message box type in 100;100;100; and press publish. The LED Strip should have changed color.
21. In the topic bar type in the subscribeTopic that we wrote in the second LED Strip control and press publish. This LED Strip should have also changed color.
22. Now the devices are complete and just need to be added to OpenHAB. So ssh into your pi or whatever your server may be. The first thing we are going to do is create the LED Strip Control items.
23. So type in
sudo nano /etc/openhab2/items/home.items and press enter, you may need to type in admin password.
24. Then go to the bottom of the file and type in
//LED Strip Control
Group MKLEDStripControl1Group "Desk LED Strip" (All)
Color MKLEDStripControl1Color "Desk LED Strip" <colorpicker> (MKLEDStripControl1Group)
String MKLEDStripControl1String (MKLEDStripControl1Group) {mqtt=">[broker:MK-SmartHouse/lights/MK-LEDStrip1:command:*:default]"}
Group MKLEDStripControl2Group "Cubes LED Strip" (All)
Color MKLEDStripControl2Color "Cubes LED Strip" <colorpicker> (MKLEDStripControl2Group)
String MKLEDStripControl2String (MKLEDStripControl2Group) {mqtt=">[broker:MK-SmartHouse/lights/MK-LEDStrip2:command:*:default]"}
And press enter.
Now let me go over the items we created. They will allow us to control the LED Strip Controls. Each LED Strip has 3 Items that go along with it. The first item is a group item and what this does is group all the items for the LED Strip so they are together. The next item is a color item and it is the item that deals with your interaction with the user interface, this is the item we will use in the sitemap file. The last item is a string item and this is the item where the MQTT command will be sent to, as you can see the subscribeTopic is at the end. Thats it for the items file.
25. Now press control x then y and enter. Next up is the sitemap file so we can control the device.
26. Type in sudo nano /etc/openhab2/sitemaps/home.sitemap and press enter. It will bring up the sitemap. If you are following along with my series then we have many different frames in our sitemap. I am going to put the device in the frame called MK-Room. So go to the frame and type in:
Colorpicker item=MKLEDStripControl1Color
Colorpicker item=MKLEDStripControl2Color
and press enter, what we did is import the item into the sitemap so we can control it from the user interface in the form of a color picker.
27. Now press control x then y and enter. There is one more thing we have to do and that is make a rule where it will convert the color picker into MQTT the device can understand.
28. In ssh type in sudo nano /etc/openhab2/rules/home.rules and press enter. At the top of the file type in
var HSBType hsbValue
var int redValue
var int greenValue
var int blueValue
var String RGBvalues
These are the variables the rules will be manipulating. In the bottom of the file type in:
rule "MKLEDStripControl1"
when
Item MKLEDStripControl1Color changed
then
hsbValue = MKLEDStripControl1Color.state as HSBType
redValue = hsbValue.red.intValue
greenValue = hsbValue.green.intValue
blueValue = hsbValue.blue.intValue
RGBvalues= redValue.toString + ";" + greenValue.toString + ";" + blueValue.toString + ";"
sendCommand(MKLEDStripControl1String, RGBvalues)
logInfo("MKLEDStripControl1Color", RGBvalues )
end
rule "MKLEDStripControl2"
when
Item MKLEDStripControl2Color changed
then
hsbValue = MKLEDStripControl2Color.state as HSBType
redValue = hsbValue.red.intValue
greenValue = hsbValue.green.intValue
blueValue = hsbValue.blue.intValue
RGBvalues= redValue.toString + ";" + greenValue.toString + ";" + blueValue.toString + ";"
sendCommand(MKLEDStripControl2String, RGBvalues)
logInfo("MKLEDStripControl2Color", RGBvalues )
end
What these rules do is take the values from the colorpicker and send them through MQTT.
29. Great! Now press control x then y and enter.
Before we go any further let's confirm that everything works so go to your web user interface and then Basic UI. You should see the LED Strip Control items. If you press the UP button it turns the LED strip on, If you press the DOWN button it turns the LED Strip off, and if you press the circle it brings up a color picker and you can choose any color you want. That is it! The software is complete, now all we have to do is install the device in its final place which will be completed in the next final installation video. Alright thank you for watching and If you have any questions leave them in the comments section below or head over to mksmarthouse.com/forum. Good Bye!