Sending a value (int) and testing for it using LoRa

I am having trouble sending a value and then testing for that value after it is received. I have handshaking with the devices.

I have tried modifying several sample files. In the examples below I am just trying to make different LEDs light up depending on the message sent. Once I have that working I will be able to work it into my program.

To be clear, I do have the sample programs working. However, this only confirms handshaking. What I want to do is to control what is sent and to make a test on what is received.

Yes, my programs have a bunch of garbage in them as I try different things.

This pair is using RH_ASK.h, Transmitting:

// ask_transmitter.pde
// -*- mode: C++ -*-
// Simple example of how to use RadioHead to transmit messages
// with a simple ASK transmitter in a very simple way.
// Implements a simplex (one-way) transmitter with an TX-C1 module

#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile

RH_ASK driver;

void setup()
{
    Serial.begin(9600);    // Debugging only
    if (!driver.init())
         Serial.println("init failed");
         pinMode(13, OUTPUT);
}

void loop()
{
    const char *msg = "B";

    driver.send((uint8_t *)msg, strlen(1));
    driver.waitPacketSent();
    digitalWrite(13, HIGH); // To oberve program without connecting Serial Monitor
    delay(200);
    Serial.println("sent");
    digitalWrite(13, LOW); // To oberve program without connecting Serial Monitor
    
}

This pair is using RH_ASK.h, Receive:

[code]
#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile

#define LED1 11
#define LED2 12
RH_ASK driver;

void setup()
{
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  Serial.begin(9600);  // Debugging only
  if (!driver.init())
    Serial.println("init failed");
}

void loop()
{
  uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
  uint8_t buflen = sizeof(buf);

  if (driver.recv(buf, &buflen)) // Non-blocking
  {
    int i;

    // Message with a good checksum received, dump it.
    driver.printBuffer("Got:", buf, buflen);

    showA(); // checking the function call
    showB(); // checking the function call
    char printBuf = buf;    // added to display received character
    Serial.println(printBuf); // added to display received character
    
    // Added to call functions depenfing on the message received
    if (printBuf == "A") {
      showA();
    }
    if (printBuf == "B") {
      showB();
    }
  }


}

void showA() {
  digitalWrite(LED1, HIGH);
  delay (500);
  digitalWrite(LED1, LOW);
  delay (500);
}
void showB() {
  digitalWrite(LED2, HIGH);
  delay (500);
  digitalWrite(LED2, LOW);
  delay (500);
}
[/code]

This pair is using RH_RF95.h, Transmit:

[code]
// Feather9x_TX
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (transmitter)
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example Feather9x_RX
// from this webpage https://learn.adafruit.com/adafruit-feather-32u4-radio-with-lora-radio-module/using-the-rfm-9x-radio
// pinout for AdaFruit Feather 32u4 LoRa here: https://learn.adafruit.com/adafruit-feather-32u4-radio-with-lora-radio-module/pinouts

#include <SPI.h>
#include <RH_RF95.h>

//for feather32u4 
//#define RFM95_CS 8
//#define RFM95_RST 4
//#define RFM95_INT 7

// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 915.0

// Singleton instance of the radio driver

const int RFM95_CS = 8;   // this is added by me
const int RFM95_RST = 4;  // this is added by me 
const int RFM95_INT = 7;  // this is added by me

RH_RF95 rf95(RFM95_CS, RFM95_INT);

void setup() 
{
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);

  Serial.begin(9600);
  while (!Serial) {
    delay(1);
  }

  delay(100);

  Serial.println("Feather LoRa TX Test!");

  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);

  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info");
    while (1);
  }
  Serial.println("LoRa radio init OK!");

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);
  
  // 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(23, false);
}

int16_t packetnum = 0;  // packet counter, we increment per xmission

