I am using LORA RFM98W with arduino for simple receiving and transmitting string of 8 byte using LORA RFM98w Module.
I receive interrupt on receiving end and size of packet of 8 bye. did not receive any transmitted message.
my seria windows shows
STATUS,-95,81,44,-11560,82
PKT,8
STATUS,-96,132
I am using LORA Ground Station library
code for TX
#include <avr/wdt.h>
#include <SPI.h>
#include "RFM98W.h"
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>
#define PAYLOAD_LENGTH 8
// UNCOMMENT ONE OF THESE BLOCKS, DEPENDING ON THE BOARD YOU USE.
// Seeeduino Mega (3.3V)
/*
#define SS_PIN 53
#define DIO0 A0
#define DIO5 A2
#define RST A1
*/
// Seeduino (3.3V)
#define SS_PIN 10
#define DIO0 A3
#define DIO5 A2
//#define RST A1
double Frequency = 431.650e6;
double FrequencyOffset = 0.0; // TODO: Automatic Frequency Correction
String In_Put;
char message[256];
unsigned char mes[10];
RFM98W rfm(SS_PIN, DIO0, DIO5);
LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup(){
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(0x27);
lcd.begin(16, 2); // initialize the lcd
lcd.setBacklight(255);
lcd.home(); lcd.clear();
lcd.print("LORA TX");
delay(100);
wdt_enable(WDTO_8S); // Enable watchdog timer, in case the SPI link dies.
wdt_reset();
rfm.setLoRaMode(Frequency);
rfm.setLoRaMode(Frequency + FrequencyOffset);
rfm.setupTX();
mes[0]='1';
mes[1]='2';
mes[2]='3';
mes[3]='4';
mes[4]='5';
mes[5]='l';
mes[6]='\r';
mes[7]='\n';
rfm.sendData(&message[0],8);
// rfm.sendData("12345\r\n",8);
lcd.print("LORA TX");
delay(100);
// rfm.startReceiving();
}
void loop(){
wdt_reset();
// rx_status();
/* if(rfm.checkInterrupt()){
get_packet();
}*/
wdt_reset();
delay(1000);
}
void get_packet(){
int packet_size = rfm.receiveMessage(message);
packet_info(); // Send packet info message before we send the packet itself.
Serial.print("PKT,");
Serial.println(packet_size);
Serial.write((uint8_t*)message, packet_size);
}
void rx_status(){
uint8_t modem_status = rfm.readRegister(REG_MODEM_STATUS);
int16_t rssi = rfm.getRSSI();
uint8_t freq_error = rfm.readRegister(REG_FREQ_ERROR);
uint8_t signal_detected = (modem_status&MODEM_STATUS_SIGNAL_DETECTED)>0;
uint8_t signal_sync = (modem_status&MODEM_STATUS_SIGNAL_SYNC)>0;
uint8_t rx_in_progress = (modem_status&MODEM_STATUS_RX_IN_PROGRESS)>0;
uint8_t got_header = (modem_status&MODEM_STATUS_GOT_HEADER)>0;
Serial.print("STATUS,");
Serial.print(rssi);
Serial.print(",");
Serial.print(modem_status);
Serial.println("");
}
void packet_info(){
int16_t packet_rssi = rfm.getRSSIPacket();
int8_t packet_snr = rfm.readRegister(REG_PACKET_SNR);
int32_t freq_error = rfm.getFrequencyError();
uint8_t lastMessageFlags = rfm.getLastMessageFlags();
Serial.print("PKTINFO,");
Serial.print(packet_rssi);
Serial.print(",");
Serial.print(packet_snr);
Serial.print(",");
Serial.print(freq_error);
Serial.print(",");
Serial.print(lastMessageFlags);
Serial.println("");
}
code For RX is
#include <avr/wdt.h>
#include <SPI.h>
#include "RFM98W.h"
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>
#define PAYLOAD_LENGTH 55
#define SS_PIN 10
#define DIO0 A3
#define DIO5 A2
//#define RST A1
// UNCOMMENT ONE OF THESE BLOCKS, DEPENDING ON THE BOARD YOU USE.
// Seeeduino Mega (3.3V)
/*
#define SS_PIN 53
#define DIO0 A0
#define DIO5 A2
#define RST A1
*/
LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars and 2 line display
// Seeduino (3.3V)
double Frequency = 431.650e6;
double FrequencyOffset = 0.0; // TODO: Automatic Frequency Correction
char message[256];
char mes[16];
RFM98W rfm(SS_PIN, DIO0, DIO5);
void setup(){
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(0x27);
lcd.begin(16, 2); // initialize the lcd
lcd.setBacklight(255);
lcd.home();
lcd.clear();
delay(1000);
lcd.setCursor(0, 0);
lcd.print("LORA RX ");
delay(1000);
wdt_enable(WDTO_8S); // Enable watchdog timer, in case the SPI link dies.
wdt_reset();
rfm.setLoRaMode(Frequency + FrequencyOffset);
rfm.startReceiving();
lcd.setCursor(0, 0);
lcd.print("LOOP START ");
}
void loop(){
unsigned char READ_FIFO_BASE_ADD;
wdt_reset();
rx_status();
if(rfm.checkInterrupt())
{
lcd.setCursor(0, 0);
lcd.print("INTERRUPT HIT");
get_packet();
rfm.receiveMessage(&message[0]);
lcd.setCursor(0, 0);
lcd.print("INTERRUPT HIT 1");
delay(100);
lcd.setCursor(0, 0);
lcd.print(mes);
Serial.println(message);
}
wdt_reset();
delay(1000);
}
void get_packet(){
int packet_size = rfm.receiveMessage(message);
packet_info(); // Send packet info message before we send the packet itself.
Serial.print("PKT,");
Serial.println(packet_size);
Serial.write((uint8_t*)message, packet_size);
}
void rx_status(){
uint8_t modem_status = rfm.readRegister(REG_MODEM_STATUS);
int16_t rssi = rfm.getRSSI();
uint8_t freq_error = rfm.readRegister(REG_FREQ_ERROR);
uint8_t signal_detected = (modem_status&MODEM_STATUS_SIGNAL_DETECTED)>0;
uint8_t signal_sync = (modem_status&MODEM_STATUS_SIGNAL_SYNC)>0;
uint8_t rx_in_progress = (modem_status&MODEM_STATUS_RX_IN_PROGRESS)>0;
uint8_t got_header = (modem_status&MODEM_STATUS_GOT_HEADER)>0;
Serial.print("STATUS,");
Serial.print(rssi);
Serial.print(",");
Serial.print(modem_status);
Serial.println("");
}
void packet_info(){
int16_t packet_rssi = rfm.getRSSIPacket();
int8_t packet_snr = rfm.readRegister(REG_PACKET_SNR);
int32_t freq_error = rfm.getFrequencyError();
uint8_t lastMessageFlags = rfm.getLastMessageFlags();
Serial.print("PKTINFO,");
Serial.print(packet_rssi);
Serial.print(",");
Serial.print(packet_snr);
Serial.print(",");
Serial.print(freq_error);
Serial.print(",");
Serial.print(lastMessageFlags);
Serial.println("");
}