Home automation over WiFi using WeMos ESP8266

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi today I will show you how to use the is P based microcontroller we most to control some LED lighting using your mobile phone my last video I have shown you how to use the ESP module as an arduino device since then many things have changed this we MOS d1 mini shown up they have already this serial programmer included and also some voltage regulation so the only thing you have to do is just to connect this to your PC program it and have some fun they are also very cheap I got this one for $2 60 so it's not worth to do all the other stuff just by a we mostly one and use it since I've also promised to show how to control some lighting using the ESP I will use this LED strip today this is one of the more expensive RGB LED strips but it's totally worth it it is based on the LEDs ws2812 be the FM control circuit integrated you have just to provide 5 volts and the data in which is chaining up all the LEDs you have to be careful where to connect the data in you have to connect it from this side and it's sending data to this side as a first step our show how to setup the IDE upload a sketch that's controlling this LEDs if you don't have installed it yet you need the arduino ide which is the development environment you go to arduino CC downloads and then choose the install all you need i have already installed it to be able to use the ESP with the arduino environment you have to add something in the preferences here so additional boss manager and you can add this URL you can find all links in the description below then you have to install the board you go to the bots manager type is B and this esp8266 by es b community is rolling up you just take the latest version and install it when it's finished you can choose your board from the list below here so we have we most D one mini so we select it and now we have to connect it the connected device shows up as a new serial port here I will select it with the install is P board you also get some examples down below here you get the blink program we will just upload it as you can see the LED is blinking so now we need a sketch to control the LEDs that we have since the other fruit neopixel devices are also based on ws2812 b we can use their library to control our strip but you need to install the library first you go to sketch and then include library and manage libraries then you just type neopixel here it is I've already installed it can just closed then if you have finished installing it and then load the example sketch here you find it under other fruit neopixel and then we want a strand test it shows up like this on the top you have the definition of the data pin that's controlling the LED strip it says 6 on other we know devices this works well but when you are using the WHMIS you have to be careful there because the mapping of the actual number and the data pin isn't that way you can see it on the website it states like d4 here but d4 is connected to GPIO 2 so the correct number would be 2 if we want to use d4 but you can also just type D for since my LED strip is 5 meters long I have 300 LEDs on it so I have to change the count as well like this now I can just upload the sketch finished let's connect the LED strip the USB port can provide enough current for this LED spread so I will connect this everything to my bench power supply I will also power the emos from this 5 volts we have 2 extra wires here but they are also connected to this connector here so I will connect ground first then the 5 volts there is a 5 volt pin here and then the data which is d4 I will turn on my bench power supply with the maximum current set and five volts as you can see it draws almost two times two amps so four amps in total that's really much but it looks gorgeous to use it more silently I will use this external 18 volts power supply and this DC converter I put this together myself let's follow it up this silence this is really much better now that we can take it to the next step to control it over Wi-Fi is a good starting point for our Wi-Fi sketch we can use example from esp8266 web server and we take the hello server that we have a simple web server implemented you need to enter the name of your Wi-Fi network here and the password here this example implements a basic web server that's running on the ESP and serving some pages over Wi-Fi the ESP needs to connect to your Wi-Fi so you have to enter the name of your Wi-Fi network here and the password here when the device is powered up it starts with the setup it's connecting to your access point and printing some information like the connection status and the IP to the serial port we can use the serial monitor to read it while it's connected to the PC the mdns would usually give USB a specific domain name like esp8266 here but this seems not to work with my router I would use the IP instead at the end of the setup there is specified what pages are served we have the root here which blinks the LED and displays a simple message then we have a simple inline example it shows how to write your code just in place and there is the response that's served when the page is not recognized this one is interesting because it also shows the argument that you are sending they are useful when we want to send some values like the pin number I will set my Wi-Fi credentials and then we can upload the example and test it I have opened a serial monitor and as you can see we got an IP and I am connected to my Wi-Fi network here most of the routers will try to give you the same IP every time if they are not you probably can configure it in the settings of your router but that's out of scope here now we can test if the server works I will try in line now this works as well you can also test handle not found when we typed something that's not recognized like on and add some parameters like pin 4 as you can see it says file not found and also it shows the arguments pin D 4 so this is what this function did now we have to add some code from the strain test to use the LED strip so let's see we need this line to include the library the pin the global strip this initialization I will put it to the end so it's only initialized when the server is running then I will replace in line by rainbow I need some functions like this one and this one and then we can call rainbow 20 here it will respond first and then run the rainbow cycle all put in the handle route simply the definition what's possible with this server let's try it I will check if the server is up and running yes and try rainbow doesn't it look great I love it I will get some more functionality to the sketch so we can also turn it off and dim up and down and so on afterwards we can set up the mobile phone to control it here is the device with the new sketch that I have implemented and we can use the mobile phone obviously you have to be connected to the same Wi-Fi then it's easy to use the browser you can see here on the root there are all the functions listed that you can use and some descriptions with the arguments that you can set and so on let's try our rainbow function here you can see there is some fading implemented so the current state is faded in we can also fade over like let's try the wave wave uses a one specified color you can also set in just one color like this or disable them like this now let's make it more convenient therefore we need an app it is also available for Apple devices it's called HTTP request widget this one now we can use it to create widgets on our screen I will create one here you it should be a wave that's faded over in five seconds and it's an orange like color call it way and then it's created also I'd end up in to turn it off like this now let's try and then turning it off easy the sketch is also capable of controlling the other things like writing PWM or just turning off and on this way we can also control amplifiers and relays so everything can be automated at you all and we'll put a link to the code and to the other stuff that you need the other subject you need in the description below second commence mode activated if you liked this video then share it subscribe to my channel and maybe support me on patreon I got to go you
Info
Channel: bitluni
Views: 652,917
Rating: undefined out of 5
Keywords: esp8266, home automation, microcontroller, maker, tinker, wifi, WS2812B, WS2812, http, app, smart phone, diy, lighting
Id: 7Dv70ci-MOw
Channel Id: undefined
Length: 15min 0sec (900 seconds)
Published: Sun Oct 02 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.