mcufriend 2,4" TFT LCD

Hello
I am working on mcufriend 2,4" TFT LCD & I2C and i have a famous problem with A4 pin.
I have connected LCD to Arduino UNO and UNO is connected to MEGA via SDA and SCL. GND and 5V is common. In I2C protocol MEGA is master writer and UNO, with display, is slave reader. I have sniped off LCD_RST and tried to somehow make it work, but it is not working.I tried to connect it to 5V, GND and reset pin but could not make it work. The screen is white and think it stuck in reset mode,if i reset the UNO board then screen is working but then i have problem with receiving information from master, master is not transmitting it.Then if i reset master it's starting to transmit again but screen gets white. While resetting these boards sometimes for few seconds its starting to work correctly, screen displays received information, but it is for like a 2 second, then display has some bugs with text and interface an its is going white again.Please help me if you can.
I am not using serial or SD card, if it can help somehow. Or i could use some other communication way to exchange information between these two Arduino board.

P.S. If something is incorrect(i mean grammar) sorry for my English :smiley:
and BTW when MEGA is transmitting data with I2S rx led is blinking. I don't get why, should not it be tx led?

You can snip off the LCD_RST pin. But you must solder a 10k resistor from the top of the snipped pin to the top of the 5V pin.

This should be fine with most MIPI style controllers. What controller is on your display? What library?

Call tft.begin() before Wire.begin() because A4 (SDA) will still get wiggled in tft.begin()

David.

p.s. if your Uno is only a Slave Display, it would be easier to use the SPI pins. Then you don't have to worry about I2C or snipping LCD_RST.

My display has two controller: SUM74HC245 (If this is what you meant). Library is your MCUFRIEND_kbv.
And about SPI. I thought to use it but in arduino pinouts scheme i saw that miso,ss, mosi and sck is on 10,11,12 and 13 pins, so i thought it would also have pin conflict with display

You can not see the TFT controller. The 74HC245 chips are just level shifter buffers.

The library will tell you the TFT ID. Run any of the examples.

You can safely use the SPI pins. They just go to the microSD card socket. If the socket is empty, there is no conflict.

You can connect between the Mega and Uno with a 6-way ribbon on the ICSP headers. Snip the "Reset" wire and connect a /CS wire from 10 on the Uno to 53 on the Mega.

Or you could use the SCL (A5) pin as /CS. you can put an angle header pin in the SDA header socket. This means the shield sits nicely on your Uno. And your connections to the Mega do not interfere with the Shield.

This all seems very complicated. I would use a single Mega (or Nucleo) board. The display shield fits on the single board. And you have plenty of "extra " pins available for external electronics.

David.

Mega is working slow with display.
and another reason why i don't want to use mega, if it is not necessary, is that i have already bought uno and nano for this project and just Practicing on mega.
Your example gave me this:
ID = 0xB505
If i will use spi, will slave device be able to send and recive data to?
And about I2C. I have connected 10K pull up to 5V from LCD_RST and tft.begin(ID) is before wire.begin(8) but it still don't wants to work. If i reset uno_ lcd works , if reset mega _ works I2C.

also this is my sketch, based on your button simple . maybe i have some mistakes in sketch!?

temp.ino (9.22 KB)

and what is karma in this forum ? :smiley: is it good?

You have a Renesas R61505V controller.

Yes, a Mega is SLOWER than a Uno because the Uno shield matches the PORT pins sensibly.
If your Uno works as an I2C Slave, it will be incredibly slow for plotting individual points.

On the other hand, the Mega could send "high level graphics commands" on the I2C bus. And the Uno processes them.

A Mega shield works fast on a Mega.
A Uno shield works fairly fast on a Uno.

David.

i started to use nano instead of mega. anyway it didn't works. screen is white.
do you suggest to make uno master and nano slave.i want uno to as send as receive data will it be possible on spi?
as i get in this case you would prefer spi connection right?

