Need help Grove LoRa 433mhz

My USB Cables are working perfectly, because I’m able to successfully upload sketches on my board.
As directed by you, I also uploaded the the blink sketch on both of my boards, and the LEDs are also finely glowing.

I uploaded the sketches of rf_95 client and server on both of my Arduino Boards, with all the wires disconnected and then again plugged in all the wires after uploading of sketch. But still the same error is being displayed on the serial monitor - “init failed” …

@tiwari73rajesh In the code, the software serial is used pin digital pin 5 and 6, so can you try to connect the Rx and Tx on the digital pin 5 and 6!

1 Like

Okay… Let me try… This

Oh… Communication got established.

1 Like

Great. what was the problem?

Actually, everytime I was connecting the radio modules to the RX and TX Pins and sometimes, to Digital pins 2 and 3. It was mentioned as SoftwareSerial ss (5,6); in the sketch. When I connected the RX of my Radio to Digital 5 and the TX of my Radio to Digital 6, then also it didn’t work. But when I interchanged the connection and connected the RX of my Radio to Digital 6, and the TX of my Radio to Digital 5, then… it did work. And I got -----!!! " Hello World " displaying on my Serial Monitor.
Thanks a lot to you… Your suggestions on Connecting to Digital pins 5 and 6 really worked. You’re great… :vulcan_salute:t2: :ok_man:t2:

Now, I just need this last help.

How can I send the readings/measurements of a Grove Vibration Sensor (SW-420) fitted on one of my Arduinos, using (or through) the LoRa Radio Transmitter (fitted on the same Arduino), to the LoRa Radio Receiver that is fitted on the second (separate) Arduino?
This is very important for me. Kindly guide me…

Could you help me out?

you can add your sensor data here and send.

But how?
Where? What to write?

@salman sir, 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 radio receiver also, then only a transmission will be taking place.

It took me 3.2 hours to prepare these two sketches. Kindly guide me, I’ll provide you with every required information.

LoRa_Sender (Vibration Sensor)

#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;
}

Kindly help as soon as possible sir…
Please detect my fault, for which the vibration measurement from the first arduino is not going to the second arduino.

Hi @tiwari73rajesh:
we can use sprintf function to make the number to string.like this:

  char *str = NULL;
  str = (char*)malloc(20);
  int number = 1;
  sprintf(str,"nubmer is %d\r\n",number);
  free(str);

Thanks @Hansen sir.
But where and how to insert this code?

Hi @tiwari73rajesh:

uint8_t data[20] = {0};
int measurement= 1;
sprintf(data,"measurementis %d\r\n",measurement);
rf95.send(data, sizeof(data));
1 Like

The code said by you is to be put in place of this (in the Transmitter Sketch)?

Hi @tiwari73rajesh
Yes

Oh…
Hello @Hansen sir. The code given by you, to write in the place of my code, just worked. At first, it wasn’t working because “int measurement= 1;” was leading the serial monitor to always give the vibration measurement as 1. But when I removed that line…!!! I’m getting the exact vibration measurements on the 2nd Arduino too (to which the LoRA Receiver is connected) and my receiver is able to catch the value of measurement. Thanks a lot.

1 Like

Hello everyone, I’m using if…else conditional statements with my LoRa Modules. Actually I want to display some desired information/message on the serial monitor when the measurement goes above a certain limit. But what I am writing under the if statement is never getting displayed on the serial monitor, and the statement which I am writing under the else statement is all the time getting displayed on the serial monitor.
This is very urgent, kindly someone help me out.

Please someone assist me.