Blocco trasmissione LoRa su Heltec WiFi Lora 32 (V3.2)

------- english ------------
Hello everyone,
I am developing a monitoring system for my home photovoltaic system, I am using a Heltec WiFi Lora 32 (V3.2).
The system is connected to the Arduino cloud, it reads the electrical data via ModBus from two electrical network analyzers via Serial1, On an I2C port I connected a lighting sensor, on another HSPI port I connected a micro-SD module to store any errors that occurred, of course I access the WiFi network both for the connection to the Arduino cloud, both for the management of the date and time (SNTP) and for access to a MySQL server on which I store important statistical data.
I would have liked to transmit the instantaneous electrical data, the same as those I send to the Arduino cloud, with a Json string via LoRa to be received by a second Heltec WiFi Lora 32 (V3.2) for monitoring without using the smartphone (cloud).
Everything works, except the transmission of data on the LoRa network. Upon closer inspection, I noticed that the LoRa system stops working when I activate the micro-SD module; therefore, almost certainly, one of the pins used to manage the HSPI port will certainly conflict with the pins used by the LoRa system.

These are the pins I use:
#define MB_CRT 48 // ModBus Control Pin
#define RXD1 45 // Rx Serial1 Pin
#define TXD1 46 // Tx Serial1 Pin
#define sda_Pin 42 // SDA Pin
#define scl_Pin 41 // SCL Pin
#define SD_CS 26 // SPI CS Pin
#define SD_MOSI 34 // SPI MOSI Pin
#define SD_MISO 19 // SPI MISO Pin
#define SD_SCLK 5 // SPI SCLK Pin
#define OledReset 21 // OLED Reset Pin
#define Button_0 0 // GPIO_0 Button on the board
#define LedInt 35 // GPIO_35 LED on the board
#define PulAzz 47 // GPIO_47 Data reset button

And these are the libraries included in the project:
#include “thingProperties.h”
#include “Arduino.h”
#include <heltec_unofficial.h>
#include <ESP32Time.h>
#include <ArduinoJson.h>
#include <ModbusMaster.h>
#include <Preferences.h>
#include <FS.h>
#include <SD.h>
#include <SPI.h>
#include <WiFi.h>
#include <esp_sntp.h>
#include <ESP32_MySQL.h>
#include <Adafruit_VEML7700.h>

Unfortunately, I deal almost exclusively with software and I can’t figure out which PIN/s may conflict.
Can someone help me?
Thanks

------ ITALIANO --------------
Salve a tutti,
Sto sviluppando un sistema di monitoraggio per il mio fotovoltaico domestico, sto utilizzando un Heltec WiFi Lora 32 (V3.2).
Il sistema è collegato al cloud Arduino, legge i dati elettrici tramite ModBus da due analizzatori di rete elettrica tramite la Serial1, Su una porta I2C ho collegato un sensore di illuminazione, su un’altra porta HSPI ho collegato un modulo micro-SD per memorizzare gli eventuali errori accaduti, naturalmente accedo alla rete WiFi sia per la connessione al cloud Arduino, sia per la gestione della data e ora (SNTP) che per l’accesso a un server MySQL su cui memorizzo i dati statistici importanti.
Avrei voluto trasmettere i dati elettrici istantanei, uguali a quelli che invio al cloud Arduino, con una stringa Json tramite LoRa per essere ricevuti da un secondo Heltec WiFi Lora 32 (V3.2) per un monitoraggio senza l’uso dello smartphone (cloud).
Funziona tutto, tranne la trasmissione dei dati sulla rete LoRa. Ad una analisi più approfondita mi sono accorto che il sistema LoRa smette di funzionare nel momento in cui attivo il modulo micro-SD; quindi quasi certamente, uno dei pin utilizzati per la gestione della porta HSPI sarà certamente in conflitto con i pin utilizzati dal sistema LoRa.

Questi sono i pin che utilizzo:
#define MB_CRT 48 // Pin di controllo ModBus
#define RXD1 45 // Pin Rx Serial1
#define TXD1 46 // Pin Tx Serial1
#define sda_Pin 42 // Pin SDA
#define scl_Pin 41 // Pin SCL
#define SD_CS 26 // Pin SPI CS
#define SD_MOSI 34 // Pin SPI MOSI
#define SD_MISO 19 // Pin SPI MISO
#define SD_SCLK 5 // Pin SPI SCLK
#define OledReset 21 // Pin Reset OLED
#define Button_0 0 // GPIO_0 Pulsante nella scheda
#define LedInt 35 // GPIO_35 LED nella scheda
#define PulAzz 47 // GPIO_47 Pulsante x azzeramento dati

E queste le librerie incluse nel progetto:
#include “thingProperties.h”
#include “Arduino.h”
#include <heltec_unofficial.h>
#include <ESP32Time.h>
#include <ArduinoJson.h>
#include <ModbusMaster.h>
#include <Preferences.h>
#include <FS.h>
#include <SD.h>
#include <SPI.h>
#include <WiFi.h>
#include <esp_sntp.h>
#include <ESP32_MySQL.h>
#include <Adafruit_VEML7700.h>

Purtroppo, mi occupo quasi esclusivamente di software e non riesco a capire quale/i PIN possano entrare in conflitto.
Qualcuno può aiutarmi?
Grazie

There will be more people able to help if you can put the post in English as well as Italian.

Bit tricky on my phone to search the forum, but if you do, the problem is well known so you will find answers.

:ok_hand:
Grazie sempre
ciao.

Both use SPI communication, and unless you’re careful about which SPI buses and pins are in use, they’ll interfere with each other and cause exactly the kind of behavior you’re seeing.

The LoRa radio is hardwired to use the VSPI bus, typically with these pins:

MOSI = GPIO 35

MISO = GPIO 37

SCLK = GPIO 36

CS (NSS) = GPIO 17

RESET = GPIO 18

IRQ (DIO0) = GPIO 14

Your SD card setup is using:

MOSI = GPIO 34

MISO = GPIO 19

SCLK = GPIO 5

CS = GPIO 26

GPIO 5 or 19 or both are interfering with the LoRa module.

You can:

  1. Use a separate SPI bus for the SD card. The ESP32 supports HSPI and VSPI, and by default LoRa uses VSPI, so put the SD on HSPI.

  2. Explicitly configure a new SPIClass for the SD card like this:

#include <SPI.h>
#include <SD.h>

SPIClass hspi(HSPI); // Use HSPI instead of default VSPI

#define SD_CS 26
#define SD_MOSI 34
#define SD_MISO 19
#define SD_SCLK 5

void setup() {
hspi.begin(SD_SCLK, SD_MISO, SD_MOSI, SD_CS);
if (!SD.begin(SD_CS, hspi)) {
Serial.println(“SD Card Mount Failed”);
} else {
Serial.println(“SD Card initialized.”);
}
}

  1. Initialize the LoRa module first (before SD)

Posts on the forum using search include:

and the link to the gold mine: