tft lcd 2 spi nodemcu arduino code brands
The ILI9341 TFT module contains a display controller with the same name: ILI9341. It’s a color display that uses SPI interface protocol and requires 4 or 5 control pins, it’s low cost and easy to use.
The resolution of this TFT display is 240 x 320 which means it has 76800 pixels. This module works with 3.3V only and it doesn’t support 5V (not 5V tolerant).
The ILI9341 TFT display board which is shown in project circuit diagram has 14 pins, the first 9 pins are for the display and the other 5 pins are for the touch module.
Pins D5 (GPIO14) and D7 (GPIO13) are hardware SPI module pins of the ESP8266EX microcontroller respectively for SCK (serial clock) and MOSI (master-out slave-in).
The first library is a driver for the ILI9341 TFT display which can be installed from Arduino IDE library manager (Sketch —> Include Library —> Manage Libraries …, in the search box write “ili9341” and choose the one from Adafruit).
The ILI9341 TFT display is connected to NodeMCU hardware SPI module pins (clock and data), the other pins which are: CS (chip select), RST (reset) and DC (data/command) are defined as shown below:
Full Arduino code:The following Arduino code is from Adafruit ILI9341 library (graphicstest.ino) with some modifications in order to work with the above circuit diagram.
It is a 2.0 inch TFT display module.TFT liquid crystal has a semiconductor switch for each pixel,and each pixel can be directly controlled by dot pulses,so each node is relatively independent and can be continuous...
As a 2inch IPS display module with a resolution of 240 * 320, it uses an SPI interface for communication. The LCD has an internal controller with basic functions, which can be used to draw points, lines, circles, and rectangles, and display English, Chinese as well as pictures.
The 2inch LCD uses the PH2.0 8PIN interface, which can be connected to the Raspberry Pi according to the above table: (Please connect according to the pin definition table. The color of the wiring in the picture is for reference only, and the actual color shall prevail.)
The example we provide is based on STM32F103RBT6, and the connection method provided is also the corresponding pin of STM32F103RBT6. If you need to transplant the program, please connect according to the actual pin.
The LCD supports 12-bit, 16-bit, and 18-bit input color formats per pixel, namely RGB444, RGB565, and RGB666 three color formats, this demo uses RGB565 color format, which is also a commonly used RGB format.
For most LCD controllers, the communication mode of the controller can be configured, usually with an 8080 parallel interface, three-wire SPI, four-wire SPI, and other communication methods. This LCD uses a four-wire SPI communication interface, which can greatly save the GPIO port, and the communication speed will be faster.
Note: Different from the traditional SPI protocol, the data line from the slave to the master is hidden since the device only has display requirement.
2.We use Dev libraries by default. If you need to change to BCM2835 or WiringPi libraries ,please open RaspberryPi\c\Makefile and modify lines 13-15 as follows:
Write Chinese string: in the image buffer, use (Xstart Ystart) as the left vertex, write a string of Chinese characters, you can choose character font, font foreground color, font background color of the GB2312 encoding
2. The module_init() function is automatically called in the INIT () initializer on the LCD, but the module_exit() function needs to be called by itself
Python has an image library PIL official library link, it do not need to write code from the logical layer like C, can directly call to the image library for image processing. The following will take 1.54inch LCD as an example, we provide a brief description for the demo.
The first argument is a tuple of four elements. (20,10) is the coordinate value in the upper left corner of the rectangle, and (70,60) is the coordinate value in the lower right corner of the rectangle. Fill =" WHITE" means BLACK inside, and outline="BLACK" means the color of the outline is black.
The first parameter is a tuple of 2 elements, with (40, 50) as the left vertex, the font is Font2, and the fill is the font color. You can directly make fill = "WHITE", because the regular color value is already defined Well, of course, you can also use fill = (128,255,128), the parentheses correspond to the values of the three RGB colors so that you can precisely control the color you want. The second sentence shows Micro Snow Electronics, using Font3, the font color is white.
I have two the same brand new displays of this type, several NodeMCU Lolin V3 boards. I checked the wires. Played around with several configuration parameters that I didn"t understand well like ST7735_INITB/ST7735_GREENTAB3/ST7735_REDTAB. etc.
We"ve written a full open source graphics library that can draw pixels, lines, rectangles, circles, text and bitmaps as well as example code and a wiring tutorial . The code is written for Arduino.
Note:If you want to show the whole pitcure on the screen, it"s suggest using arduino mega2560. Because when you use Arduino UNO, thememory is not enough which cause the application simply ran out of memory.
The breakout has the TFT display soldered on (it uses a delicate flex-circuit connector) as well as a ultra-low-dropout 3.3V regulator and a 3/5V level shifter so that you can use it with 3.3V or 5V power and TTL control logic.
I have tried david_prentice"s MCUFRIEND_kbv Library with some hacks to no avail. I tried to hack the library for ESP8266 (updated write_8 and read_8 functions in mcufriend_sheild.h and defined SUPPORT_4532) - using these connections
This person ( (146) ESP8266 and 2.4" 8-bit parallel ST7781 TFT Uno Shield - YouTube) got the same display working w/ nodeMCU (albeit their module is 5V one and has hack on the LDO).
The Bodmer/TFT_eSPI: Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips (github.com) library says 8 bit parallel is not possible w/ ESP8266 because of shortage of GPIOs - but ESP8266 has 16 GPIOs (out of which 4 are SPI). I don"t plan on using touch or SD card functionality anyways. The LCD requires 8(data) + 4 (Control) + 1 = 13 pins, which should fit in the 16 provided by ESP8266 ? Please let me know if I am missing anything.
Anyways - the first question at hand would be - is it possible to run 8 bit parallel tft w/ ESP8266, followed by - which library can do the job if possible.
I was excited to see a game "engine emulator and compiler readily available for the ESP8266. It"s pretty neat! You can make your game using corax89"s repository and upload it to the ESP8266 to play. I actually used a fork of corax89"s code under mali1741 where he uses a nunchuk instead of the PCF8574 button matrix or I/O expander. However, implementing the hardware wasn"t as straightforward as I thought it would be. Implementing it directly from corax89"s repository resulted in a repeated flashing screen and MCU reset. The instructions to do it isn"t as fleshed out as well. So I cobbled together my own configuration in hopes that it will help others to implement theirs. Here we go!
Go ahead and connect the hardware as shown above. One of the LCD pins,SDO/MISO, is left floating or no connection. Then we can do some sanity checks to make sure all the hardware are working properly using some sketches.
We"ll be using the files found in the repository and the zipped libraries. The project uses theNintendoExtensionCtrl,coos, andTFT_eSPIlibraries. Make sure to use the ones zipped because the new versions of these libraries are not compatible. I found this out the hard way after trying several versions of each library from their respective repositories.
SanityCheck#1:ILI9341 SPI TFT LCD Screen (240x320)// Demo based on:// UTFT_Demo by Henning Karlsen// web: http://www.henningkarlsen.com/electronics/*The delay between tests is set to 0. The tests run so fast you will need tochange the WAIT value below to see what is being plotted!This sketch uses the GLCD and font 2 only.Make sure all the required fonts are loaded by editting theUser_Setup.h file in the TFT_eSPI library folder.############################################################################### DON"T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ############ TO SELECT THE FONTS YOU USE, SEE ABOVE ###############################################################################*/// Delay between demo pages#define WAIT 0 // Delay between tests, set to 0 to demo speed, 2000 to see what it does!#define CENTRE 240#include
Use this sketch by Henning Karlsen to check that your TFT wiring and libraries are working properly. It should display some graphics and cycle through them intermittently.
SanityCheck#2:Wii Nunchuk/** Project Nintendo Extension Controller Library* @author David Madison* @link github.com/dmadison/NintendoExtensionCtrl* @license LGPLv3 - Copyright (c) 2018 David Madison** This file is part of the Nintendo Extension Controller Library.** This program is free software: you can redistribute it and/or modify* it under the terms of the GNU Lesser General Public License as published by* the Free Software Foundation, either version 3 of the License, or* (at your option) any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU Lesser General Public License for more details.** You should have received a copy of the GNU Lesser General Public License* along with this program. If not, see
You can also use different pinouts, you"ll just have to changeUser_Setup.hfound in theTFT_eSPIlibrary in Arduino sketchbook folder/directory (this may vary depending on your setup. For example for mine, it"s found inDocuments/Arduino/libraries/TFT_eSPI). It should have something like this:// Only define one driver, the other ones must be commented out#define ILI9341_DRIVER#define TFT_CS PIN_D3 // Chip select control pin D3#define TFT_DC PIN_D4 // Data Command control pin#define TFT_RST -1 // Reset pin
After verifying all the parts are working individually, time to upload theESP_ILI9341_game_engine.ino. To avoid any issues, make sure all the files are within the same folder. This includes the data folder containing the game.binfiles. Your Arduino IDE should look like this:
Now choose the board that you have, for me it"s the NodeMCU 1.0 (ESP-12E Module). The COMPORT depending on where your device is connected. Finally the Flash Size set to what your board has. Here"s a screenshot of my settings:
You can check the size of your memory using the sketch by Markus Setller if you"re not sure:/*ESP8266 CheckFlashConfig by Markus SattlerThis sketch tests if the EEPROM settings of the IDE match to the Hardware*/void setup(void) {Serial.begin(115200);}void loop() {uint32_t realSize = ESP.getFlashChipRealSize();uint32_t ideSize = ESP.getFlashChipSize();FlashMode_t ideMode = ESP.getFlashChipMode();Serial.printf("Flash real id: %08X\n", ESP.getFlashChipId());Serial.printf("Flash real size: %u bytes\n\n", realSize);Serial.printf("Flash ide size: %u bytes\n", ideSize);Serial.printf("Flash ide speed: %u Hz\n", ESP.getFlashChipSpeed());Serial.printf("Flash ide mode: %s\n", (ideMode == FM_QIO ? "QIO" : ideMode == FM_QOUT ? "QOUT" : ideMode == FM_DIO ? "DIO" : ideMode == FM_DOUT ? "DOUT" : "UNKNOWN"));if (ideSize != realSize) {Serial.println("Flash Chip configuration wrong!\n");} else {Serial.println("Flash Chip configuration ok.\n");}delay(5000);}
We have it working but no games? It"s because we haven"t uploaded the games to theESP8266"s SPIFFS. There are numerous ways to do it, but we can use this Arduino plugin:https://github.com/esp8266/arduino-esp8266fs-plugin..The installation instructions can be found on the repository. It"s easy to follow, but I"ll break it down here:
So get yourself acquainted with how things work either through the "help" function, the user guide (https://corax89.github.io/esp8266Game/user_guide/index.html), or going through the code of other games on the web emulator and compiler:https://corax89.github.io/esp8266Game/index.html.Start by choosing a demo game and clicking through here:
Again, building this thing from the ground up wasn"t as straightforward as I thought. There was a lot of reflection time on my part (a lot of "What am I doing wrong?). Thankfully, I got it working despite using different components from the original project. This walkthrough should save you some headaches. Peace and game on!
※Price Increase NotificationThe TFT glass cell makers such as Tianma,Hanstar,BOE,Innolux has reduced or stopped the production of small and medium-sized tft glass cell from August-2020 due to the low profit and focus on the size of LCD TV,Tablet PC and Smart Phone .It results the glass cell price in the market is extremely high,and the same situation happens in IC industry.We deeply regret that rapidly rising costs for glass cell and controller IC necessitate our raising the price of tft display.We have made every attempt to avoid the increase, we could accept no profit from the beginning,but the price is going up frequently ,we"re now losing a lot of money. We have no choice if we want to survive. There is no certain answer for when the price would go back to the normal.We guess it will take at least 6 months until these glass cell and semiconductor manufacturing companies recover the production schedule. (May-11-2021)
ER-OLEDM032-1W is the 256x64 white pixels OLED display with adaptor board that simplifies your design,diagonal is only 3.2 inch.The controller ic SSD1322, communicates via 6800/8080 8-bit parallel and 3-wire/4-wire serial interface. Because the display makes its own light, no backlight is required. This reduces the power required to run the OLED and is why the display has such high contrast,extremely wide viewing angle and extremely operating temperature.Please refer to below interfacing document for how to switch to different interface. The default interface is 8-bit 8080 parallel.
It"s easily controlled by MCU such as 8051,PIC,AVR,ARDUINO,ARM and Raspberry Pi.It can be used in any embedded systems,industrial device,security,medical and hand-held device.
Of course, we wouldn"t just leave you with a datasheet and a "good luck!" We prepared the interfacing documents,libraries and examples for arduino due,mega 2560,uno,nano and for raspberry pi or raspberry pi zero.For 8051 microcontroller user,we prepared the detailed tutorial such as interfacing, demo code and Development Kit at the bottom of this page.
NodeMCU has ESP-12 based serial WiFi integrated on board to provide GPIO, PWM, ADC, I2C and 1-WIRE resources at your finger tips, built-in USB-TTL serial with super reliable industrial strength CH340 for superior stability on all supported platforms.
ESP8266 has powerful on-board processing and storage capabilities that allow it to be integrated with the sensors and other application specific devices through its GPIOs with minimal development up-front and minimal loading during run-time.
The breakout has the TFT display soldered on (it uses a delicate flex-circuit connector) as well as a ultra-low-dropout 3.3V regulator and a 3/5V level shifter so that you can use it with 3.3V or 5V power and TTL control logic.