void loop()
{
  delay(1000); // Wait 1 second between transmits, could also 'sleep' here!
  Serial.println("AF7JA Transmitting..."); // Send a message with callsign to rf95_server
  
  int radiopacket = 2;
  itoa(packetnum++, radiopacket, radiopacket);
    sprintf(radiopacket, 1, radiopacket, radiopacket);
  Serial.print("Sending "); Serial.println(radiopacket);
//  radiopacket[19] = 0;
  
  Serial.println("Sending...");
  delay(10);
  rf95.send((uint8_t *)radiopacket, 1);

  Serial.println("Waiting for packet to complete..."); 
  delay(10);
  rf95.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  Serial.println("Waiting for reply...");
  if (rf95.waitAvailableTimeout(1000))
  { 
    // Should be a reply message for us now   
    if (rf95.recv(buf, &len))
   {
      Serial.print("Got reply: ");
      Serial.println((char*)buf);
      Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);    
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
  else
  {
    Serial.println("No reply, is there a listener around?");
  }

}
[/code]

This pair is using RH_ASK.h, Receive:


#include <SPI.h>
#include <RH_RF95.h>

// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 915.0

const int RFM95_CS = 8;   // this is added by me
const int RFM95_RST = 4;  // this is added by me
const int RFM95_INT = 7;  // this is added by me
// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);

// Blinky on receipt
#define LED 13
#define LED1 11
#define LED2 12

void setup()
{
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);
  //
 Serial.begin(9600);
  ////  while (!Serial) {
  ////    delay(1);
  ////  }
  delay(100);
 showA();
 showB();
  Serial.println("Feather LoRa RX Test!");

  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);

  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info");
    while (1);
  }
  Serial.println("LoRa radio init OK!");

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);

  // 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(23, false);
}

