Using a 2.8in SPI LCD Touchscreen ILI9341 with an ESP32 on Platformio

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign today we're going to connect this LCD touch screen to an esp32 it's a 320 by 240 SPI 2.8 inch touchscreen it's one that you see a lot of when you see these LCD touch screens a lot of people have problems connecting them to an esp32 we're going to see how easy it is these have the ili 9341 driver and you can pick these up on Amazon for around 22 dollars and while they all seem to have a built-in SD card slot there's nothing actually special about the SD card slot I'm going to be talking about that in a separate video we're not going to be doing anything with that this video furthermore this project will directly interface with platform IO at the time of this video core 6.1.4 home is 3.4.3 if you're looking for this video except running under Arduino IDE instead of platform IO click the link in the top right corner we'll take you to it the LCD display as well as the backlit screen pulls a bit of current and I don't want to run it through the esp32 voltage regulator so I have the separate power supply which will supply the 5 volts and the 3.3 volts that I'm going to be using for this project so I will show you how I'm doing that this hw-131 is one of the more common cheap esp32 power supplies so in the main screen of platform IO we're just going to start with a new project for this and we're going to choose what project name we're going to have so I'm not going to be overly creative we're just going to call this the touch screen test and then we'll select the type of board that we're using type ESP into the filter and then scroll down to the board that I'm using may be different from your board mine is the do it esp32 dev kit V1 our framework is going to be Arduino so I hit finish and in a couple of seconds we're ready to go I'm going to click that bottom file the platform io.ini and most people familiar with this file will find it very easy to add the library to it but regardless we do want to set our monitor speed which we're going to set for 9600 only because that's a speed that's already in the program so it's just easier that way I would generally set it higher at around 115 but but we'll do this a conventional way I'm going to click back on platform IO home and then I'm going to click on libraries over to the search window I type in TFT underscore espi and then hit the search button and scroll down until I find TFT underscore espi and then I select it and the TFT ESP library is open right here current version 2 4 76 from 21 days ago click on installation and we could see how we would put it in to our platform IO ini but we're just going to select a project select our touch screen test and just hit add to give it for us speed this up by factor of four and congrats it's completed hit that little X and we're ready to go I'll show you comment Pitfall though since platform io.ini was already open while we did this you'll see that the changes did not appear here and if I attempt to close or save that file which I will now attempt to save the file we'll get an arrow because there'll be a newer version than the one that's currently there and we can see that the error is is that one of them has the monitor speed and the other one has the live depths added and this is not really a major problem obviously I could take that line 15 on the left side and copy it and I could put it in line 16 on the other side resolving the conflicts I close it and then I add line 16 here and then I could save this and then when it asks me to overwrite I could simply overwrite it and the problem is resolved as a new project if we go over to the source folder we'll see main.cpp and it looks very much like an Arduino style program these obviously include the arduino.h and platform i o but everything else looks the same continuing we make our way to Pio and then live depths and we see TFT underscore espi we open that scrolling down to user setup select.h we select that file for editing A first order of business will make our way down to line 42 where we will disable usersetup.h so we'll put two forward slashes right there then we'll scroll all the way down to line 91 which happens to be set up 42. we can see right here for ili 9341 320 by 240 and uncomment that at this point I'd like to hit save we'll scroll down now to the user setups directory and open that and make our way down to setup number 42 and open that file for editing in this file we'll just be going to line number 14 which will be uncommenting to enable touch support so we'll do that now and then we'll save this file and that is it for all the configuration editing that's required to get this thing going we can now close all these tabs that we've opened up on our screen from here we'll move right into the physical wiring we'll call this out point to point starting with the esp32 and the LCD display VCC will go to 5 volts ground will go to ground CS will go to D15 rst will go to D4 DC will go to D2 MOSI will go to d23 fck will go to d18 the LED will go to 3 volts m-i-s-o will go to d19 tclk will go to d18 t c s will go to D5 t d i n will go to d23 and finally t d o will go to d19 the last one is not connected I wired everything as previously described as we could see here the 5 volt power coming off the power supply through this rail through these blue and white wires feeding voltage in as well as this yellow wire to the module it was plugged in here on the last video 3.3 volts and my other 3.3 volts is plugged in over here to the 3.3 volt part of the power supply now this is very strange because the jumper wasn't modified to support this in the last video and it still worked which means I had 3.3 volts coming into the 3.3 volt voltage regulator on this board but I guess whatever it worked and unlike the Arduino version of this video we're running it through the power supply and not through the voltage regulator of the esp32 which is what I intended to do on the left side I'm going to open up examples and scroll down to 320 by 240 and then what I want to do is scroll down we're going to start with an easy one and that's TFT star field I open that and we see this program and what I'm going to do is I'm going to hit copy then I'm going to make my way down to the source folder and I realize it's just off screen but what I'm doing is I'm pasting that file into the source folder now I'm going to rename main.cpp to main.bak and then rename this test program to main.cpp then I will add and include for arduino.h make my way down to verify and hit it for the first build I'll speed this up by a factor of four and everything here on the build looks good so we're going to push to the device this portion again I'll also speed up and once the device reboots I switch over to serial monitors so we could take a look at the frames per second which is available as part of the program and we see we're looking at 40 something frames per second and we see the screen coming up with our star field program and it looks really cool I always like this example just because it looks really cool get a close-up of this take a look at that that's pretty awesome but this just confirms that our test works so it's time to move on to our next example so now I'm going to delete main CPP our first example move to trash and I'm going to scroll up through our examples again until I find the keypad 24320 example and I'm going to copy it I'm going to scroll back down to our source folder and I'm going to paste it in here and then I'm going to rename this main CPP again adding to this and include for arduino.h now I'm going to hit verify and I know it's not going to work even though it works in Arduino but we're going to talk about why we see right here that we get was not declared in scope errors and there's a lot of them and we'll go through right quick and we'll see how easy it is to correct here it says line 89 and this function is indeed called online 89 won't be declared till 205 so we could see the problem here this somehow Works in Arduino but yeah it's not going to work here so what we're going to do is we're going to declare it up top void and watch me spell touch calibrate wrong obviously I'm going to catch this later but it's not going to work and that's fine we understand the spirit of what I'm trying to do and I'm going to move on to the other one draw a keypad and we're just going to put that one right under it void draw a keypad I'm actually making an attempt to spell this one correctly so now what we're going to do I'm going to hit verify again we'll see how it changes we see a third function not declared it's called status I'm going to show you a gotcha here because I'm going to add status up Top Line 26 and it's not going to work we'll talk about why now we're getting a too many arguments function for void status and the problem is evident status takes an argument and we've declared it without an argument it's a constant character doing one more shortfall I'll add constant character and try it without the star at the end so we could see the error and we can see an invalid conversion from Khan's Car Star to car so I'm going to add that star now finally realizing I incorrectly declared the touch calibrate function name I go ahead and make the last of the changes and then hit verify one last time and everything compiled error-free before push it to the device I want to change the value on line 34 from false to true that allows for the repeating of the calibration every time the device is Rebooted so now we'll push into the device speed this up by a factor of four and it was a success as it turns on we're greeted with a calibration screen and I'm going to pick up the device I have to be careful not to touch anything I'm going to use the white pen that was supplied to do this and if I mess up the calibration I have to reboot everything at startle over this is one of the reasons why we set this parameter to true so that we could redo this every time we reboot but I happen to get it right and it booted into what looks like a phone keypad and the numbers are all responsive as we could see the resolution is good enough for me to use my finger to be able to type in and that's working absolutely fine the commands are working in the program as we see as well but I will also try to type in some numbers here and then hit send to the serial port and we can see that worked so I can hit a couple more times there again again again so that functionality also worked too so we got the screen working as well as the touch features absolutely no problem we saw some anomalies setting up power through the voltage regulator was very interesting but that concludes this video I hope you found this video enjoyable entertaining and informative do me a favor hit that like button down below helps me out a lot when you do and hit that subscribe button for more videos like this when they come out when another video like this comes out a link will be posted in the top right corner again I hope you enjoyed this video thanks for watching thanks for watching would you like to reply
Info
Channel: Retro Tech & Electronics
Views: 9,653
Rating: undefined out of 5
Keywords: ili9341, tft_espi, tftespi, 2.8in SPI LCD Touchscreen, 2.8in LCD Touchscreen, esp32, esp32 lcd touchscreen, esp32 touchscreen, 2.8in lcd touchscreen pinout, hw-131, hw131, arduino ide, arduino ide 2, arduino ide 2.0, esp32 arduino ide, esp32 tutorial, howto lcd touchscreen, howto, espressif, spi, esp32 how to, esp32 howto, touchscreen ili9341 esp32, esp32 ili9341, esp32 ili9341 touchscreen, ili9341 tft_espi, esp8266 ili9341, esp8266 howto, ttgo ili9341, platformio, platformio ili9341
Id: RMSn61iInEE
Channel Id: undefined
Length: 13min 18sec (798 seconds)
Published: Sat Feb 11 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.