I am horrified by the thought of respectable Shield and a silly Nano.
You have to make 16 proper connections with Dupont cables. When it is cheaper and MORE reliable to plug a Shield into a proper Uno clone.

There is nothing wrong with making an intelligent graphics screen. Use a bare 3.3V panel with a 3.3V BluePill.

Personally, I believe in plugging a male shield into female Arduino header sockets as Nature intended.

David.

display is plugged in uno. nano is for receive data from temperature sensors an give it to uno, which will display it and user can change min and max temperature with display so... also it should give back information about potential minimum and maximum temperature before alert.

Ah-ha. A plugged in shield is wise.

If you make the LCD_RST hardware modification, you can use as many I2C peripherals as you want e.g. temperature Sensors.

If you use SPI sensors, you can use 10, A5 as chip-selects. With mod you have A4 as well.
i.e. not many SPI sensors.

You can use as many DS18B20 OneWire sensors as you like.

David.

i prefer i2c but i can't use it. i did what you said: sniped off lcd_rst, wired 10k resistor on lcd shield from lcd_rst to 5v, in sketch tft.begin(ID) is before wire.begin(8) and when i upload sketch it's working correctly for like a 2 sec an then screen smashes and its going white. do have any ideas how solve this? i even would rip off sd card slot to make it work please help

i am new and maybe i am missing something

Please attach your sketch code.

Or explain your project requirements e.g. what sensors?

David.

temp.ino is for arduino uno with tft shield and it is slave,this sketch is based on your button simple.
master is for arduino nano and it is master.
the thing is to display temperature of 5 different places(c1,c2,c3,c4,c5), given from arduino nano , on shield. by clicking on temperature icon user must be able to change minimum and maximum value of temperature in each place by individual and give this value to arduino nano(that part is not written yet, i am stuck on communication problem).the sketch seems complicated, that's the way i have came to reach the 'result', uno by individual worked fine, it was displaying values (0 by default),was changing mintemp and maxtemp of each place and remembering it, but when it came to exchange information i get stucked

master.ino (790 Bytes)

temp.ino (9.3 KB)

You appear to have 5 different LM35 style temperature sensors. This requires 5 different Analog channels.

If you had chosen LM75, all 5 LM75 could sit on the same I2C bus. And even have their own set points in hardware and even interrupt in hardware.

There are many ways to do your project with a single MCU e.g. 5 LM75 or 5 DS18B20
Or you could use 5 LM35 with an external ADC chip (on SPI or I2C bus).

Or use a Mega2560 which has 5 spare ADC pins for 5 LM35.

I suspect that your prime consideration is the shape of the Sensor package.

David.

yes but main problem is that i can't solve problem with i2c and display pin conflict.
now i am learning about SPI and it seems more complicated, thats why i wanted to use i2c, but now i think
it would be easier to use SPI. i have read your posts about slving LCD_RST problem but i couldn't solve it.
but thanks for help and advice.now i will try SPI and let you know what will it do

If I have some enthusiasm, I will build your Slave on a Mega or Zero.
And write a Master to create some random data.

And compare I2C with SPI.

Don't get excited. I suspect that bedtime is more appealing.

David.

:smiley: ok thanks

I put the Slave on a Mega2560. Master on a Uno. 4k7 pullups on SDA, SCL.
The Analog reads random noise on the Uno.

Sure enough the TFT suffers glitches. Lots of them with I2C sending data every 100ms. Still get glitches with 1000ms.

I will have a look at your Slave code. But not till the morning.

David.

:astonished: :astonished: :astonished: :astonished:
i can't believe, i made it ;D ;D :smiley:
i changed slave and master in i2c protocol and it's working.
it seems arduino with tft shield prefers to be a master in i2c protocol.
the only bug i have left, is that after disconnecting/connecting slave device display gets white for 2-3 seconds and then works correctly again. it's not even a bug, it is just Unpleasant.