void loop()
{
  int buf;
  if (rf95.available())
  {
    // Should be a message for us now
    uint8_t buf;
//    [RH_RF95_MAX_MESSAGE_LEN];
    uint8_t len = 1;
//    sizeof(buf);

    if (rf95.recv(buf, &len))
    {
      // digitalWrite(LED, HIGH);
      RH_RF95::printBuffer("Received: ", buf, len);
      Serial.print("Got: ");
      Serial.println((char*)buf);
      Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);
      int sentValue = buf;
      if (sentValue == 1) {
        showA();
      }
      if (sentValue == 2) {
        showB();
      }

      // Send a reply
      digitalWrite(LED, HIGH);
      uint8_t data[] = "AF7JA Says Hello";
      rf95.send(data, sizeof(data));
      rf95.waitPacketSent();
      Serial.println("Sent a reply");
      digitalWrite(LED, LOW);
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
}
void showA() {
  digitalWrite(LED1, HIGH);
  delay (500);
  digitalWrite(LED1, LOW);
  delay (500);
}
void showB() {
  digitalWrite(LED2, HIGH);
  delay (500);
  digitalWrite(LED2, LOW);
  delay (500);
}

To send one character, replace this

   driver.send((uint8_t *)msg, strlen(1));`

with this

    char msg = 'B';
    driver.send((uint8_t *)&msg, 1);

To send an integer variable

    int j = 1234;
    driver.send((uint8_t *)&j, sizeof(int));

To receive an integer variable:

    int j = 0;  //received data go here
    int len = sizeof(int);  //expected size of data

    if (rf95.recv((uint8_t *)&j, &len)) {
    if (len == sizeof(int)) Serial.println(j);
   ...

Thanks. I put this into the Transmit side:

// ask_transmitter.pde
// -*- mode: C++ -*-
// Simple example of how to use RadioHead to transmit messages
// with a simple ASK transmitter in a very simple way.
// Implements a simplex (one-way) transmitter with an TX-C1 module

#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile

RH_ASK driver;

void setup()
{
  Serial.begin(9600);    // Debugging only
  if (!driver.init())
    Serial.println("init failed");
  pinMode(13, OUTPUT);
}

void loop()
{
  int j = 2;
  driver.send((uint8_t *)&j, sizeof(int));
  driver.waitPacketSent();
  
  digitalWrite(13, HIGH); // To oberve program without connecting Serial Monitor
  delay(200);
  Serial.print("sent ");
  Serial.println(j);
  digitalWrite(13, LOW); // To oberve program without connecting Serial Monitor

}

I compiles. I do not know if it is working because I am still working on the receiving side.

I am not so sure how to get the code you provided into the receiver. I have put it where it seems to make the most sense, however, I get:

Here is the receive code:

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile

#define LED1 11
#define LED2 12
RH_ASK driver;

void setup()
{
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  Serial.begin(9600);  // Debugging only
  if (!driver.init())
    Serial.println("init failed");
}

void loop()
{
//  uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
//  uint8_t buflen = sizeof(buf);
    int j = 0;  //received data go here
    int len = sizeof(int);  //expected size of data

    if (rf95.recv((uint8_t *)&j, &len)) {
    if (len == sizeof(int)) Serial.println(j);

// if (driver.recv(buf, &buflen)) // Non-blocking
//  {
   
    int i;

    // Message with a good checksum received, dump it.
    driver.printBuffer("Got:", buf, buflen);

    showA(); // checking the function call
    showB(); // checking the function call
    char printBuf = buf;    // added to display received character
    Serial.println(printBuf); // added to display received character
    
    // Added to call functions depenfing on the message received
    if (printBuf == "A") {
      showA();
    }
    if (printBuf == "B") {
      showB();
    }
  }


}

void showA() {
  digitalWrite(LED1, HIGH);
  delay (500);
  digitalWrite(LED1, LOW);
  delay (500);
}
void showB() {
  digitalWrite(LED2, HIGH);
  delay (500);
  digitalWrite(LED2, LOW);
  delay (500);
}
int j = 0;  //received data go here
    int len = sizeof(int);  //expected size of data

    if (rf95.recv((uint8_t *)&j, &len)) {
    if (len == sizeof(int)) Serial.println(j);

There is a working example of sending a command, to control an LED, or number of LEDs, on a remote receiver in this LoRa library;

The receiver will only accept the command, to switch the outputs, if there is a matching 'networkID' in the packet and the CRC of the data payload, sent with the packet, matches on receipt. The transmitter will keep sending the packet until it receives a secured acknowledge from the receiver.

You build the control packet for transmit like this;

LoRa.startWriteSXBuffer(0);             //start the write at SX12XX internal buffer location 0
LoRa.writeUint16(destinationNode);              //destination node for packet
LoRa.writeUint8(outputNumber);                  //output number on receiver
LoRa.writeUint8(onoroff);                       //0 for off, 1 for on
TXPayloadL = LoRa.endWriteSXBuffer();           //closes packet write and returns the length of the payload to send

The networkID and payloadCRC checking is automatic in the background.

The error message is clear:

'rf95' was not declared in this scope

This

  if (rf95.recv((uint8_t *)&j, &len))`

should be

  if (driver.recv((uint8_t *)&j, &len))

Thanks, I had already tried replacing "rf95" with "driver." It didn't work, I got this error:

which makes little sense because "driver.send. . . " worked just fine on the Tx side and it is using the same library

Post ALL the code that generated that error, using code tags.

Thanks, I had already tried replacing "rf95" with "driver."

Then why post the wrong code? You will get the wrong answers from the forum.

I tried to show what I was doing, but that wasn't working. I tried replacing "rf95" with "driver" after you had sent me the example. when it didn't compile that was the first thing I tried. That was after your first post (after I tried your suggestion), and before my second post.

I remain at a loss for how to send and receive, a single integer. I have spent the last couple of hours trying sandeepmistry's libraries, but that isn't working either. I also tried to use the examples at StewartsProjects, as linked to above. However, there is a chance that I am just getting too tired, his examples look nearly incomprehensible.

All I want to do is to send a single integer from one LoRa Feather board to another. Anything I have posted is an example of something that hasn't worked yet.

I have no problem sending a single integer (or other data), but since you won't post all the code corresponding to your attempt, together with the associated error message, I'm not able to help.

Good luck with your project!

I am a bit confused here, first, you are annoyed that I posted code that didn't work, but now you are saying that I should post all of my code.

please understand, I have tried close to a dozen different things. It seems a bit silly to post all of them and all iterations.

As far as error codes, Most of the code is not generating error codes, it just isn't working.

I do have some ideas. Seeing as I can pass character strings, I may try just spelling out the number, and then using some more IF statements to assign a value to that.

I have trouble believing that I am the only person that has ever wanted to pass an integer, yet there seem to be no examples of anyone else doing it.

If I get it to work, and the thread lifespan hasn't expired, I will post the code, but I am pretty sure that it will be ugly.

this example uses a UNO with a LoRa shield and a Adafruit feather 32u4 Lora (bothuses a RFM9x module) to send and receive BME280 sensor data
UNO transmitter

// RH_RF95 - UNO with Dragino LoRa shield -  transmit a structure

// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (transmitter)
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example Feather9x_RX

#include <SPI.h>
#include <RH_RF95.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define SEALEVELPRESSURE_HPA (1013.25)

struct __attribute__((packed)) BME280 {
  byte StructureID;  // identifies the structure type
  byte NodeID;       // ID of transmitting node
  int16_t seq;       // sequence number
  float temperature;
  float pressure;
  float altitude;
  float humidity;
} bme280 = { 1, 1, 0, 23.0, 1000.0, 100.0, .5 };

Adafruit_BME280 bme;  // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

/* for feather32u4 */
/*#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 7*/

/* for feather m0  
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 3
*/

/* for shield */
#define RFM95_CS 10
#define RFM95_RST 9
#define RFM95_INT 2




/* for ESP w/featherwing 
#define RFM95_CS  2    // "E"
#define RFM95_RST 16   // "D"
#define RFM95_INT 15   // "B"
*/

/* Feather 32u4 w/wing
#define RFM95_RST     11   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     2    // "SDA" (only SDA/SCL/RX/TX have IRQ!)
*/

/* Feather m0 w/wing 
#define RFM95_RST     11   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     6    // "D"
*/

/* Teensy 3.x w/wing 
#define RFM95_RST     9   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     4    // "C"
*/

// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 868.0

// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);

int BME280ok = 1;

void setup() {
  Wire.setClock(400000);
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);

  while (!Serial)
    ;
  Serial.begin(115200);
  delay(100);

  Serial.println("Uno LoRa shield BME280 TX Test!");
  int status = bme.begin(0x76);
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    //while (1) delay(10);
    BME280ok = 0;  // indicate failed
  } else Serial.println("BME280 sensor, found!");

  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);

  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    while (1)
      ;
  }
  Serial.println("LoRa radio init OK!");

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1)
      ;
  }
  Serial.print("Set Freq to: ");
  Serial.println(RF95_FREQ);

  // 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(23, false);
}

