2.4 TFT LCD With I2C Module(s)

20K2128

Intro: 2.4 TFT LCD With I2C Module(s)

Hello!

In this short instructable i will show you how i managed to use the I2C bus with this TFT LCD.

STEP 1: Materials

The parts needed:

-Arduino Uno

- 2.4 TFT LCD

- DS3231 for example

- some wires

- female pins

- solder and soldering iron

- a cutter

STEP 2: The Display and the Preparation

The SPFD5408 tft as you know is a 240x320 pixel display that can be easily connected most of the Arduino boards and it works with most of them. It uses 8 digital , 5 analog , 2 power and 1 ground pin.

The display is very convenient in my oppinion, because just plug and use it. The only thing was disturbing me is that the display most commonly uses the one of the I2C bus line (A4) for the reset function. But after yesterday night i found myself a solution for this case.

The solution i found is that i needed to remove the reset pin of the shield and with a small wire connected it with the arduinos RESET pin. I did not mind the pin removal because the display i had was a bit defective and had to fix it before to make it usable.

STEP 3: Software and the Source

Earlier when i was searching on the internet found a video on youtube. In this video was an arduino with the same display and a DS3231 RTC module. I really wanted to remake the same clock but did not have the parts to make it. So i rested the case till yesterday, when i had succeeded after 1 hour of work.

Added another sketch for McuFriend library.

The video can be found here:

The sketch : http://arduino.ru/forum/apparatnye-voprosy/deshevy...

STEP 4: The Modification

Disclaimer: I DID NOT WRITE THE SKETCH. ONLY MODIFIED IT TO FIT MY NEEDS!!

The original setup and sketch did not work for me. So i added a few lines of code souch as theese libraries:

#include SPFD5408_Adafruit_GFX.h

#include SPFD5408_Adafruit_TFTLCD.h

#include SPFD5408_TouchScreen.h

This library will drive our display. It has to work with ILI9320/25/28/40/41 TFT driver chips.

The next thing is to declare the analog pinout:

#define LCD_CS A3

#define LCD_CD A2

#define LCD_WR A1

#define LCD_RD A0

#define LCD_RESET 1

The Reset can be commented since we will not use the Analog 4 pin for this feature.

Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, 1);

We need 3 more lines in the void(setup):

tft.reset(); to reset the diplay

tft.begin(0x9328); set the tft lcd driver chip ID manually.

Replace the rtc.halt(false); to rtc.begin(); to start the RTC.

I had 1 compiling error: exit status 1

'drawMark' was not declared in this scope

As usual copy and paste into a new tab and no error. Problem solved!

This setup might work with the McuFriend library as well, but not sure because i have not tried.

STEP 5: Assembly and the Result

The preparation and assembly was not more than 30 minutes.

So cut the shields reset pin, solder it together with Arduino reset pin. Cut down 4 or 6 female pins, use a little piece of pcb. Connect (solder) the RTC pins to the arduino board (correctly) with a few wires.

Upload the sketch and you are ready. You have a very precise Arduino clock.

STEP 6: Conclusion

So it took me a while to figure this thing out(because of my stupidity), but finally it turned out in a good result.

With this simple modification now you can connect (multiple) I2C and regular sensors to the Arduino board with a "little sacrifice" and expand the possibilities of your project you want to make.I think it will be the goal for a few Arduino gadgets that i am planning with a programmer friend. The only limit is our imagination.

STEP 7: Done

You are done, use it as you like!

I hope you find it useful and could help someone facing the same problem.

Have a nice day.

19 Comments

I have created a new whole shell. I have converted it into an STL file and am ready to put it into the 3D printer for final assembly.
Looks nice :) Good work!😉
I like this clock very much, thank you👍 for sharing the code and letting me learn
I like this clock very much, thank you👍 for sharing the code and letting me learn
I also want to use a photoresistor to automatically adjust the brightness of the TFT backlight LED with ambient light. Using UNO’s analog input A0 pin/output control is one of the pins 12 or 13. The pin output is connected to a transistor. The TFT_led pin (the circuit needs to be slightly modified) is used to control the strong light and low light of the led. Of course, I am adding code, and the definition of the pin also adds the value change from 0 to 255.

(I will add code when I have time)
I thought of it too a few years back. Since the backlight is based on 5V , to set backlight level there is no need for big value changes, a simple transistor is fine for that. I suggest NPN tranyo.
I re-uploaded and set the RTC module. After the completion, the time was the same as my computer, and my original TFT screen was broken (there were many return lines), so I just replaced it with a new one. I was really busy.
In the follow-up, I am drawing a 3D shell to print the shell (no need to dig a big hole), I will install it in the shell and publish it: I did it, and I transferred the printer to STL format and shared it with everyone
The A4 pin of the UNO should not be connected to the TFT, and it didn’t show up after trying it, so I pulled the A4 of the TFT to a high potential directly to +5V, and it would show up

(A4 (reset) of the TFT cannot be floating or not connected to the potential, it must have a high potential + 5V to display.)
I have same issue with my first prototype. This is based on Atmega328 pro mini and used a potmeter for backlight and reseting.
You are great, using Atmega328 pro mini-5v/16M, I saw you working hard, it is very professional and challenging
It seems to me it is(could be) a tft transistor film damage(i could be wrong)or maybe the lcd is faulty.
For tft resetting i strongly recomend only 3.3volt logic levels, cuz some faulty lcd-s cant take it without a damage or graphical gliches This kind of display works fine even with 3.3 volt a for eg:esp32, stm32.
Pls try tft reset with 3.3v, or try to test it with another display(if you have).
Input voltage and current drops and overs still can cause issues like this.
Pls report back later if its solved or not.
3.3v I want to connect RTC

thankyou
In the follow-up, I will draw a 3D shell in the new creation to print the shell (you don't need to dig a big hole), I will install it in the shell and I will publish it: I did it, and I transferred the printer to the STL format and shared it with Everyone
I edited and uploaded according to your code. When testing, the TFT is bright white, and there is no display
3 possible glitch:
- Pls make sure that the LCD_CS pin is using arduinos reset pin. Cuz any I2C device is using A4+A5 pins for the bus. A4 pin can not be used for both purposes at the same time.
-White backlight is usually a problem if not the proper type of lcd is declared in the sketch(for eg. 0x9325 or 9328 etc).
Pls make sure what kind of lcd are you using. Even worked for me with ILI9340/9341

-The connections are not correct.

Till this very day i am using this clock with a arduino nano and refreshed the sketch and not a problem.
The TFT is *not* being accessed by I2C, but by SPI instead in this sketch.
The RTC is being accessed by I2C
Hello,
I'm trying to figure out how to connect i2c display to Raspberry Pi. I get the SCK/SDA part, but what should I do with A0, CS and reset pins? Just connecting to i2c bus does not register that screen in device list. I looked and I looked through this library, but I don't see wiring diagram. Thank you!