Replies: 6 comments 5 replies
-
I cannot answer the question (for that we must summon @jgromes the Great), but I do have a question for you to answer in the meantime: what is your transmission source? Is it another SX1276, or an SX1262, or something else (if so, what is it)? |
Beta Was this translation helpful? Give feedback.
-
Hi, sorry to disturb your slumber 😉 The original code is not suitable for sharing, but knocked up a reasonable facsimile using the FSK modem example. The sender is a Lillygo TTGO (ESP32 WROOM with a sx1276). The receiver is a custom board which has a few Waveshare Core1262 modules on it, connected to an ESP32 WROOM. These modules are connected together on a shared bus, with different chip select lines selecting for each one. The CS lines are inverted, so have (crudely...) altered the RadioLib library to account for that (can't for the life of me imagine how that could affect things). So here's the sender code:
// include the library
#include <RadioLib.h>
#define SERIAL_BAUDRATE 4000000
// Lilygo TTGO (SX1276)
////////////////////////////////////////
// SPI clock frequency
#define RADIO_SPI_SCK_FREQ 10000000
// Pins used by the radio transceiver module
#define RADIO_SPI_SCK 5
#define RADIO_SPI_MISO 19
#define RADIO_SPI_MOSI 27
#define RADIO_SPI_CS 18
#define RADIO_SPI_RST 23
#define RADIO_SPI_IRQ 26
// FSK configuration
////////////////////////////////////////
#define FSK_CFG_TX_PWR 2
#define FSK_CFG_BAND 869.8
// Bit rate: 19.2k
#define FSK_CFG_BIT_RATE 19.2
#define FSK_CFG_FREQUENCY_DEVIATION 20
#define FSK_CFG_RX_BANDWIDTH 50
#define FSK_CFG_PREAMBLE_LEN 16
#define FSK_CFG_SYNC_WORD { 'H', 'L', 'P' }
#define FSK_CFG_SYNC_WORD_LEN 3
#define FSK_CFG_RSSI_SAMPLES 1
#define FSK_CFG_ENCODING RADIOLIB_ENCODING_WHITENING
#define FSK_CFG_DATA_SHAPING RADIOLIB_SHAPING_0_5
SX1276 radio = new Module(RADIO_SPI_CS, RADIO_SPI_IRQ, RADIO_SPI_RST);
void setup() {
Serial.begin(SERIAL_BAUDRATE);
// Setup for radio module hardware
SPI.begin(RADIO_SPI_SCK, RADIO_SPI_MISO, RADIO_SPI_MOSI, RADIO_SPI_CS);
// Set SPI bus frequency
SPI.setFrequency(RADIO_SPI_SCK_FREQ);
// initialize SX1276 FSK modem with default settings
Serial.print(F("[SX1276] Initializing ... "));
int state = radio.beginFSK();
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true);
}
// Select FSK, not OOK
if (radio.setOOK(false) != RADIOLIB_ERR_NONE) {
Serial.println(" Error initialising radio module: failed to select FSK mode");
while (true);
}
// Configure FSK transceiver module
if (radio.setFrequency(FSK_CFG_BAND) == RADIOLIB_ERR_INVALID_FREQUENCY) {
Serial.println(" Error initialising radio module: invalid frequency");
while (true);
}
if (radio.setBitRate(FSK_CFG_BIT_RATE) == RADIOLIB_ERR_INVALID_BIT_RATE) {
Serial.println(" Error initialising radio module: invalid bit rate");
while (true);
}
if (radio.setFrequencyDeviation(FSK_CFG_FREQUENCY_DEVIATION) == RADIOLIB_ERR_INVALID_FREQUENCY_DEVIATION) {
Serial.println(" Error initialising radio module: invalid frequency deviation");
while (true);
}
if (radio.setAFCBandwidth(FSK_CFG_RX_BANDWIDTH) == RADIOLIB_ERR_INVALID_RX_BANDWIDTH) {
Serial.println(" Error initialising radio module: invalid AFC Rx bandwidth");
while (true);
}
if (radio.setRxBandwidth(FSK_CFG_RX_BANDWIDTH) == RADIOLIB_ERR_INVALID_RX_BANDWIDTH) {
Serial.println(" Error initialising radio module: invalid Rx bandwidth");
while (true);
}
if (radio.setPreambleLength(FSK_CFG_PREAMBLE_LEN) == RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH) {
Serial.println(" Error initialising radio module: invalid preamble length");
while (true);
}
uint8_t sync_word[] = FSK_CFG_SYNC_WORD;
if (radio.setSyncWord(sync_word, FSK_CFG_SYNC_WORD_LEN) != RADIOLIB_ERR_NONE) {
Serial.println(" Error initialising radio module: invalid sync word");
while (true);
}
if (radio.setRSSIConfig(FSK_CFG_RSSI_SAMPLES) == RADIOLIB_ERR_INVALID_NUM_SAMPLES) {
Serial.println(" Error initialising radio module: invalid RSSI sample average");
while (true);
}
if (radio.setEncoding(FSK_CFG_ENCODING) == RADIOLIB_ERR_INVALID_ENCODING) {
Serial.println(" Error initialising radio module: invalid encoding scheme");
while (true);
}
if (radio.setDataShaping(FSK_CFG_DATA_SHAPING) == RADIOLIB_ERR_INVALID_DATA_SHAPING) {
Serial.println(" Error initialising radio module: invalid data shaping");
while (true);
}
if (radio.setOutputPower(FSK_CFG_TX_PWR, false) == RADIOLIB_ERR_INVALID_OUTPUT_POWER) {
Serial.println(" Error initialising radio module: invalid output power");
while (true);
}
// Disable CRC generation
radio.setCRC(false);
}
void loop() {
// FSK modem can use the same transmit/receive methods
// as the LoRa modem, even their interrupt-driven versions
// NOTE: FSK modem maximum packet length is 63 bytes!
// transmit FSK packet
int state = radio.transmit("Hello World!");
/*
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
0x89, 0xAB, 0xCD, 0xEF};
int state = radio.transmit(byteArr, 8);
*/
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("[SX1276] Packet transmitted successfully!"));
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
Serial.println(F("[SX1276] Packet too long!"));
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
Serial.println(F("[SX1276] Timed out while transmitting!"));
} else {
Serial.println(F("[SX1276] Failed to transmit packet, code "));
Serial.println(state);
}
// // receive FSK packet
// String str;
// state = radio.receive(str);
// /*
// byte byteArr[8];
// int state = radio.receive(byteArr, 8);
// */
// if (state == RADIOLIB_ERR_NONE) {
// Serial.println(F("[SX1278] Received packet!"));
// Serial.print(F("[SX1278] Data:\t"));
// Serial.println(str);
// } else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
// Serial.println(F("[SX1278] Timed out while waiting for packet!"));
// } else {
// Serial.println(F("[SX1278] Failed to receive packet, code "));
// Serial.println(state);
// }
delay(1000);
} The receiver code:
// The chip select lines on this board are 'weird'
// So the library has been updated to reflect this
// So need this
#define RADIOLIB_GODMODE true
// include the library
#include <RadioLib.h>
// Serial baudrate
#define SERIAL_BAUDRATE 1000000
// ESP32 WROOM / Waveshare Core1262
////////////////////////////////////////
// SPI clock frequency
#define RADIO_SPI_SCK_FREQ 10000000
// Pins used by the radio transceiver module
#define RADIO_SPI_SCK 18
#define RADIO_SPI_MISO 19
#define RADIO_SPI_MOSI 23
#define RADIO_SPI_CS 5
#define RADIO_SPI_RST 4
#define RADIO_SPI_IRQ 21
#define RADIO_SPI_BUSY 22
#define SPI_CSEXTRA_X 16
#define SPI_CSEXTRA_Y 17
#define RADIO_TCXO_VLTG 1.8
#define RADIO_TCXO_STRTUP 5000
// FSK configuration
////////////////////////////////////////
#define FSK_CFG_RX_GAIN false
#define FSK_CFG_BAND 869.8
// Bit rate: 19.2k
#define FSK_CFG_BIT_RATE 19.2
#define FSK_CFG_FREQUENCY_DEVIATION 20
#define FSK_CFG_RX_BANDWIDTH 58.6
#define FSK_CFG_PREAMBLE_LEN 16
#define FSK_CFG_SYNC_WORD { 'H', 'L', 'P' }
#define FSK_CFG_SYNC_WORD_LEN 3
#define FSK_CFG_RSSI_SAMPLES 1
#define FSK_CFG_ENCODING RADIOLIB_ENCODING_WHITENING
#define FSK_CFG_DATA_SHAPING RADIOLIB_SHAPING_1_0
SX1262 radio = new Module(RADIO_SPI_CS, RADIO_SPI_IRQ, RADIO_SPI_RST, RADIO_SPI_BUSY);
void setup() {
Serial.begin(SERIAL_BAUDRATE);
// Invert radio's CS logic
radio.mod->hal->CsLevelLow = radio.mod->hal->GpioLevelHigh;
radio.mod->hal->CsLevelHigh = radio.mod->hal->GpioLevelLow;
// Configure additional SPI CS lines
pinMode(SPI_CSEXTRA_X, OUTPUT);
digitalWrite(SPI_CSEXTRA_X, LOW);
pinMode(SPI_CSEXTRA_Y, OUTPUT);
digitalWrite(SPI_CSEXTRA_Y, LOW);
// Setup for radio module hardware
SPI.begin(RADIO_SPI_SCK, RADIO_SPI_MISO, RADIO_SPI_MOSI, RADIO_SPI_CS);
// Set SPI bus frequency
SPI.setFrequency(RADIO_SPI_SCK_FREQ);
// initialize SX1262 FSK modem with default settings
Serial.print(F("[SX1262] Initializing ... "));
int state = radio.beginFSK();
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true);
}
// Configure TCXO
if (radio.setTCXO(RADIO_TCXO_VLTG, RADIO_TCXO_STRTUP) != RADIOLIB_ERR_NONE) {
Serial.println(" Error initialising radio module: failed to configure TCXO");
while (true);
}
// Configure FSK transceiver module
if (radio.setFrequency(FSK_CFG_BAND) == RADIOLIB_ERR_INVALID_FREQUENCY) {
Serial.println(" Error initialising radio module: invalid frequency");
while (true);
}
if (radio.setBitRate(FSK_CFG_BIT_RATE) == RADIOLIB_ERR_INVALID_BIT_RATE) {
Serial.println(" Error initialising radio module: invalid bit rate");
while (true);
}
if (radio.setFrequencyDeviation(FSK_CFG_FREQUENCY_DEVIATION) == RADIOLIB_ERR_INVALID_FREQUENCY_DEVIATION) {
Serial.println(" Error initialising radio module: invalid frequency deviation");
while (true);
}
if (radio.setRxBandwidth(FSK_CFG_RX_BANDWIDTH) == RADIOLIB_ERR_INVALID_RX_BANDWIDTH) {
Serial.println(" Error initialising radio module: invalid Rx bandwidth");
while (true);
}
if (radio.setPreambleLength(FSK_CFG_PREAMBLE_LEN) == RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH) {
Serial.println(" Error initialising radio module: invalid preamble length");
while (true);
}
uint8_t sync_word[] = FSK_CFG_SYNC_WORD;
if (radio.setSyncWord(sync_word, FSK_CFG_SYNC_WORD_LEN) != RADIOLIB_ERR_NONE) {
Serial.println(" Error initialising radio module: invalid sync word");
while (true);
}
if (radio.setEncoding(FSK_CFG_ENCODING) == RADIOLIB_ERR_INVALID_ENCODING) {
Serial.println(" Error initialising radio module: invalid encoding scheme");
while (true);
}
if (radio.setDataShaping(FSK_CFG_DATA_SHAPING) == RADIOLIB_ERR_INVALID_DATA_SHAPING) {
Serial.println(" Error initialising radio module: invalid data shaping");
while (true);
}
if (radio.setRxBoostedGainMode(FSK_CFG_RX_GAIN, true) != RADIOLIB_ERR_NONE) {
Serial.println(" Error initialising radio module: invalid gain");
while (true);
}
// Disable CRC generation
radio.setCRC(false);
}
void loop() {
// // transmit FSK packet
// int state = radio.transmit("Hello World!");
// /*
// byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
// 0x89, 0xAB, 0xCD, 0xEF};
// int state = radio.transmit(byteArr, 8);
// */
// if (state == RADIOLIB_ERR_NONE) {
// Serial.println(F("[SX1262] Packet transmitted successfully!"));
// } else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
// Serial.println(F("[SX1262] Packet too long!"));
// } else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
// Serial.println(F("[SX1262] Timed out while transmitting!"));
// } else {
// Serial.println(F("[SX1262] Failed to transmit packet, code "));
// Serial.println(state);
// }
// receive FSK packet
String str;
int state = radio.receive(str);
float rssi = radio.getRSSI(true);
/*
byte byteArr[8];
int state = radio.receive(byteArr, 8);
*/
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("[SX1262] Received packet!"));
Serial.print(F("[SX1262] Data:\t"));
Serial.print(str);
Serial.print("\t\tRSSI: ");
Serial.println(rssi);
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
Serial.println(F("[SX1262] Timed out while waiting for packet!"));
} else {
Serial.println(F("[SX1262] Failed to receive packet, code "));
Serial.println(state);
}
} Log files of the terminal session, showing average RSSI does not change whether definition 'FSK_CFG_RX_GAIN' is true or false. As to the antenna, I'm working on this remotely so can't check myself, but I believe the antenna is suitable for the selected frequency. Thanks for any insights. |
Beta Was this translation helpful? Give feedback.
-
BUSY & IRQ are 'normal' hence why I needed to get creative with the CS line. Yep, overriding the HAL would be the way to go long term, but this is a quick and dirty test. I have access (now) to another sx1262 module (LillyGo T3S3) which I can try, but I expect the same results..
Neither. It is designed as an 868 antenna, but I have no way to measure that this end. As to the dropped packets, if you take a look at the sender code, I added a 1 second delay to the loop (so as not to be spamming the air waves). Here are the logs with that removed: |
Beta Was this translation helpful? Give feedback.
-
Okay. To remove any doubts, I swapped out the custom board for a Lillygo T3S3 which has a sx1262 module on it. I also did a completely fresh install of RadioLib to remove any of my 'weirdness'. Sender code:
Receiver code:
And the results! Rx Gain on:
Rx Gain off:
There is slight variation in the RSSI +-0.5, so I would say it is receiving. But no visible variation with Rx Gain on or off. Weird! |
Beta Was this translation helpful? Give feedback.
-
I hope you have lots of money to pay for the courts, fines and lawyers from breaching almost every air time law anywhere? Whilst you are moving funds, perhaps wonder how it helps us to help you with such a long long log of repetition?? |
Beta Was this translation helpful? Give feedback.
-
I did some testing on my own, and I can confirm the behavior is not what I would expect. Enabling or disabling the boosted Rx gain doesn't seem to influence the actual values of the packet or instant RSSI (nor LoRa SNR for that matter) for FSK or LoRa modem. And I can also see the value in the register updating, as expected. So TL;DR, I don't know. It is possible we are just using it incorrectly, maybe it has to be sent at a specific time (e.g. before something else is configured). The right people to ask would be the manufcaturer, i.e. Semtech. Unfoprutnately they took down their developer forum, so right now the only public communication channel is their git repositories. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm hoping that somebody can put me out of my misery on this one.
Have an SX1262 setup to receive FSK packets, no problem. However noticed that the RSSI for the packets was substantially lower (10-20 db) in comparison to a sx1276 that I also have setup. Having done some Googling saw some mention of a similar situation and it being resolved by enabling Rx Boosted Gain. Having included that in my code I found it made absolutely no difference. I checked my code, and it's looks like it's writing the correct values to the registers, read back the register and it is also what I expect...
Should I expect Rx Boosted Gain to increase the RSSI for FSK packets, or am I being a moron...
Thanks for any input.
Beta Was this translation helpful? Give feedback.
All reactions