int16_t packetnum = 0;  // packet counter, we increment per xmission

void loop() {
  if (BME280ok) {  // if BME280 connected read data
    bme280.temperature = bme.readTemperature();
    bme280.pressure = bme.readPressure() / 100.0F;
    bme280.altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
    bme280.humidity = bme.readHumidity();
  } else {  // if not connected generate data
    bme280.temperature += 1.0;
    bme280.pressure += 10.0;
    bme280.altitude -= 3.0;
    bme280.humidity += 1.0;
  }
  Serial.println("Sending BME280 data to  to rf95_server");
  Serial.print("seq ");
  Serial.print(++bme280.seq);
  Serial.print(" Temperature = ");
  Serial.print(bme280.temperature);
  Serial.print("*C");
  Serial.print(" Pressure = ");
  Serial.print(bme280.pressure);
  Serial.print("hPa");
  Serial.print(" Approx. Altitude = ");
  Serial.print(bme280.altitude);
  Serial.print("m");
  Serial.print(" Humidity = ");
  Serial.print(bme280.humidity);
  Serial.println("%");
  rf95.send((byte *)&bme280, sizeof(bme280));
  Serial.println("Waiting for packet to complete...");
  delay(10);
  rf95.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  Serial.println("Waiting for reply...");
  delay(10);
  if (rf95.waitAvailableTimeout(1000)) {
    // Should be a reply message for us now
    if (rf95.recv(buf, &len)) {
      Serial.print("Got reply: ");
      Serial.println((char *)buf);
      Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);
    } else {
      Serial.println("Receive failed");
    }
  } else {
    Serial.println("No reply, is there a listener around?");
  }
  delay(3000);
}

Adafruit feather 32u4 LoRa receiver

// RH_RF95 - Adafruit Feather 32u4 LoRa - receive a structure 

// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (receiver)
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example Feather9x_TX

#include <SPI.h>
#include <RH_RF95.h>

struct __attribute__((packed)) BME280 {
  byte StructureID;  // identifies the structure type
  byte NodeID;       // ID of transmitting node
  int16_t seq;       // sequence number
  float temperature;
  float pressure;
  float altitude;
  float humidity;
} bme280;

/* for feather32u4 */
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 7

/* for feather m0  
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 3
*/

/* for shield 
#define RFM95_CS 10
#define RFM95_RST 9
#define RFM95_INT 2
*/


/* for ESP w/featherwing 
#define RFM95_CS  2    // "E"
#define RFM95_RST 16   // "D"
#define RFM95_INT 15   // "B"
*/

/* Feather 32u4 w/wing
#define RFM95_RST     11   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     2    // "SDA" (only SDA/SCL/RX/TX have IRQ!)
*/

/* Feather m0 w/wing 
#define RFM95_RST     11   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     6    // "D"
*/

/* Teensy 3.x w/wing 
#define RFM95_RST     9   // "A"
#define RFM95_CS      10   // "B"
#define RFM95_INT     4    // "C"
*/

// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 868.0

// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);

// Blinky on receipt
#define LED 13

void setup() {
  pinMode(LED, OUTPUT);
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);

  while (!Serial)
    ;
  Serial.begin(115200);
  delay(100);

  Serial.println("Feather LoRa RX Test!");

  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);

  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    while (1)
      ;
  }
  Serial.println("LoRa radio init OK!");

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1)
      ;
  }
  Serial.print("Set Freq to: ");
  Serial.println(RF95_FREQ);

  // 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(23, false);
}

