AbHacKbArrEr:
Oh… the communication got established. Now I am able to connect the two LoRa radio modules with each other.
But now I'm again stuck in a problem.
I want to send the readings/measurements of a Grove Vibration Sensor (SW-420) fitted on one of my Arduinos, using (or through) the LoRa Radio - 433 MHz Transmitter (fitted on the same Arduino), to the LoRa Radio - 433 MHz Receiver, that is fitted on the second (separate) Arduino. And I want to see the vibration measurements on the serial monitor of the second arduino (to which the the LoRa receiver is connected).
I have made the LoRa sender and receiver sketches for vibration sensor, and I’m attaching them with this message. The good thing is that I have successfully established communication between the two radios, along with vibration sensor and when the vibration sensor (on the first arduino, with transmitter) is getting any jerk or vibration, the led (on the second Arduino, with receiver) is lighting up. I am able to get the measurements of vibrations on the serial monitor of radio transmitter. But I need them on the serial monitor of the receiver radio also (then only a transmission is said to be taking place), which I'm not getting.
It took me 3.2 hours to prepare these two sketches. Kindly someone guide me, I’ll provide with every required information. Please detect my fault, for which the vibration measurement from the first arduino is not going to the second arduino.
Here are my sketches :
[b]LoRa_Sender (Vibration Sensor)[/b]
#include <SoftwareSerial.h>
#include <RH_RF95.h>
int EP = 2;
// Singleton instance of the radio driver
SoftwareSerial ss(5, 6);
RH_RF95 rf95(ss);
void setup() {
pinMode(EP, INPUT); //set EP input for measurment
Serial.begin(115200); //init serial 9600
Serial.println("----------------------Vibration demo------------------------");
if (!rf95.init())
{
Serial.println("init failed");
while(1);
}
rf95.setFrequency(434.0);
}
void loop() {
long measurement = TP_init();
delay(10);
Serial.print("measurment = ");
Serial.println(measurement);
if (measurement > 50) {
delay(200);
// Send a message to rf95_server
uint8_t data[] = "measurement";
rf95.send(data, sizeof(data));
delay(6000);
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))
{
Serial.print("got reply: ");
Serial.println((char*)buf);
}
else
{
digitalWrite(ss, LOW);
}
}
}
long TP_init() {
delay(10);
long measurement = pulseIn (EP, HIGH); //waits for the pin to get HIGH and returns measurement
return measurement;
}
LoRa_Receiver (Vibration Sensor)
#include <SoftwareSerial.h>
#include <RH_RF95.h>
// Singleton instance of the radio driver
SoftwareSerial ss(5, 6);
RH_RF95 rf95(ss);
int ledPin = LED_BUILTIN;
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(115200); //init serial 115200
Serial.println("-----------------------Pole - Urban Area - GHY_1---------------");
if(!rf95.init())
{
Serial.println("init failed");
while(1);
}
rf95.setFrequency(434.0);
}
void loop()
{
long measurement = TP_init();
delay(10);
Serial.print("measurment = ");
Serial.println(measurement);
if(rf95.available())
{
delay(200);
// Should be a message for us now
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if(rf95.recv(buf, &len))
{
Serial.print("GOT VIBRATION: ");
Serial.println((char*)buf);
digitalWrite(ledPin, HIGH);
delay(6000);
// Send a reply
uint8_t data[] = "Thanks for the Data";
rf95.send(data, sizeof(data));
rf95.waitPacketSent();
Serial.println("Sent a reply");
digitalWrite(ledPin, LOW);
}
else
{
Serial.println("recv failed");
}
}
}
long TP_init() {
delay(10);
long measurement = pulseIn (ss, HIGH); //wait for the pin to get HIGH and returns measurement
return measurement;
}
Hopefully waiting for a reply and help... ???



Please....Someone assist me and point out the errors in my sketch,for which, the vibration measurement is not going from the first arduino to the second arduino (on which the LoRa receiver is fitted).