ESP32 - TFT - MFRC522 > Red stripes

Hello,

I have connected a 4" SPI TFT display to an ESP32. This works fine, display looks good and the text / images appear on the screen.

As soon as i run this code, i get strange red stripes in the display (see image).

if ( ! mfrc522.PICC_IsNewCardPresent()) {
        return;
    }
    
    if ( ! mfrc522.PICC_ReadCardSerial()) {
        return;
    }

    MFRC522::PICC_Type picc_type = mfrc522.PICC_GetType(mfrc522.uid.sak);
    
    
    //mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
    if(picc_type == mfrc522.PICC_TYPE_MIFARE_UL) {
        beep(success);
    }
    else {
        beep(fail);
    }

If i keep my code the same except the part above, all the stripes are gone.

Does anyone know what the problem can be?
The display driver is ST7796_DRIVER

No one knows how to solve this?

You have been a member for 9 months.

Please post links to your hardware i.e. ESP32 board, TFT display.

Please quote which library(s) you are using and any library examples that do not work.

If all library examples work 100%, paste/attach your custom sketch that exhibits the problem. (and how you have wired it)

David.

You are right,

The hardware i am using is:

ESP32 WROVER
MFRC522
W5500 Ethernet
4" SPI TFT (4.0Inch Tft Spi Seriële Lcd Resolutie 480*320 4.0Inch Lcd Display Module Met Sd Card Slot 3.3V 5V Driver Ic ST7796S|Display Screen| - AliExpress)

The libraries i am using:
MFRC522 (GitHub - miguelbalboa/rfid: Arduino RFID Library for MFRC522)
TFT_espi (GitHub - 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)

The wiring diagram:

All code works, the only thing that doesn't work correctly is that when i combine the MFRC522 code together with the TFT display, i get those red stripes. Even than the RFID scanner works and i can write images or text to the display, i only get the strange stripes

As soon as i include this code the stripes appear:

if ( ! mfrc522.PICC_IsNewCardPresent()) {
        return;
    }
    
    if ( ! mfrc522.PICC_ReadCardSerial()) {
        return;
    }

    MFRC522::PICC_Type picc_type = mfrc522.PICC_GetType(mfrc522.uid.sak);
    
    
    //mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
    if(picc_type == mfrc522.PICC_TYPE_MIFARE_UL) {
        beep(success);
    }
    else {
        beep(fail);
    }

Please post a schematic that is readable.

It is not possible to identify what IOxx pin is connected to anything.

You have chosen to NOT paste the sketch. So we can't even inspect your class constructors.

If you want readers to help, you need to take 10 minutes from your life to provide proper information.

David.

I am not sure if this is more readable but maybe it is:

I posted the code, without that bit of code everything works fine (display shows everything correct).
The problem is in the code above.

I can post the code that writes the display:

spr.loadFont(FONT_SANSATION_REGULAR_100);
        spr.setTextColor(TFT_WHITE, TFT_BLACK);
    
        tft.setTextDatum(MC_DATUM);
    
        int xpos = tft.width() / 2;  // Centre of screen
        int ypos = tft.height() / 2;  // Centre of screen
    
        ClearDisplay();
        int font_width = spr.textWidth(current_time, 1) + 5;
        int font_height = spr.fontHeight(1);
        tft.setCursor(xpos - (font_width / 2), ypos - (font_height / 2));
        spr.printToSprite(current_time);

I know this bit works because it is exactly the same from the library example and like i said, when i remove the RFID code this shows correctly as well (without red stripe)

If you need anything else please let me know

No one who knows what the problem can be? For some this might be normal that this happens right?

@bluebirdsoftware,

a quick look at the code you posted doesn't reveal any constructors.

Maybe the driver of one of the other parts uses the default SS for selecting its device, but you connected your TFT to SS. This might produce spurious writing to your TFT.

But if you don't follow advice that was given, we can't know or help.

david_prentice:
Please post a schematic that is readable.

Looks pretty readable to me, especially if you click on it! :roll_eyes:

Paul__B:
Looks pretty readable to me, especially if you click on it! :roll_eyes:

I assume most of your posts are more relevant for the topic in question, aren't they?

@ Paul__B ,
I could not read the wiring image in #3

bluebirdsoftware posted a good schematic image in #5 and a good photo of the problem in #0.