void loop() {
  if (rf95.available()) {
    // Should be a message for us now
    uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(bme280);

    if (rf95.recv((byte *)&bme280, &len)) {
      digitalWrite(LED, HIGH);
      RH_RF95::printBuffer("Received: ", (byte *)&bme280, len);
      if(len != sizeof(bme280)) {
        Serial.println("***** packet wrong length! *****");
        return;
      }
      Serial.print("RSSI: ");
      Serial.print(rf95.lastRssi(), DEC);
      Serial.print(" seq ");
      Serial.print(bme280.seq);
      Serial.print(" Temperature = ");
      Serial.print(bme280.temperature);
      Serial.print("*C ");
      // Convert temperature to Fahrenheit
      Serial.print(1.8 * bme280.temperature + 32);
      Serial.print("*F");
      Serial.print(" Pressure = ");
      Serial.print(bme280.pressure);
      Serial.print("hPa");
      Serial.print(" Approx. Altitude = ");
      Serial.print(bme280.altitude);
      Serial.print("m");
      Serial.print(" Humidity = ");
      Serial.print(bme280.humidity);
      Serial.println("%");
      delay(10);
      static int16_t seqExpected = 0, seqErrors = 0;
      if (bme280.seq != seqExpected) {  // check for sequence error!
        Serial.print(" ***** seq number error expected ");
        Serial.print(seqExpected);
        Serial.print(" received ");
        Serial.print(bme280.seq);
        Serial.print("  seq  errors ");
        Serial.println(++seqErrors);
        seqExpected = bme280.seq;
      }
      seqExpected++;  // next sequence nunber expected

      // Send a reply
      delay(200);  // may or may not be needed
      uint8_t data[] = "receive OK";
      rf95.send(data, sizeof(data));
      rf95.waitPacketSent();
      Serial.println("Sent a reply");
      digitalWrite(LED, LOW);
    } else {
      Serial.println("Receive failed");
    }
  }
}

UNO transmitter serial monitor output

Uno LoRa shield BME280 TX Test!
BME280 sensor, found!
LoRa radio init OK!
Set Freq to: 868.00
Sending BME280 data to  to rf95_server
seq 1 Temperature = 21.27*C Pressure = 1019.87hPa Approx. Altitude = -54.98m Humidity = 44.49%
Waiting for packet to complete...
Waiting for reply...
Got reply: receive OK
RSSI: -98
Sending BME280 data to  to rf95_server
seq 2 Temperature = 21.28*C Pressure = 1019.87hPa Approx. Altitude = -55.01m Humidity = 44.37%
Waiting for packet to complete...
Waiting for reply...
Got reply: receive OK
RSSI: -98
Sending BME280 data to  to rf95_server
seq 3 Temperature = 21.29*C Pressure = 1019.91hPa Approx. Altitude = -55.27m Humidity = 44.38%
Waiting for packet to complete...
Waiting for reply...
Got reply: receive OK
RSSI: -98
Sending BME280 data to  to rf95_server
seq 4 Temperature = 21.28*C Pressure = 1019.92hPa Approx. Altitude = -55.35m Humidity = 44.27%
Waiting for packet to complete...
Waiting for reply...
Got reply: receive OK

Feather 32u4 receiver

Feather LoRa RX Test!
LoRa radio init OK!
Set Freq to: 868.00
Received: 
1 1 1 0 71 3D A8 41 56 F8 7E 44 BA 37 5C C2
0 E2 3A 42 
RSSI: -106 seq 1 Temperature = 21.03*C 69.85*F Pressure = 1019.88hPa Approx. Altitude = -55.05m Humidity = 46.72%
 ***** seq number error expected 40 received 1  seq  errors 18
Sent a reply
Received: 
1 1 2 0 0 0 AA 41 AD F7 7E 44 25 E1 5B C2
0 0 35 42 
RSSI: -106 seq 2 Temperature = 21.25*C 70.25*F Pressure = 1019.87hPa Approx. Altitude = -54.97m Humidity = 45.25%
Sent a reply
Received: 
1 1 3 0 7B 14 AA 41 3A FA 7E 44 F 36 5D C2
0 3C 33 42 
RSSI: -106 seq 3 Temperature = 21.26*C 70.27*F Pressure = 1019.91hPa Approx. Altitude = -55.30m Humidity = 44.81%
Sent a reply
Received: 
1 1 4 0 71 3D AA 41 74 F7 7E 44 16 C6 5B C2
0 4F 32 42 
RSSI: -106 seq 4 Temperature = 21.28*C 70.30*F Pressure = 1019.87hPa Approx. Altitude = -54.94m Humidity = 44.58%
Sent a reply
Received: 
1 1 5 0 71 3D AA 41 C F9 7E 44 21 99 5C C2
0 CA 31 42 
RSSI: -106 seq 5 Temperature = 21.28*C 70.30*F Pressure = 1019.89hPa Approx. Altitude = -55.15m Humidity = 44.45%
Sent a reply

