FORUM

Semtech SX1268 RSSI Calculation

Hi there, I am very new in LoRa. I am unable to find the correct value of RSSI. For example, with 1m distance between Tx and Rx, I am getting -256 dBm packet RSSI, although with zero packet loss, I guess. The GitHub code is here: Here and
Here

def get_channel_rssi(self):
        GPIO.output(self.M1,GPIO.LOW)
        GPIO.output(self.M0,GPIO.LOW)
        time.sleep(0.1)
        self.ser.flushInput()
        self.ser.write(bytes([0xC0,0xC1,0xC2,0xC3,0x00,0x02]))
        time.sleep(0.5)
        re_temp = bytes(5)
        if self.ser.inWaiting() > 0:
            time.sleep(0.1)
            re_temp = self.ser.read(self.ser.inWaiting())
        if re_temp[0] == 0xC1 and re_temp[1] == 0x00 and re_temp[2] == 0x02:
            # print("the current noise rssi value: -{0}dBm".format(256-re_temp[3]))
            print("the last receive packet rssi value: -{0}dBm".format(256-re_temp[4]))
        else:
            # pass
            print("receive rssi value fail")

Any adjustments or how to calculate RSSI?

Hi @mithun.mukherjee - welcome on the developer portal!

Can you please elaborate on how you perform this RSSI measurement?

  • What are the functions you are calling?
  • In which mode is the transceiver?

The mode is WOR or Transmit mode
After RSSI is enabled in the transmit node, it seems that when I send the command 0xC0,0xC1,0xC2,0xC3 to obtain the RSSI value of packet and ambient noise.

This is the following code that I used:

def get_channel_rssi(self):
 GPIO.output(self.M1,GPIO.LOW)
 GPIO.output(self.M0,GPIO.LOW)
 time.sleep(0.1)
 self.ser.write(bytes([0xC0,0xC1,0xC2,0xC3,0x00,0x02]))
 time.sleep(0.5)
 re_temp = bytes(5)
 if self.ser.inWaiting() > 0:
 time.sleep(0.1)
 re_temp = self.ser.read(self.ser.inWaiting())
 if re_temp[0] == 0xC1 and re_temp[1] == 0x00 and re_temp[2] == 0x02:
 print(“Noise RSSI : -{0}dBm".format(re_temp[3]))
 print(“Packet RSSI: -{0}dBm".format(re_temp[4]))
 else:
 print("receive rssi value fail: ",re_temp)

The meaning of last two hex value in [0xC0,0xC1,0xC2,0xC3,0x00,0x02] is as follows: 0x00: Begin address and 0x02: is the number of register to read. The return value will be 0xC1 0x00 0x02 + Data, i.e., to say, 0xC1 + Begin address + number of register to read + Data of each registers

So, does it mean that re_temp[3] and re_temp[4] store the noise and packet RSSI, respectively?

After I run the code, I found that the re_temp[4] always returns integer value of 0.

Please correct me if I am doing anything wrong here.

There are actually different ways to get a RSSI value from the chip.

The first one is when you receive a packet (RxDone event). You can send a command sx126x_get_gfsk_pkt_status() or sx126x_get_lora_pkt_status() depending on the modulation you are using: you’ll get the value you are looking for.

The other way is more “manual”. You put the chip in RxMode with a call to sx126x_set_rx() - pay attention to the value of the timeout - and then you can request the RSSI with a call to sx126x_get_rssi_inst() while the chip is in RxMode.

You can find a reference implementation for the driver here (https://github.com/Lora-net/sx126x_driver)