Hello guys,
I think I stuck at a very simple "C" logic but cannot find the answer, can you help please?
I built a simple circuit with ESP32 Wrover and Ai-Thinker RA-02(sx1278) LoRa Module and trying to interface them.
My connections are;
ESPIO5 --> LoRaSS
ESPIO18 --> LoRaSCK
ESPIO19 --> LoRaMISO
ESPIO21 --> LoRaIO0
ESPIO22 --> LoRaRST
ESPIO23 --> LoRaMOSI
ESP32 EN and IO0 are connected button circuits for reset and programming, ESP and LoRa PWR connections are decoulped and seems fine on oscillator.
I'm using default LoRa library and Since I'm using Wrover module, I'm using "SPIClass * classname" to change SPI pins but since "LoRa.setSPI(SPIClass& classname)" function expects an address, I cannot use SPIClass pointer in this function and getting errors. Can you take a look at my code please?
#include <SPI.h>
#include <LoRa.h>
int counter = 0;
#define rst 22
#define dio0 21
#define VSPI_MISO 19
#define VSPI_MOSI 23
#define VSPI_SCLK 18
#define VSPI_SS 5
SPIClass * vspi = NULL;
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("LoRa Sender");
vspi = new SPIClass(VSPI);
vspi->begin(VSPI_SCLK, VSPI_MISO, VSPI_MOSI, VSPI_SS); // Start SPI
LoRa.setSPI(vspi);
LoRa.setPins(VSPI_SS, rst, dio0);
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
delay (2000);
ESP.restart();
}
}
void loop() {
Serial.print("Sending packet: ");
Serial.println(counter);
// send packet
LoRa.beginPacket();
LoRa.print("hello ");
LoRa.print(counter);
LoRa.endPacket();
counter++;
delay(1000);
}
If I compile like this, I get the compiling error "invalid user-defined conversion from 'SPIClass*' to 'SPIClass&' [-fpermissive]"
And if I comment out the setSPI method then I stuck at "Starting LoRa failed!"
Thanks for helps