By going through the replies here, and looking at more example code, I thought I was getting closer when I got to this on the receiver side:

16:21:13.512 -> Received:
16:21:13.512 -> E1
16:21:13.512 -> Got: ⸮⸮⸮⸮⸮⸮%
16:21:13.512 -> 255
16:21:13.512 -> RSSI: -9
16:21:13.560 -> Sent a reply

Unfortunately, when I went and changed the value being sent from the transmitter, the output remained the same.

I realize people want to see the compile errors, but there are none (other than the usual forgetting something like a ")" somewhere, which is promptly fixed).

I still am just trying to send a single integer, like a 1 (or 2, or whatever, just an integer) from the transmitter to the receiver, and have it arrive as an integer at the receiver (integer, hex, something that I can test for. . . I got really hopeful when I got the E1, but it didn't change when I changed the value of "radiopacket" on the transmitter).

Here is the current transmitter code:

// Feather9x_TX
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (transmitter)
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example Feather9x_RX
// from this webpage https://learn.adafruit.com/adafruit-feather-32u4-radio-with-lora-radio-module/using-the-rfm-9x-radio
// pinout for AdaFruit Feather 32u4 LoRa here: https://learn.adafruit.com/adafruit-feather-32u4-radio-with-lora-radio-module/pinouts

#include <SPI.h>
#include <RH_RF95.h>

//for feather32u4 
//#define RFM95_CS 8
//#define RFM95_RST 4
//#define RFM95_INT 7

// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 915.0

// Singleton instance of the radio driver

const int RFM95_CS = 8;   // this is added by me
const int RFM95_RST = 4;  // this is added by me 
const int RFM95_INT = 7;  // this is added by me

RH_RF95 rf95(RFM95_CS, RFM95_INT);

void setup() 
{
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);

  Serial.begin(9600);
//  while (!Serial) {
//    delay(1);
//  }

  delay(100);

  Serial.println("Feather LoRa TX Test!");

  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);

  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info");
    while (1);
  }
  Serial.println("LoRa radio init OK!");

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);
  
  // 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(23, false);
}

int16_t packetnum = 0;  // packet counter, we increment per xmission

void loop()
{
  delay(1000); // Wait 1 second between transmits, could also 'sleep' here!
  Serial.println("AF7JA Transmitting..."); // Send a message with callsign to rf95_server
  
  int radiopacket = 1;
  itoa(packetnum++, radiopacket, radiopacket);
    sprintf(radiopacket, 1, radiopacket, radiopacket);
  Serial.print("Sending "); Serial.println(radiopacket);
//  radiopacket[19] = 0;
  
  Serial.println("Sending...");
  delay(10);
  rf95.send((uint8_t *)&radiopacket, sizeof(int));

  Serial.println("Waiting for packet to complete..."); 
  delay(10);
  rf95.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  Serial.println("Waiting for reply...");
  if (rf95.waitAvailableTimeout(1000))
  { 
    // Should be a reply message for us now   
    if (rf95.recv(buf, &len))
   {
      Serial.print("Got reply: ");
      Serial.println((char*)buf);
      Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);    
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
  else
  {
    Serial.println("No reply, is there a listener around?");
  }

}

Here is the current receiver code:

#include <SPI.h>
#include <RH_RF95.h>

// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 915.0

const int RFM95_CS = 8;   // this is added by me
const int RFM95_RST = 4;  // this is added by me
const int RFM95_INT = 7;  // this is added by me
// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);

// Blinky on receipt
#define LED 13
#define LED1 11
#define LED2 12

void setup()
{
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);
  //
 Serial.begin(9600);
//    while (!Serial) {
//      delay(1);
//    }
  delay(100);
 showA();
 showB();
  Serial.println("Feather LoRa RX Test!");

  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);

  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info");
    while (1);
  }
  Serial.println("LoRa radio init OK!");

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);

  // 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(23, false);
}

