Sharing same SPI with LoRa/LMIC and Epaper

I am trying to configure my HeltecV2. Idea is to share the same SPI with LMIIC and Epaper (Waveshare 2,9" using GxEPD). Is it even possible?

My Pin mapping is below

//// Pin mapping
const lmic_pinmap lmic_pins = {
.nss = 18,
.rxtx = LMIC_UNUSED_PIN,
.rst = 14,
.dio = {26, 34, 35},
};

GxIO_Class io(SPI, /CS=/ 17, /DC=/ 23, /RST=/ 16);
GxEPD_Class display(io, /RST=/ 16, /BUSY=/ 2);

Epaper data in is connected to same MOSI pin 27 and CLK pin5

LoRa part works nicely but I havent got this Epaper working on this board. (It works nicely with Arduino UNO) Can someone help please!

BR,
Tuomo

If the ePaper display does not work on your HeltecV2 then you will need to solve that problem first, before you think of sharing the SPI with LoRa\LMIC.

Have you checked if your ePaper library is ESP32 compatible ?

Yes, I believe this is the main issue. Still unsuccefull.

GxEPD should be ESP32 compatible.

The Epaper displays do work on a shared SPI bus, but your question is not related to that, the question is really, why does my display not work an my ESP32 ?

This may not be the best place to solve a problems with your ESP32 hardware, the ESP32 itself (which is not an Arduino) is supported by Expressif or perhaps the Arduino\Displays forum.

GxEPD should be ESP32 compatible.

Should be, but is it ?

Extensive thread on the GxEPD library over in the Arduino\Display forums;

https://forum.arduino.cc/index.php?topic=487007.0

Almost 1,500 messages, might be some useful information in there.

2 Likes

Hi tuhorkko,
Did you find a solution to your problem? I’m having similar problems.

I have an Adafruit Lora M0 Feather and an Adafruit EPD display. The display works fine if I hard code the CS to disable the LoRa chipset, otherwise I just get random noise displayed on the EPD.

Does the Arduino LMIC library assume that there are no other devices on the SPI bus?

Each device needs it’s own CS and in your code you should ensure you are doing nothing at all whilst the radio is active.

.rxtx Pin is not configured like that. You will need to know how spi works exactly for this board

Please be more specific and specify the proper full name. HeltecV2 could mean several things.

Do you mean you got the ePaper display working on Arduino Uno without LoRa and without sharing SPI?
Do you mean you did not get the ePaper display working on your Heltec board even when you are not using LoRa (using an example from the ePaper library)? If not then that would be your next step to try.

It should be possible to use two different SPI interfaces on an ESP32: HSPI and VSPI. Only one of these is used for LoRa. Using a separate SPI interface for the display may help reduce/prevent timing issues related to LoRa SPI traffic.

Any pointers for how to do this and best practices?

I don’t use the scheduler that’s built in to any of the Arduino LMIC’s for data collection or sending a job. I set a flag (aka semaphore) when I request a send and then unset it when the transmission is complete.

So all I have to do is check the flag and if it’s not set, I could, in theory, because I haven’t got anything hanging off the back of SPI on any of my devices, use the CS line setup for the ePaper and do as I see fit.

It’s not well documented (yet), but if you read through the main loop on this and refer over to the functions (procedures, whatever) it uses, it should make things clearer.

Not sure what you are trying to say here.
.rxtx pin (definition) is unrelated to SPI and the radio can be busy both when receiving and when transmitting.

It is commonly advised to do use LMIC’s built-in scheduler (except for certain cases e.g. state management with deep sleep on ESP32).

That’s true as long as you are not using lmic on top of a multitasking os, like RTOS.

With an RTOS it’s possible to run lmic in a task, while running other tasks for other purposes.

is there any example sketch that you can share?
I got the same issue with a ST7789 /ST7735 Display.
Display works alone with HW wired to Lora Chip and Display
LORA Works alone with HW wired to Lora Chip and Display
As soon as I use both Code parts in one sketch only the LORA Arduino LMIC part works :frowning:

Do you have separate chip select lines for the display & the LoRa radio chip?

yes… completely independent CS Lines. One seperate for the display and one unique for the LORA SX1276 Chip.

Leave it with me - I’ll need to get some hardware together to make sure it works.