I want to use the Grove LoRa Radio library using SoftwareSerial.
And I get the following error:
sketch\rf95_client.ino.cpp.o: In function `__static_initialization_and_destruction_0':
C:\Users\rr\AppData\Local\Temp\arduino_modified_sketch_514036/rf95_client.ino:18: undefined reference to `RH_RF95<SoftwareSerial>::RH_RF95(SoftwareSerial&)'
sketch\rf95_client.ino.cpp.o: In function `setup':
C:\Users\rr\AppData\Local\Temp\arduino_modified_sketch_514036/rf95_client.ino:42: undefined reference to `RH_RF95<SoftwareSerial>::init()'
C:\Users\rr\AppData\Local\Temp\arduino_modified_sketch_514036/rf95_client.ino:54: undefined reference to `RH_RF95<SoftwareSerial>::setFrequency(float)'
sketch\rf95_client.ino.cpp.o: In function `loop':
C:\Users\rr\AppData\Local\Temp\arduino_modified_sketch_514036/rf95_client.ino:61: undefined reference to `RH_RF95<SoftwareSerial>::send(unsigned char*, unsigned char)'
C:\Users\rr\AppData\Local\Temp\arduino_modified_sketch_514036/rf95_client.ino:71: undefined reference to `RH_RF95<SoftwareSerial>::recv(unsigned char*, unsigned char*)'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Seeeduino Wio Terminal.
My code:
#include <RH_RF95.h>
#include <SoftwareSerial.h>
SoftwareSerial SSerial(0, 1); // RX, TX
#define COMSerial SSerial
#define ShowSerial Serial
RH_RF95<SoftwareSerial> rf95(COMSerial);
void setup() {
ShowSerial.begin(115200);
ShowSerial.println("RF95 client test.");
if (!rf95.init()) {
ShowSerial.println("init failed");
while (1);
}
// Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
// The default transmitter power is 13dBm, using PA_BOOST.
// If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
// you can set transmitter powers from 5 to 23 dBm:
//rf95.setTxPower(13, false);
rf95.setFrequency(434.0);
}
void loop() {
ShowSerial.println("Sending to rf95_server");
// Send a message to rf95_server
uint8_t data[] = "Hello World!";
rf95.send(data, sizeof(data));
rf95.waitPacketSent();
// Now wait for a reply
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf95.waitAvailableTimeout(3000)) {
// Should be a reply message for us now
if (rf95.recv(buf, &len)) {
ShowSerial.print("got reply: ");
ShowSerial.println((char*)buf);
} else {
ShowSerial.println("recv failed");
}
} else {
ShowSerial.println("No reply, is rf95_server running?");
}
delay(1000);
}
I also know that it is possible to use SoftwareSerial on Wio Terminal.
Is there a solution?