void loop()
{
int buf = 0;
//int j = 0;
  if (rf95.available())
  {
    // Should be a message for us now
    uint8_t buf;
//    [RH_RF95_MAX_MESSAGE_LEN];
    int len = sizeof(buf);
  //  uint8_t len = 1;
//    sizeof(buf);

    if (rf95.recv((uint8_t*)&buf, sizeof(buf)))
    {
      // digitalWrite(LED, HIGH);
      RH_RF95::printBuffer("Received: ", buf, len);
      Serial.print("Got: ");
     Serial.println((char*)buf);
      Serial.println(buf);
      Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);
      int sentValue = buf;
      if (sentValue == 1) {
        showA();
      }
      if (sentValue == 2) {
        showB();
      }

      // Send a reply
      digitalWrite(LED, HIGH);
      uint8_t data[] = "AF7JA Says Hello";
      rf95.send(data, sizeof(data));
      rf95.waitPacketSent();
      Serial.println("Sent a reply");
      digitalWrite(LED, LOW);
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
}
void showA() {
  digitalWrite(LED1, HIGH);
  delay (500);
  digitalWrite(LED1, LOW);
  delay (500);
}
void showB() {
  digitalWrite(LED2, HIGH);
  delay (500);
  digitalWrite(LED2, LOW);
  delay (500);
}

you re-declared buf down to a byte??
watch out passing "int" to different systems..
size of int depends on system, 16 bit or 32 bits..

Remember way back to post #2? This is what I successfully use:

jremington, I don't doubt that the answer will include those lines of code, it is just a matter of figuring out how to make them work. In fact, I think I was working with the lines when I got some long hex arriving at the receiver. However, the hex didn't change when I tried changing the value being sent.

Part of what makes it so frustrating is that I have no way of knowing if the Tx code or the Rx code is the problem. I suspect that they are both a mess. As I said, I am sure this can be done. I will probably have time to give it another hour or two tomorrow.

Keep in mind, most of what I am doing is randomly stabbing. I have looked for thorough documentation of the various libraries and, as you can see in this thread, I have tried several different libraries. I remain surprised that this isn't a common need.

I can change the text travelling in both directions, so I know the devices are communicating. The challenge remains in passing an integer. And yes, I have tried sending a value instead of the text in the "hello" messages that are being passed back and forth. So far I haven't been able to make that work either.

No worries, don't mean no offense..
~q

The library mentioned in post #4 does have a packet logger receiver example that prints out the hex values of a received packet, which is handy for debugging such issues.

it was the Rx code

made some slight modifications to your code of post 12
transmitter incrementing int value on each loop() (note change frequency to 868MHz)

// Feather9x_TX
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (transmitter)
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example Feather9x_RX
// from this webpage https://learn.adafruit.com/adafruit-feather-32u4-radio-with-lora-radio-module/using-the-rfm-9x-radio
// pinout for AdaFruit Feather 32u4 LoRa here: https://learn.adafruit.com/adafruit-feather-32u4-radio-with-lora-radio-module/pinouts

#include <SPI.h>
#include <RH_RF95.h>

//for feather32u4 
//#define RFM95_CS 8
//#define RFM95_RST 4
//#define RFM95_INT 7

// Change to 434.0 or other frequency, must match RX's freq!
//#define RF95_FREQ 915.0
#define RF95_FREQ 868.0

// Singleton instance of the radio driver

const int RFM95_CS = 8;   // this is added by me
const int RFM95_RST = 4;  // this is added by me 
const int RFM95_INT = 7;  // this is added by me

RH_RF95 rf95(RFM95_CS, RFM95_INT);

void setup() 
{
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);

  Serial.begin(115200);
  while (!Serial) {
    delay(1);
  }

  delay(100);

  Serial.println("Feather LoRa TX Test!");

  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);

  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info");
    while (1);
  }
  Serial.println("LoRa radio init OK!");

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);
  
  // 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(23, false);
}

int16_t packetnum = 0;  // packet counter, we increment per xmission

