After a few months of experimenting I eventually found a sketch which exactly fits my Tx and Rx needs.
The following sketch worked perfectly at a 250 meter range for just 10 days and then just "Stopped".
Testing revealed that the Tx and Rx unit would work perfectly at a range of 2 meters but more distabce than that message is "send to wait failed".
Am using "Duinotech Shields" at 915 Mh with Arduino Mega.
Using "<RHReliableDatagram.h> and <RH_RF95.h>" I have tried 4 different "shields " and 4 different "Mega" in all different combinations but range is always limited to 2 Meters.
If I use "<SPI.h> and <LoRa.h>" sketch from Sanddeep, I get back my 250 meters range no problem.
I am thinking that maybe there is a file in the RadioHead .pde that may need to be changed.
Any constructive advice would be appreciated
//........................................SENDER...TX....PORT 5................................
#include <RHReliableDatagram.h>
#include <RH_RF95.h>
#include <SPI.h>
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2
//.................................RTC.................
#include <Wire.h>
#include <ds3231.h>
struct ts t;
RH_RF95 driver;
RHReliableDatagram manager(driver, CLIENT_ADDRESS);
unsigned int senD1 = 0;
unsigned int senD2 = 0;
unsigned int senD3 = 0;
void setup()
{
Serial.begin(9600);
//.....................................SET UP LEDs...................
for (int aaa = 22;aaa<35;aaa++){
pinMode((aaa),OUTPUT);
digitalWrite((aaa),LOW);
delay(300);
digitalWrite((aaa),HIGH);
}
//............................................RTC
Wire.begin();
DS3231_init;
// t.hour=13;
// t.min=19;
// t.sec=5;
// t.mday=25;
// t.mon=4;
// t.year=2020;
// DS3231_set(t);
//............................................TX
while (!Serial) ; // Wait for serial port to be available
if (!manager.init())
Serial.println("init failed");
// 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:
// driver.setTxPower(23, false);
// If you are using Modtronix inAir4 or inAir9,or any other module which uses the
// transmitter RFO pins and not the PA_BOOST pins
// then you can configure the power transmitter power for -1 to 14 dBm and with useRFO true.
// Failure to do that will result in extremely low transmit powers.
// driver.setTxPower(14, true);
}
uint8_t data[] = "Hello World!";
// Dont put this on the stack:
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
struct message_t {
int value1;
int value2;
int value3;
} message;
void TimE(){
Serial.print(t.mday);
Serial.print("/");
Serial.print(t.mon);
Serial.print("/");
Serial.print(t.year);
Serial.print(" ");
Serial.print(t.hour);
Serial.print(":");
Serial.print(t.min);
Serial.print(".");
Serial.println(t.sec);
}
void TX(){
// Send a message to manager_server
message.value1 = senD1;
message.value2 = senD2;
message.value3 = senD3;
if (manager.sendtoWait((uint8_t *)&message, sizeof(message), SERVER_ADDRESS))
{
Serial.print(" Sent.......... ");Serial.print(message.value1);Serial.print(" , ");Serial.print(message.value2);Serial.print(" , ");Serial.println(message.value3);
// Now wait for a reply from the server
uint8_t len = sizeof(buf);
uint8_t from;
if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
{
Serial.println("Receipt Acknowledged ");
}
else
{
Serial.println("No reply, is rf95_reliable_datagram_server running?");
}
}
else
Serial.println("sendtoWait failed");
delay(2000);
}
//........................................SENDER...TX....PORT 5................................
void loop()
{
//........................GET CURRENT TIME...............
DS3231_get(&t);
//TimE();// Only if Needed to go to screen
//...................................STATIONS DATA ON OFF..
delay(10000);
int HouR =(t.hour);
int MiN =(t.min);
Serial.print(" Hour is . ");Serial.print(HouR); Serial.print(" Minute is . ");Serial.println(MiN);
if ((HouR==14)&& (MiN==10)){
digitalWrite(22,HIGH);
senD1 = 22;
senD2 = 0;
TX();
delay(10000);
}
if ((HouR==14) && (MiN==2)){
digitalWrite(22,LOW);
senD1 = 22;
senD2 = 1;
TX();
delay(10000);
}
//........................................SENDER...TX....PORT 5................................
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//................................................RECEIVER.......RX.....PORT 4................................
#include <RHReliableDatagram.h>
#include <RH_RF95.h>
#include <SPI.h>
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2
RH_RF95 driver;
RHReliableDatagram manager(driver, SERVER_ADDRESS);
int aaa = 0;// Loop Variable
void setup()
{
Serial.begin(9600);
//................................................... LED SET UP ....................................
//................................................. RECEIVER SETUP ................................
while (!Serial) ; // Wait for serial port to be available
if (!manager.init())
Serial.println("init failed");
}
uint8_t data[] = "Acknowledged";
// Dont put this on the stack:
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
struct message_t {
int value1;
int value2;
int value3;
} message;
//................................................RECEIVER.......RX.....PORT 4................................
void loop()
{
if (manager.available())
{
uint8_t len = RH_RF95_MAX_MESSAGE_LEN;
uint8_t from;
if (manager.recvfromAck((uint8_t *)&message, &len, &from))
{
Serial.println("Received ");
if (!manager.sendtoWait(data, sizeof(data), from))
Serial.println("sendtoWait failed");
Serial.print(F("value1 "));
Serial.println(message.value1);
Serial.print(F("value2 "));
Serial.println(message.value2);
Serial.print(F("value3 "));
Serial.println(message.value3);
// ...............................................TURNING LED and RELAY ON and OFF .........................
if ((message.value1 == 22) && (message.value2 == 0)) {
digitalWrite(22, HIGH);
}
if ((message.value1 == 22) && (message.value2 == 1)) {
digitalWrite(22, LOW);
}
}
}
//................................................RECEIVER.......RX.....PORT 4................................
}