How to Use 16x2 i2C LCD Display With ESP32 | With Program Explanation

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so in this video I am going to show you how you can use an LCD display so this is a simple 16 by 2 LCD display and what basically mean by 16 by 2 is that it can display 16 characters in a single line and it can print total of two lines which will consist of 16 characters each pretty simple project you can easily do it and there are not many applications with esp32 and the LCD display but still it is pretty nice to see how it functions basically it is the same as the Arduino code so you don't need to change anything like that all you have to do is just change the pins which I will tell you in the video so let me just power it around see how it performs so once I power on you can see we can print the text here and then we can print any number at the bottom there as you can see so it can be anything of your liking right now I have set it to 500 milliseconds so every 500 milliseconds or half a second it updates the counter river which can go I mean can go as far as I want I mean till the till it ran out of space or whatever so without wasting time let's get started so for this project obviously we will need our esp32 board and as you can see I have done some modification to it by soldering an external engine output but this really doesn't affect your project if you don't have this antenna then don't worry it will just work fine as it is and then obviously we will need our LCD display and as you can see I have an i2c board right at the top over here so if you don't have this then the connections between the two devices will be a very difficult job to do so that's why I recommend I highly recommend you get an i2c board just like this one so you can just type in i2c board for LCD display and right away will get this board so this just makes the connection a lot easier between the esp32 and the LCD display by just four pins and out of those four pins two are for power and obviously to connect them all we will need some jumper wires so now let's connect them so first up and the i2c boot you can see we have VCC ground SDA and scl so obviously ground and VCC our power supply so we will connect the ground to the ground on the esp32 board which is right over here the second pin as you can see then we will connect the VCC which will be plus 5 volts or it could be 3.3 volts but sometimes that is not enough to power up the LCD display so we'll connect the VCC to the v in pin on the esp82 board which is right next to the ground as you can see now we will connect the third pin which is SDA as you can see it is quite nicely labeled so the SDA pin will be connected to the gpio pin number 21 on the esp32 board which is on the other side so this is the one as you can see it is fifth from the right side so we'll connect it there and then the final pin which is the scl that will be connected to the gpio pin number 22 which is right up to the TX and RX pin so the second last pin as you can see over here just like so so that's all for the connection between the ESP credit report and the LCD now all you have to do is just upload our code and get it working so let's head over to our computer and program it okay so before we do anything further first we need to make sure that our Arduino IDE is capable of programming the esp32 board so first of all what you have to do is just copy this link I have given it in the description then what you have to do is just go to files then click on preferences so here you will find the additional board manager URL and you have to paste your link here just like so I have done over here but let's say if you have a additional link then you can just place an comma and then paste the link so as you can see I have put a comma right over here so this is my esp8266 package that I have installed previously and then I put a comma then pasted the link for the esp32 package so after that you can just go ahead and click on OK then head over to tools and go to the boards and select the board managers so this little window will open up and it will update the boards manager so on the search bar on the top you have to type in esp32 so this will show up and all you have to do is just click on the install button as you can see I have already installed it so that's why I'm not getting the install option but it will just show up right here so once that's installed you can go ahead and close it and restart your Arduino IDE so at first we need to upload this code and what this code basically does is it gives us the i2c address of the LCD and this is very crucial of course because without the address we won't be able to send data to the LC display but if you don't want to do that then I will just write here two codes which is zero small x 2 7 and 0 X 3 and capital F so your address could be one of these two addresses so just trial and error it and get your particular address but if they don't both work then you might be having some different address so just make sure that you run this code first and get your i2c address for mine I think it is 0 x 3F so anyways I will just upload this code and check for myself so just select your right board and com Port it is always selected esp32 and the com port 5. so all you have to do is just click on upload and it will obviously compile the sketch and upload the code to the board and after a very long time it says finally done uploading and uh basically the Arduino IDE is not designed for esp32 boards that's why it takes a very long time to upload and compile the code now you can go ahead and just press this button over here which will open up the serial monitor and then here you can see we have found our address which is 0x3f and you need to remember that for your next code so you can go ahead and click on close so here's the code that we'll upload and as you can see I have installed this Library which is the liquid Crystal i2c library and you can find this library in my GitHub link below so all you have to do is just go to sketch and then click on include library and then click on ADD zip library and just navigate to where you have downloaded your zip library then here we defined an instance of it so we name it LCD and we put in our address which is 0x3 from earlier and the resolution of the display which is 16 by 2. so in total we have 16 columns and two rows then in the setup function we initialize the LCD and the backlit function of it so the backlit actually lights up and then we set it to clear so if any previous thing was written on the LCD it should be wiped out with this function then in the loop function we will set our cursor to 0 0 and basically what happens is in coding you don't start with one you always start with zero so if we have 16 columns then we'll start from 0 and then we will go to 1 2 3 4 and all the way to 15. and why 15 because we are including the zero so first we will set our cursor to 0 0 which is the top left corner and then we'll print any text we like so I am printing my channel name over here and then we will set the cursor to another location which is 0 comma 1 so it will be in the zeroth column which should be the First Column and in the first row so earlier it was on the zeroth row now in the first row so basically that means is earlier it was on the first row and now it is on the second row which is the bottom most row and then we will print a variable which is labeled as counter so initially the counter was set here at zero as you can see with this function over here so initially it will pin 0 then its value will be incremented by 1 as you can see over here and then we will add a delay of half a second or here it is written as millisecond so it is 500 millisecond and basically it's just to show you how you can print different types of variables so for an ESP board this should not be necessary for your program you just remember that how to print some string value or how to print an integer variable onto the screen so once you have modified your code then you can just simply go to select your board and com Port which is pre-selected as well now and then just go ahead and click on upload and once it finally uploaded then we can head over to our board so once the code is uploaded we can remove it from the laptop and do check if the LCD is getting the text printed or not so let me just power it on real quickly and then you can see the text is now printed but sometimes what may happen is that you may may not be getting some text printed and you have done everything correct and double checked everything so there is a little blue thing over here as you can see this is called a potentiometer so this basically controls the brightness of the LCD display so all you have to do is just take a screwdriver just like this one and then just adjust the brightness and as you can see the text becomes faded away so I am turning it in the zero position so all you have to do is just turn it in the right way which is I think in this particular case clockwise Direction so if you turn it far enough then surely you will get the text and if you overdo it then you can see it just completely goes all white but still you will be able to read the text at a certain angle as you can see so there you guys now you can control your LCD display with your esp32 board so this was a really fun project you can use it as a web server and put random text on the display whenever you like from the web page or whatever so thanks for watching video guys hopefully you like it I have given all the code and the circuit diagram in the description below so if you have any doubts then you can recheck the codes and the circuit diagram from the description and if you have student notes then you can comment down below I will try to answer them as soon as possible so until then I will see you all later
Info
Channel: INOVATRIX
Views: 24,110
Rating: undefined out of 5
Keywords: #creative, #hobby, #inovation
Id: wkbScuJQxFc
Channel Id: undefined
Length: 10min 6sec (606 seconds)
Published: Mon Jun 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.