Hello guys,
I am trying to send the h and t variable values to Blynk could.
But when I put the Blynk code together with the code below, the LoRa communication doesnt work anymore and I assume thats because the use of the SPI for the LoRa device. Do you think it would work on Arduino Mega as it has 3 serial ports?
Or, would be possible to make it work with Arduino Uno using and ethernet shield W5100? If so could you post the recommended changes on the code below?
Thank you very much.
#include <SPI.h>
#include <LoRa.h>
float h,t;
void setup() {
pinMode(7, OUTPUT);
Serial.begin(9600);
while (!Serial);
Serial.println("LoRa Receiver");
if (!LoRa.begin(915E6)) { //LoRa Frequency @ 915Mhz
Serial.println("Starting LoRa failed!");
while (1);
}
Serial.println("LoRa init succeeded!");
Serial.println();
}
void loop() {
// try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize) {
// received a packet
Serial.println("Received packet");
// read packet
while (LoRa.available()) {
//Read and store received values
h = LoRa.read();
t = LoRa.read();
}
Serial.println(h);
Serial.println(t);
// print SNR and RSSI of packet
Serial.print("SNR= "); //As higher the number, better the signal (higher than 7 is perfect)
Serial.print (LoRa.packetSnr());
Serial.print(" RSSI= "); //As higher the number, better the signal (0 = Very good signal and -80 = not so good)
Serial.println(LoRa.packetRssi());
//Toggle the LED when a packet is received
digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level)
delay(10); // wait for a second
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(10);
Serial.println();
}
}