ESP32 Tutorial 52 - WS2812 CheerLights MQTT Global Sync with LCD | SunFounder ESP32 IoT kit

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hi. welcome to internet of thing tutorial from  Robojax in this video we are going to have a   CheerLights which gets updated using MQTT from the  internet and this will change simultaneously with   a lot of other people across the world the color  changes so we feel that we are connected and we   are not alone and also I will display the color  that is shown and number of times for example if   you sleep over time and when you're connected  to Wi-Fi you will see the signal here esp32   starter kit from SunFounder this is the best  esp32 learning kit from SunFounder it has this   esp32 microcontroller which has built-in Wi-Fi and  Bluetooth this board can do everything Arduino Uno   can do or many other Arduinos can do plus extra  more features because we have white Wi-Fi and   Bluetooth the possibilities are endless you can  get connected to the cloud or do the control or   read information or values via your mobile device  or your desktop or over the cloud from a far location it comes with a camera extension  kit where you can stream the video over   Wi-Fi either through the cloud or to your  network and also it comes with micro SD   card where you can save images on the micro  SD card or you can write from the device any   information log the information on the device  and read it back you can power the board using   this included 18650 lithium battery and it has  built-in charger where you can connect micro USB   and charge the battery the kit comes with 320  pieces of component that you can learn tons of projects we had an introduction video on this  RGB LED please watch that because I'm not going   to explain how this works the link will be below  this video then we had a video uh introduced how   to use this LCD screen you can watch that as  well and then we had a video on Cheer lights   which we just used it without LCD please  watch that video so this will be very easy   to understand introduce this cheer lights where  this is connected using MQTT where we subscribe   to a feet and a lot of other people have sub have  subscribed and everybody will see the same color   so you can put this somewhere in your room and  when other people or yourself change the color   the color of all other users will change so you  feel connected and it will cheer you up in this   video I've added this LCD where we will see  the color that is displayed and also it shows   how many times it has been uh replaced let's  say when you leave it or when you sleep you   wake up in the morning and you see how many  people have changed it and also when you are   connected it shows that you are connected and  if I disconnect the internet right now I turned   off the Wi-Fi and it takes few seconds and it  will show that the uh internet is not connected   and it says connecting and it shows the SSID  for your Wi-Fi this is very good uh example   of MQTT and also internet of thing with esp32  so you will learn a lot of principle in this   video when I when I now one when I connected  back the Wi-Fi it takes few seconds to get connected and we got connected back you need  to log in and subscribe I'm going to show   you to this cheer lights group on Discord  the color can be changed from the Discord   cheer lights group you will log in here and  you just type and you can just type forward   slash cheer lights and enter and you will  get the options to select or see the color   for example if I click it will read the  color that everybody sees which is red   at the moment and if you want to change  the color simply we click and the color   option is displayed and you can select for  example orange and the color is now change to Orange come to this page docs.sunFounder.com  scroll down until you see esp32 then click on   esp32 starter kit main on the left side click on  Arduino user scroll down until you see 8.5 five   Cheer lights now to join the Cheer LED Community  uh I'm if I click this it will just open it directly so we will we will go to this page uh  to this group it's called cheer light and here   we can click here to join and that's the link let  me right click and copy here right click paste and go and here you can join and type a display  name and login there are some information   here on this page there is there is some  information on this page but the rest is   referring to this uh LED strip and it shows it  asks you to install this to uh Library which   I'm going to show you and here is the code and  the explanation of the code and how to use the Discord when you use esp32 with s Founders  esp32 camera extension module like this it   comes also with battery on the package and it  comes a built-in charger so you can connect it   and charge it and disconnect and later on you  can use it with a lot of power so you can power   up your application very easily and now this is  the wiring for WS2812 we are connecting pen one   to the ground and VCC to 5 volts the red and uh  black and then the yellow or data to pen 14 as   it's shown here let me show you here so we have  three wires the red is connected to 5 volts black   is connected to the ground you can also connect  it here I've left this 5 volts for LCD and then   the yellow is connected to P4 as it mentioned  here and this is the wiring for the LCD now for   the LCD we are connecting four wires from the  top that's ground, ground is connected to the   ground this ground is connected to the ground  the second pen is ground and then we have VCC   in my case it's white is connected to 5 volts  you can connect it in here the first pin is 5   volts when the USB is facing this way and then  the third pen is SDA which is gray to pen 21 and   here I've connected to pen 21 and the last pen  is SC it will be connected to pen 22 and Pen 22   is in here second pen from the bottom you can  also connect it to the these terminals if you wish now let's have a look at the  code I've used the code that was here file sketch scroll down iot CheerLights this was the main code and I've changed it and I've added that  display and I've written code for you so it   can display a lot of other information and this is  for the LCD screen initializing L CD screen this   is to display that this is the icon that shows  we are connected to the internet and I've used   a tool here to generate it I use this tool where  you can click and draw anything that you want for   example like this or maybe just clear and any  shape or thing that you want to do you can just   generate yours and this will be the code if you  want it in binary I use binary and just copy this   portion and run it I'll provide you the link for  this this this portion was original code from Cher   app and then you enter your SSID as I mentioned  it multiple time if your SSID has capital D and   if you write it like small D it will not work make  sure to write it exactly as it is and this is for   the password this is the MQTT server uh and then  this is a unique identifier that you're connecting   the rest of the code is exactly the same these  are the available color for us and available   color also has values these values each correspond  to the value that uh that are there so we have 12   colors and this is pen P 13 is for LED and number  of LEDs we have eight you can have more if you want we need to install this library and we need  to install this Library uh for both of these we   so we need to install this Library double click  select it right click copy it go to library right   click here and paste it and the first one is  PubSubClient by Nick Oli and it is installed   in your case it will be the install button will  be in here and click to install it for the new   pixel the same way add a fruit right click and  copy it and come here right click and paste it   and so until scroll down until you see new fruit  Ada fruit new pixel 8 by Ada fruit it's installed   you will see the install button something like  this click and install it then we will need to   install this Liquid Crystal LCD I've already  shown full details of it right click here paste   it and you will see that it shows LiquidCrystal  by Frank D Bar bender and it is installed so   you must watch the video related for each so  you can successfully run this project and in   here we have the address for the I Square C you  please watch that video how to get that address   16 mean 16 characters and two mean two lines and  that is referring to the number of characters 16   and two lines one two colors inside the setup  we initialize the CD and backlight and this is   a Wi-Fi setup this Wi-Fi setup LCD connect which  is at the bottom of the code that I have written and and inside the set color we have two variables  one is the last color so we remember it and   also the counter these two variables are inside  the set color LCD connect is this function that   I've have written so first we clear the screen we  set the cursor at line zero character Zero and we   print the word connecting and then go to the next  line and we print the text SSID and the actual SS   ID inside the loop we clear the screen and this  portion was already there I just added else uh   if it is connected then we print this uh connected  character which we shown at the top of the code at   character 15 line zero so character so character  15 line Z is here line 0er and character 0 1 2 3 15 and then we write that character  first we create it and then we write   it using write and bite zero  and then this is a client Loop   for the MQTT and then we print this  text on the screen character Z line Z so this is printing character Z  line zero the word color and then   gets the color so the word color and then gets the color character Z line one this was  character 0 line Z character 0 line one   so we jump to the second line and we put  the word changed and then color count so   this was a variable that we are holding it's  one and then we put the word times will move   automatically if if this number reaches  99 and it becomes 100 so this could move   and the loop comes at the end and it will  repeat it will repeat everything all over again now let's see how we can select the esp32  board we can click here under the select board and   type here esp32 de as soon as you type Dev you  will see Dev board you can select it and click   okay so the board have been selected now we have  to select the port the other way to select the   board is Click On Tools board esp32 and select  the esp32 dev module now we have to select the   port if I click here it shows two port and I don't  know which one belongs to my device sometimes you   will see you will not see the number properly  so the best way to be sure the right click on   the start menu go to the device manager and you  will see here the ports if I click on this Arrow   it will show me the ports is USB serial ch340  when the other is USB serial device and here   now it's connected if I disconnect this one of  them disappear the one that disappeared is my board so six stays and it disappeared if I connect it so it is my comport ch340 now it is my  comport and I can select it or I can click   on tool port and here you will see it you can  select whichever you want hours is come it now   we have successfully selected the board and the  port and this is very important it must be done first and here's the demonstration that  the the board have been connected to the   internet as you can see we are connected and  here we can see that the color is displayed   and this icon shows that we are connected to the  internet so far from the time that I turned this   on seven times it has been changed and  this is the color at the moment purple and let me show you and I disconnected from  the internet so there are two ways one is   when the when it was initially connected and gets  disconnected we will see that it say connecting   and it shows the SSID this is taking like about  10 seconds that it goes and checks that connection and it says now connecting and then SSID D this is  my Wi-Fi for this tutorial and this will continue   until it's connected now if I get I'm connecting  back the internet connection to my router now it   and if the color is changed since again still  the color is purple and we got connected there   is another option that when I disconnect it and  reboot it let's say it was turned off when you   turn it on you just see this at the beginning  connecting and this is the SSID so you know   that which wi-fi this is connecting in case if  you have multiple router and now if I connect   the the router to the internet we will see that  connection happens and this my esp32 pulls up the   MQTT feed data and we'll turn on this accordingly  so now it shows purple and then one time it has   changed so this is the first time and bar graph  also shows this icon also shows that we are connected
Info
Channel: Robojax
Views: 896
Rating: undefined out of 5
Keywords: robojax, sun, founder, sunfounder, course, tutorial, kit, learn, learning, step by step, esp32, arduino, iot, wifi, cheelights, cheer, lights, ws2812, led, extension, mqtt, LCD, connect, count, @CheerLights, PubSubClient, Adafruit_NeoPixel
Id: xEqmxMiF-E8
Channel Id: undefined
Length: 18min 46sec (1126 seconds)
Published: Sun Dec 31 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.