void loop()
{
  delay(5000); // Wait 1 second between transmits, could also 'sleep' here!
  Serial.println("AF7JA Transmitting..."); // Send a message with callsign to rf95_server
  
  static int radiopacket = 1; // <<<<<
  radiopacket++;              // <<<<<  

  itoa(packetnum++, radiopacket, radiopacket);
    sprintf(radiopacket, 1, radiopacket, radiopacket);
  Serial.print("Sending "); Serial.println(radiopacket);
//  radiopacket[19] = 0;
  
  Serial.println("Sending...");
  delay(10);
  rf95.send((uint8_t *)&radiopacket, sizeof(int));

  Serial.println("Waiting for packet to complete..."); 
  delay(10);
  rf95.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  Serial.println("Waiting for reply...");
  if (rf95.waitAvailableTimeout(1000))
  { 
    // Should be a reply message for us now   
    if (rf95.recv(buf, &len))
   {
      Serial.print("Got reply: ");
      Serial.println((char*)buf);
      Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);    
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
  else
  {
    Serial.println("No reply, is there a listener around?");
  }

}

receiver corrected problem with if (rf95.recv((uint8_t*)&buf, &len))

#include <SPI.h>
#include <RH_RF95.h>

// Change to 434.0 or other frequency, must match RX's freq!
//#define RF95_FREQ 915.0
#define RF95_FREQ 868.0

const int RFM95_CS = 8;   // this is added by me
const int RFM95_RST = 4;  // this is added by me
const int RFM95_INT = 7;  // this is added by me
// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);

// Blinky on receipt
#define LED 13
#define LED1 11
#define LED2 12

void setup()
{
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);
  //
 Serial.begin(115200);
    while (!Serial) {
      delay(1);
    }
  delay(100);
 showA();
 showB();
  Serial.println("Feather LoRa RX Test!");

  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);

  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info");
    while (1);
  }
  Serial.println("LoRa radio init OK!");

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);

  // 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(23, false);
}

void loop()
{
int buf = 0;
//int j = 0;
  if (rf95.available())
  {
    // Should be a message for us now
    uint8_t buf=200;
//    [RH_RF95_MAX_MESSAGE_LEN];
     uint8_t len = sizeof(buf);             // <<<< 
  //  uint8_t len = 1;
//    sizeof(buf);

    if (rf95.recv((uint8_t*)&buf, &len))    // <<<<< 
    {
      // digitalWrite(LED, HIGH);
      RH_RF95::printBuffer("Received: ", buf, len);
      Serial.print("Got: ");
   //  Serial.println((char*)buf);
      Serial.println(buf);
      Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);
      int sentValue = buf;
      if (sentValue == 1) {
        showA();
      }
      if (sentValue == 2) {
        showB();
      }

      // Send a reply
      digitalWrite(LED, HIGH);
      uint8_t data[] = "AF7JA Says Hello";
      rf95.send(data, sizeof(data));
      rf95.waitPacketSent();
      Serial.println("Sent a reply");
      digitalWrite(LED, LOW);
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
}
void showA() {
  digitalWrite(LED1, HIGH);
  delay (500);
  digitalWrite(LED1, LOW);
  delay (500);
}
void showB() {
  digitalWrite(LED2, HIGH);
  delay (500);
  digitalWrite(LED2, LOW);
  delay (500);
}

Feather 32u4 transmitter output

Feather LoRa TX Test!
LoRa radio init OK!
Set Freq to: 868.00
AF7JA Transmitting...
Sending 2
Sending...
Waiting for packet to complete...
Waiting for reply...
No reply, is there a listener around?
AF7JA Transmitting...
Sending 3
Sending...
Waiting for packet to complete...
Waiting for reply...
Got reply: AF7JA Says Hello
RSSI: -71
AF7JA Transmitting...
Sending 4
Sending...
Waiting for packet to complete...
Waiting for reply...
Got reply: AF7JA Says Hello
RSSI: -72
AF7JA Transmitting...
Sending 5
Sending...
Waiting for packet to complete...
Waiting for reply...
Got reply: AF7JA Says Hello
RSSI: -71
AF7JA Transmitting...
Sending 6
Sending...
Waiting for packet to complete...
Waiting for reply...
Got reply: AF7JA Says Hello
RSSI: -71

Feather 32u4 receiver output

Feather LoRa RX Test!
LoRa radio init OK!
Set Freq to: 868.00
Received: 
B6 
Got: 2
RSSI: -72
Sent a reply
Received: 
6F 
Got: 3
RSSI: -73
Sent a reply
Received: 
EF 
Got: 4
RSSI: -73
Sent a reply
Received: 
EF 
Got: 5
RSSI: -73
Sent a reply
Received: 
77 
Got: 6
RSSI: -73
Sent a reply
Received: 
BD 
Got: 7
RSSI: -73
Sent a reply
Received: 
58 
Got: 8

you can see the received integer incrementing on each packet received

Thank you, the receiver now works.

Every other packet it is reporting that it received the value of "65" however, that is something that I can easily work around.

For later reference: the Rx code in 19 is the one that is working.