Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display(s) driver conflicts (SPI and I2C) with the RF24 library #719

Closed
donniebergh opened this issue Jan 10, 2021 · 10 comments
Closed

Display(s) driver conflicts (SPI and I2C) with the RF24 library #719

donniebergh opened this issue Jan 10, 2021 · 10 comments

Comments

@donniebergh
Copy link

I'm have trouble getting any TFT/LCD display to work along side the RF24 library on an Arduino Nano. To date I have tried 3 different displays all using some form of the Adafruit or Arduino drivers.

I have narrowed my problem to the moment the radio is initialized with "RF24 radio(10,9); // CE, CSN" the display(s) stop working. I have also tried moving the CE,CSN pins around with no success. The radio continues to work and I can display the data on the Serial monitor - but no long on the display.

I'm using the following hardware:

  • Arduino Nano V3
  • Several displays - the latest I have tried is a "240x240 IPS ST7789" using SPI. Have also used a 1306 (128x64 pixels) on the I2C bus
  • NRF24L01 transceiver module

Can you help me - Is there a fix for this?

Thank you,
-Donnie

@2bndy5
Copy link
Member

2bndy5 commented Jan 10, 2021

Can you provide store links for the displays? "1306" isn't helpful. ST7789 is the driver IC for the display, but it doesn't describe the board the display is on. I'm curious because most of the SPI display boards that I saw (when recently shopping for a TFT display) included an SD card reader. So, that might be detrimental to using the nRF24L01 over the same SPI bus.

@Avamander I did happen to buy a TFT (ST7789 + SD card reader) & an OLED (default I2C xor optional SPI interfaces - no SD card reader) for exploring #714

@donniebergh Maybe when they arrive I will be better suited to help you debug this issue.

No idea why the I2C display + nRF24L01 wouldn't work though. Does the nRF24L01 have a on-board antenna or is it a PA/LNA module? I ask because you might be suffering a power problem in that case.

@donniebergh
Copy link
Author

donniebergh commented Jan 10, 2021 via email

@TMRh20
Copy link
Member

TMRh20 commented Jan 12, 2021 via email

@2bndy5
Copy link
Member

2bndy5 commented Jan 12, 2021

@donniebergh just to be clear, the radio's CSN pin is not the same pin used for the ST7789's CS pin right? And you are only trying to connect 1 display at a time? These questions are so basic I forgot to ask.

@donniebergh
Copy link
Author

donniebergh commented Jan 13, 2021 via email

@2bndy5
Copy link
Member

2bndy5 commented Jan 13, 2021

ok, glad I asked. Most SPI devices need to have a CS (Chip Select) or CSN (Chip Select Not -- same behavior, different label) so that the MCU (the nano) can tell which SPI device to pay attention to the communication happening on the SPI bus (MISO, MOSI, & SCK/SCLK pins). Without attaching the ST7789's CS pin to the MCU, the display is likely paying attention to all communication over the SPI bus, even when the data over MOSI is only intended for the nRF24.

According to the code you posted, and the adafruit library for the ST7789, you are trying to use software driven SPI data over the nano's designated pins for hardware driven SPI. I highly recommend you change the TFT_MOSI & TFT_SCLK pins to something that isn't also attached the nRF24. Or just use the ST7789's CS pin. Notice that the ST7789 is one of those few SPI devices that doesn't use the MISO (because its an output only device).

p.s. SCL & SDA are terms usually reserved for the I2C bus, but they are often used as a reference for the SPI pins SCK & MOSI/MISO (as evident by the ST7789 datasheet which doesn't explicitly mention using I2C). I've also seen SDO & DO used for MOSI and SDI & DI used for MISO. The SCK/SCLK pin shares the same identical role as the SCL (again just different labels for a different interfacing bus).

EDIT: oops, I misread your code. Looks like your not using the adafruit library that I linked to. Can you post a link to the library you are using for the ST7789?

@2bndy5
Copy link
Member

2bndy5 commented Jan 15, 2021

@donniebergh I can confirm that there must've been something wrong with your wiring/code using the I2C to the SSD1306 driven display. I recently received my displays, and I encountered no problems with the I2C OLED display + SPI nRF24 radio. More to come when I have a try at the SPI TFT display driven by the ST7789...

@donniebergh
Copy link
Author

donniebergh commented Jan 15, 2021 via email

@2bndy5
Copy link
Member

2bndy5 commented Jan 16, 2021

@donniebergh The hardware driven SPI pins on the ATMega328(p) (the CPU used on the Uno the Nano, and the RF Nano) are D11, D12, D13 (that's the MOSI, MISO, and SCK/SCLK respectively). image
According to this schematic from the PDF provided by emakefun about the RF Nano, the nRF24L01's SPI bus is using the ATMega328's hardware driven SPI bus. One of your SPI displays (the bigger one) does not provide access to the ST7789's CS pin. This means that you can't connect the display (without the CS pin) to the same SPI pins that the nRF24L01 is using (please re-read my previous comment for more explanation about the CS pin).

Simply said

  1. When using the RF Nano, the display without a CS pin has to use software driven SPI via pins that are not D9, D10, D11, D12 and D13.
  2. If you use a regular Nano (with an external nRF24L01 radio), then the nRF24L01 can be connected using some software driven SPI pins (not the hardware driven SPI pins), and the display without a CS pin can be connected to the hardware driven SPI pins.
  3. If using a display with a CS pin, then both the display and the radio can use the same hardware driven SPI pins, but make sure that the CS pin for the display is not connected to the same pin that the CSN pin for the nRF24L01 is connected to.

Moving on

I'm going to try and use the Adafruit library for the ST7789 (& ST7735) for my TFT display because I can use the same Adafruit GFX library to draw the same graphics/text that I did on the I2C OLED display.

@donniebergh
Copy link
Author

donniebergh commented Jan 16, 2021 via email

@2bndy5 2bndy5 closed this as completed Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants