Using LCD1602 or LCD2004 with ESP32

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hi, welcome to another ESP32 tutorial by Robojax. my name is Ahmed Shamshiri. I'm presenting this tutorial from Canada in this tutorial we are going to learn how we can use the LCD screen of 1602 or LCD 2004 with ESP 32 microcontroller Bluetooth Wi-Fi unit. we're going to display the text or numbers you can get the code for this by clicking at the link below the video in the description which will take you to www.robjax.com/learn/arduino let's get started with this. Hardware explained these are the ESP32 development boards with Wi-Fi and Bluetooth, and they are offered in different formats for example if you compare these two you will see what one is shorter the other is longer or you might see it something as a shield like this this is the same ESP 32 ESP 32 Wroom 32. Or may be completely different something like this. which I have separate video on that. and their code an explanation that I will do will work with this LCD screen this has 1602 characters and two line with I2C module at the back so it has only four wires. Or if you use of 2004 which has four line and 20 characters this will also has a I2C module at the back as you can see both of these. so the code will work exactly the same and this needs 5 volts to operate these two is 5 volts to operate. and you have to get 5 volts which I'm going to show. you next we have explained this module a separate video explaining that with full details with I2C communication module to attache and solder. when you purchase it they either they send the separate with this already soldered and sent. so make sure to get the one that is already ready so you don't have to spend any time on that. there are 4 pins for ground VCC SDA and SCL. these two are for I2C communication this is the chip I2C communication that gets the data with some other components so it can go to this LCD otherwise you have to connect this many wires which is very hard. and then we the contrast of this can be adjusted using this. Contrast of this if I bring this up you see it's completely disappeared. the text but if I go this way it will be too much dark so you have to find somewhere in between those two. so you can read it. and if you disconnect this the light will be turned off it's like that. connecting a voltmeter here so you can see the voltages I'm connecting the ground pin then the negative to the ground here and the positive which I have connected a red one if I connect it to this point which is 3.3 volt labeled as 3.3 volts you will see that we are getting 3.3 volts but the LCD will not be turned on with this 3.3 volts we need 5 volts. and only pin that have that 5 volts is this last pin which has been labeled as 5 volts and this module. and this is now 5 volts this is a 5 volt that is coming from usb and immediately exiting and then it goes to this 3.3 volts which gives power to the rest of the board. a separate video explaining that. now if you are connecting external power then you need to connect 5 volts here and from the same wire connected to your LCD. so this will not be available to you. and if you have this module here you see this these two are different in terms of length. and it does have not been labeled as 5 volts but it's labeled as VIN. let me show. you let me connect this to the ground where if ground in here and let me connect the positive to this pin. and now it shows 4 points X a little drop but still it will work so this is with a little voltage drop that due to this Schottky diode that is here it's being reduced 0.4 volts and that is the 5 volt that will work with the LCD. and then 3.3 voltage at this point. so depending on a module make sure that you can get 5 volts otherwise LCD will not work. Wiring Explained the wiring diagram for this project is available as part of my Arduino course at udemy.com the link will be available. below this video let me explain the wiring and help for the wiring I've prepared this so you can see it easily SCL is pin, pin 22 if it is labeled D twenty two or twenty that's the pin. SDA is Pin 21. and here on this module it has been labeled as G 22 and g21. there is RX, TX in between. and if you're getting a different module like that again here it says D22 and here D 21. grounds from this side is connected using this ground wire to the ground doesn't matter which ground you have but in this module this ground does not work when I use the continuity tester it fails so this is a ground when I connect it. and the next one is VCC VCC needs 5 volts. and this module has 5 volts our death pen SDA is orange this has been connected to pin 21 and here and SCL is yellow it has been connected to pin 22. if you need to connect multiple devices that need I2C communication because we have two pins, bring a jumper wire here and from here you can distribute it to up to 128 devices keep that in mind. Code Explained let me explain the code. you need to download this LiquidCrystal_I2C library I will provide you the link so you have to download it when you download it it will be a zip file save it in your computer. then go to a sketch include library add .zip library and then to point it to where you have saved it. for example if this was your library that you have downloaded for LiquidCrystal_I2C.zip select it and click open. once that is open then the library will be ready. and this example you would copy and paste this code and it will work. so we include this this header file which is part of a library. and after that and death line we create an instance of this class and we call it LCD and we are passing 3 parameter this one the first one is 3f the zero X means hexadecimal and this is an address for I2C. how you get this address? I will provide you the I2C scanner code. and this is I2C scanner we know we do not worry what is inside it the original link is here if you want it just upload it to your (ESP32) module my module is already connected. I'm uploading it bringing a serial monitor by clicking tools serial monitor or you can press CTRL+SHIFT+M make sure to set your serial monitor with the same baud rate otherwise you will not be able to see it on the right side and the lower corner go to 9600 and wait. you see it's reading at 0 X 3 F. 3F is the address are then continuously doing the same thing. close this and then close the I2C scanner. so we got our address. and and I have already printed here so I don't forget it. we have 16 characters here and 2 line. so that's why we put 16 and 2. this count is just for the counting of this number do not worry we are initializing the serial monitor and we are initializing the screen by using LCD dot begin because we have created an object for the screen this is initializing it this is setting the backlight on and this is just renting this text on the screen if i press this reset button on that side. you will see that the demo and this text are shown a two line so we are using a CD dot print to print this text inside that double quotation. you see it is printing the text and then we set the cursor at character 0 line 1 so we are moving that to this character character 0 line 1 this is line 0 that is line 1. and we print the text demo let me bring it again so you can see it. demo and then we wait for 2 seconds so the user can see it. inside the loop() we clear the screen from previous value because the loop will continuously print something. and then using lcd.print() print we print this text. This text is printed from there if we don't use lcd.serCursor(0,0) automatically it goes to cursor at character 0 line 0. that's why we didn't use setCursor at the beginning. but after this because if you don't put this this text will go at the end and will be print over the previous value or out of the screen. so we set this so the cursor moves to the next line and it turns this counting with a colon. this is a text after that we set cursor to character 11 line 1 0 1 2 3 4 5 6 7 8 9 10 11 we go to character 11 line one. that is line 0 line 1. and then we print this count count is a number that is being incremented every 200 milliseconds. So this loop prints all that and comes and adds (increments) one and it goes. so from the beginning if I reset that you will see that it would be zero and it had adds up so 0 1 2 3 is just renting. so in this code I've demonstrated to print text and also print a number an integer as a variable so this is a text and this is a variable. and the loop will continue increases and until it doesn't fit on the screen and it will overlap but it's just a demonstration. Demonstration now here is a demonstration with a little larger screen so you can see it fully. and if you disconnect this the light will be turned off it's like that. can read it easily Subtitle typed by Ahmad Shamshiri on Sep 23, 2020 in Canada I did my part to help you learn. Now it is your turn. You can subscribe to my channel, thumb up 👍 the video and type a comment by saying thank you. If you don't skip ads it will also help you . My PayPal Account link is in the description if you want to make cash donation. Thank you I would like to thank my patrons from Patreon.com I did my part to help you learn. Now it is your turn. thank you for watching this was how to use LCD screen with EF P 32 to display text or information if you learn something and found this useful please thumb up as this will help my video in the search algorithm of YouTube if you have comment our question posted at the comment section below I always try to answer and reply and if you want to get updates of my upcoming videos you may subscribe now you
Info
Channel: Robojax
Views: 69,606
Rating: undefined out of 5
Keywords: electronic, tutorial, training, video, robojax, arduino, code, download, esp32, bluetooth, wifi, lcd, display, lcd1604, lcd2004, how to, wiring, show, ahmad, shamshiri, screen, i2c, sda, scl
Id: COssWn4Pcm4
Channel Id: undefined
Length: 13min 49sec (829 seconds)
Published: Mon Sep 09 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.