The (#5) schematic looks fine to me.

Since we do not know what constructors or sketch code he has used, it is not possible to offer any sensible advice.

I would agree with Jean-Marc. There is a possible software conflict for ChipSelect pins.

David.

david_prentice:
@ Paul__B ,
I could not read the wiring image in #3

It is too small.

The forum scales posted images to fit on the page along with the text and mostly does not use the full width of the window (on more current monitors such as a 22 inch, especially apparent if maximised). Zooming the page using Ctrl;+ expands the image, potentially to its full size and well beyond. The image in #3 is actually not much larger than you see it but zooming it allows most of it to be read - albeit with difficulty.

It does however contain a link to the image hosting page containing the full-size and perfectly clear original diagram, when you simply click on it.

When I post images, if (I know) they are actually larger than the space allocated on the forum page, I post them using image tags but also as a link to the same image. Due to a particularly nasty foul-up in the forum software, clicking on them as a link to an image causes the browser to refuse to display them natively, but refers you to the OS associated external image viewer such as IrfanView on Windoze or Document Viewer on Linux. However if they are actually of a greater resolution than allowed in the forum page, you can "zoom" them instead of using the link.

My apologies. When #3 was originally posted I tried "View image", clicking on image, ... all the usual tricks. With no success. The "view image" was very low resolution. I am sure that clicking did not work.

Anyway, now that I can see the whole schematic, there are a few anomalies. e.g. R1, R2 with capacitor symbols. C3, C4 with electrolytic on "output". 25AA02 chip with 5V power on a 3.3V system.

When there are obvious "features" in a schematic I would suspect multiple "software features" too.

I am not going to waste time speculating.
If someone posts buildable code, readers can reproduce the problem and offer a solution.

If a poster does not want to provide the information, she just has to solve it for herself.

David.

I didn't change any of the messages so the link should have been there i think.
The 5v is from the development board. I need 5V on the eeprom (with 3.3V i don't get any values)

R1 and R2 are my bad, i used the same symbol because i use the same size pcb smd components. I will look for the right symbols.

I will post my code tomorrow, i have made seperate .h files for parts of the code so i need to find a good way to make it available here

If your sketch has multiple tabs, just ZIP up the project. Then we get all the files in one ZIP.

Your 25AA03E48 is rated for 1.8V - 5.5V operation.
It should run fine @ 3.3V (with SPI clock = 5MHz)

If you power it at 5.0V the 5V SO signal is going to damage the ESP32.

David.

I'm sorry for the delay but here is the zipfile:

URL: Connecting...
Password: esp32_source

All the help is welcome, if you have a better solution for the 5.0V for the 25AA03E48 that would be great.
I have also noticed that i get different MAC addresses over time, isn't that wrong?

The problem is if i connect it to 3.3V i get only 0 values.
Do you know what can be wrong?

Thanks for the help so far and if you need more information please let me know

No one who can help? Or is my code that terrible that it is not possible to fix haha

Your ZIP is on an external server with a password. Unlikely for readers to trust.

When downloaded into a Project directory, there is executable code in H files.
There are an inordinate number of external libraries to install. Several that are not available through the IDE Library Manager.

I wasted some time attempting to build your "project".

I am out.

David.

p.s. I would be interested in investigating your "red line" problem.
Bodmer would be probably be interested too.

If you can provide a minimal buildable example, you might get some response.

The file is hosted on my synology so i thought people would trust synology over an external file upload website.

I will try to make a complete small project but by doing that maybe i am changing code so the problem won't occure but i can try

Think about it.

The Arduino system means that everyone has the "core" set of libraries and examples that come with the IDE.
Everyone can access any "approved" third party libraries via the IDE Library Manager.

So you can paste a sketch or attach a project ZIP to the Forum.
And anyone in the world can replicate your project.

Yes, you can flout the C / C++ conventions if you want. e.g. code in H files

But you will keep people happier if you just create a minimal example that exhibits your problem.

Or at least add any "unusual files" to local tabs in your project.
Build your project yourself first. All the libraries, versions and locations are reported in a "verbose compile".
You just need to go through the list in the Library Manager.

David.

p.s. we make allowances for young members, newcomers, non-English speakers, ...
I am guessing that you don't fall into those categories.