Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 1 month ago.
LoRa receiver
Hi! I am trying to use sx127x as receiver (transmitting looks alright). My code looks as follows
sx127x receiver
#include "sx127x_lora.h" #include "mbed.h" SX127x kom(PTD6, PTD7, PTD5, PTD4, PTA6, PTA7, PTC16, PTC13, PTA14); SX127x_lora Lora(kom); DigitalOut led_red(LED_RED); Serial pc(USBTX, USBRX); int main() { Lora.enable(); uint8_t data[8]; led_red = 1; //no light pc.baud(115200); Lora.start_rx(); //pc.printf("%x",kom.read_reg(0x01)); while(true) { while(Lora.service() != SERVICE_READ_FIFO); for(unsigned i = 0; i < 8; i++) { data[i] = kom.rx_buf[i]; pc.printf("%c",data[i]); } Lora.start_rx(); } }
Lora.service() function is always in SERVICE_NONE. Perhaps I have bad receiving code sequence but I don't know how to do it right. Thanks
Question relating to:

1 Answer
10 years, 1 month ago.
before you start_rx(), you must first set receiver to same settings as the transmitter side: Lora.setSf(), Lora.setBw() and kom.set_frf_MHz().
You should call kom.init() just before Lora.enable().
If you still have trouble, you can poll the REG_LR_IRQFLAGSMASK on receiver.
This is in both transceivers set equally. The problem was in bad connection. Btw: the code construction is good? I tried cut Lora.start_rx() from endless while loop and it works as well. But it receives individual characters, but not the message as it was sent. E.g. if I have in transmitter for(unsigned i = 0; i < 8; i++) kom.tx_buf[i] = 0xf; and in endless while loop Lora.start_tx(8), it receives only one character (in rx_buf).
posted by 06 Feb 2015