ESP8266 + Arduino + database - Control Anything from Anywhere

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today I have another easy but difficult project and I say easy and difficult at the same time because you have all the files that you need ready to download below this video so you only have to setup your device but if you want to make your own code from the beginning this might be a little bit tricky but I will try to explain the best that I can how this works I want to say thank you to Kevin Terra YouTube channel for teaching me so much about esp8266 I've learned how to do this with the help of his videos and I was able to make my own code and use the esp8266 connection so now I want to pass that knowledge to you guys so let's see what this setup will do here I have the Arduino mega connected to an esp8266 Wi-Fi module now here I have my smart phone with internet connection I enter my webpage and now I have this control setup I could control boolean indicators send numeric values up to 32,000 I can send text or I could receive values as boolean indicators or dimeric values once again so look when I press the third button for example the third LED connected to Merlino turns on but have in mind that this is not made with a local connection between my smart phone Wi-Fi and the esp8266 this is made via internet and the data will be saved to the database of my website so we could control this from anywhere in the world if you have an internet connection look now I disabled my Wi-Fi connection of my smart phone so now I'm using the 4G data with my mobile service but I'm still able to control the LEDs so imagine creating a setup in your home and be able to control that from anywhere in the world instead of the LEDs you could connect some relays and be able to control those from anywhere the possibilities for this are infinite with an IOT system but at the same time we could receive data so for example if I have a guest sensor connected to mared we know I can see that value on my website in case that we detect gas but you could add any other kind of sensor which can be a light sensor temperature humidity movement and so on and be able to see those values from anywhere so a security system for your home sounds interesting okay guys so let's see how to make this what will the coat do and what we need to create our IT system remember to subscribe and hit the notification bell and also a huge thank you to all my patrons so let's get started the PCP prototype enterprise gel CPCB is sponsoring this video get PCBs up to six layer for very low prices and also with fast delivery time you can also order the SMT stencil for SMD soldering and soon we'll also have the SMD assembly service as well upload your design and easily get five PCBs of any color for only $2 what's up my friends welcome back first let's see what this setup could do the first part for this is boolean control so turn on and off switches on my table I have five LEDs connected to the Arduino if I enable any of these on my website the ESP will get the data from the internet and turn on the LEDs but if you know how to program Arduino you could connect this signal not to just LEDs you could control relays alarms enable any other module connected to the Arduino and so on so imagine the possibilities as an example one idea of mine is to connect the ESP set up to the intercom button that opens the main door of my building in this way I don't need a key anymore just press a button on my smartphone and the door will open okay so the next part is to control a node values with numbers from negative 32,000 up to 32,000 because we are using integer values of 16 bits now I have the LEDs connected to some PWM pins of the Arduino I set the control number 1 to 10 so as you can see the first LED is now a little bit bright at the same time I'm also printing the value onto the LCD so we could better see the results now I set that value to 255 and the LED has maximum brightness now I set it back to 0 and the LED will turn off once again you could use these numbers to do any the process that you want increase the values for a temperature control send the data to display change the speed of a fan and so on okay guys so the third control line on my website is for text input you could place here any text up to 100 characters and send it to the database the ESP will grab the data and then you could do whatever you want with it as for example I type hello world and I press send I now get that text on my LCD and this is coming from the database pretty cool right okay so finally we have two more lines for receive data from the Arduino we could receive three boolean values and for adult values look now I have three switches connected to the Arduino all switches are turned off so the labels on my website are all inactive but now I turn on switch to after some time I can see that the second indicator is now green and active but instead of switches you could also connect some sensors with digital outputs and send that to the internet and be able to see the sensor values on your website the last part is the same but with analog values I now have some potentiometers connected to the analog input of the Arduino right now all these inputs are set to zero but now increase the first potentiometer and after some time the new data will be displayed on my website so if you know a little bit of PHP coding you could set an email each time that the values are over a certain limit imagine that you have a gas or a fire sensor and now the output is above 800 which means that gas was detected you want the website to send an email to you and inform you about that right anyway imagine all that you could do once we have the data on the database and you are able to grab that with the ESP so now let's make this we need two parts the part that goes to the website that is PHP code and the part for the Arduino I will use an Arduino mega it works with the Arduino Uno as well but the code is too big and ahead stability problems you need an esp8266 Wi-Fi module you need to create a website and a hosting service where you have the PHP files but don't worry there are a lot free hosting services as well this is how the setup will go in PHP you could send a link that already has the values that you need to send first we have to send our web page in this case electrolux comm then we send a directory which is the folder where you have the files then you have to send the name of the PHP file that will update the database and then you add the values so for example if I send this link and I add the question mark and the sensor equal to 33 in PHP we could detect the sensor world and grab the 33 value and then update the table with that value in the same way using PHP we could echo stuff for example if I write echo hello world in an empty PHP file each time that I refresh that website I'll get the hello world on my screen but instead of that we could echo something like this for example double slash 33 and the ESP module will receive that line and store it so all we have to do is to detect the double slash sign and store the value just after that which in this case is 33 so pretty much that's how we send the data and receive it from the server please read all the codes line by line in order to understand more and do that for the Arduino code but also for the PHP files okay guys so below you can download a zip file inside of that file you will have Kennard we know code and another folder called Novak's you have to upload the arduino code to the Arduino mega and then you have to paste the new bik's folder to the website directory so make these connections between the Arduino and esp8266 module make sure that you use the 3.3 volt supply okay now let's get a free hosting page and a website domain for that I usually use the zero zero zero web host com so go to that link and click free sign up now here you have to enter your valid email address and create a new password and then click the sign up button now you'll get the message that a confirmation mail was sent to you so check your mail inbox so open that mail click the confirmation link and confirm your email address once you are verified click the get start button you can skip the first two questions but then when you're asked to create on your website enter your website name in my case I want to call it new bik's you can use any other name that you want also create a password and click Next on the next page you have to select that you want to upload an existing website now this is our directory of the website that we have just made so we have to upload the files from the new exfol de right here but first we need to change a few things in the PHP files because you have to add your own data from your new website so first we open the database Connect PHP file I'm using Dreamweaver but you could use any other PHP notepad software as for example notepad plus plus in this file you have to add the server the username the password and the database of your website but for that we have to go back to the zero-zero-zero web host you have to login with the used mail and password before now you have to select the created website in my case is no mix and click manage site now you have to go to tools and select the database manager and let's create a new database click new database give a name a username and a password mine will be esp8266 no one has a username and my password now you have to click manage and select PHP myadmin that will open a new page and now we have to create a new table in order to store our data but don't worry you also have that in the downloaded zip file so for that you first have to select the database now go and select import click select file and go to the knoblauch's folder you have just downloaded and select the ESP table to file click continue and the new table will be inserted now if you click this table you can see that we have all the values for our website the ID the password and the same numbers and so on ok so now we have to copy the database information and place the names on the PHP file before the server in this case is localhost the user will be this one the database is this one and use the password that you have ok so now you could upload for files to your website for that you have to go to zero zero zero web host and click file manager now click upload files click the upload button and select the for PHP files now if you go to your website settings in general and copy your website link you should have the same tables that I do on my website and you could change the data ok so finally go back to the PHP my admin page and change your ID and password if you want this must have a maximum of 5 characters I click change and in the ID tab I add five nines and the password will be one two three four five as an example this must be only numerical values now click continue and it's time to see the Arduino code when you open this code you will see a lot of separated Ino files open the main esp8266 file first you have the variables that you need to change you have to add your Wi-Fi name and the password of your internet router then you must add your host in this example that will be new Bicks that's zero zero zero web host comm and in your case this will be the name you selected now you have to add the ID that you have used for the database for my example that is five nines and the password of one two three four five read the comments for more details now you have to go to the ESP connection file and you have to place your domain here as well in my case is this one and remember to add the triple W in this case upload a code to the Arduino mega connect the ESP the LEDs and the potentiometer as in the schematic and test if it works now you should be able to turn on the LEDs and get a sensor data in the code these are all the data that you can use the received boolean values the send boolean values the numbers and so on please read all the comments in the code because this is a very long code so this is how you can make your own Internet of Things set up and control stuff from anywhere in the world just with a push of a button if you need more information read all the comments or ask a question below you have the schematic and the zip file below ready to download in that zip file once again you'll find the PHP files and the Arduino code you also have another Arduino code that will be for an Arduino Uno but this will send and receive only one number otherwise the code is too long and we'll get stability problems if you like this video and you have learned something new click the like button and subscribe and also consider supporting me on patreon so thanks again and see you later guys [Music]
Info
Channel: Electronoobs
Views: 418,498
Rating: undefined out of 5
Keywords: ESP8266, IOT, Arduino, database, mysql, webhost, host, control, App, internet, wifi, world, website, free, mobile, php, mail, notification
Id: 6hpIjx8d15s
Channel Id: undefined
Length: 13min 51sec (831 seconds)
Published: Sun Aug 04 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.