RSSI in Python

Hi all,

I was wondering how I can get the RSSI value from my XBee devices using the Python libraries?

Best regards
Kenneth

Hi kfc,

The RSSI value can come in a few different forms from the XBee device. The simplest would be to query the ‘DB’ value from the device to get the RSSI value of the last received packet.

If you are using the python interpreter on a Digi Gateway product, this could be done like so:

import zigbee, struct
rssi_raw = zigbee.ddo_get_param(‘[00:13:a2:00:40:0a:12:96]!’, ‘DB’)

rssi_val = struct.unpack(‘=B’, rssi_raw)

We do two things in the above code. First we query the address ‘[00:13:a2:00:40:0a:12:96]!’ for its DB value using the zigbee.ddo_get_param() call, then we use the struct.unpack() function to cast the output of the function as a character.

Casting the output as a character is necessary when receiving data through the ddo_get_param() function. Everything received is a binary packed string.

Other methods for getting the RSSI value from a node without using a Digi Gateway are going to depend on your particular setup.

Mawr

Hi Mawr,

I also utilized your rssi code, thank you for that. Do you know the range for the rssi values it gives? I get something like (37,) or (38,) when the radio and gateway are next to each other and the number gets bigger when distance grows. Does it have some kind of maximum and minimum values? I have connectport X8 gateway and Xbee series 2 modules.

Thanks

-Matalalento-

Hi again Mawr,

referring to your code:

import zigbee, struct
rssi_raw = zigbee.ddo_get_param(‘[00:13:a2:00:40:0a:12:96]!’, ‘DB’)

rssi_val = struct.unpack(‘=B’, rssi_raw)

If the node (in this case [00:13 … :96]) is unavailable the code seems to try to search for the DB value for over 30 seconds before it finally sends and exception error “error fetching DDO parameter”.

Do you know if there would be some timeout for this so I wouldnt need to wait so long in case the node doesnt respond?

thanks again!

-Matalalento-

Hi Mawr, I’m using the LQI and RSSI, value; first I will want to know in what datasheet is the information about the RSSI value, I already readied the following datasheets:
ConnectPort X Family User’s Guide
Digi Connect Family
XBee/XBee-PRO ZB RF Modules

Now, the gateway that I’m using (connectport X4 S2 ethernet, X4-B11-E-A) get the LQI values (by python commands) between nodes, for example if we have 3 nodes a, b, c the gateway get the LQI value between the node a and b, a and c, b and c, ¿can i get the RSSI values between the nodes (the same as in the LQI)?, now, ¿the LQI values obtained, are an average of the LQI value of node a with respect to the b and the b with respect to the a? or ¿how the gateway know about the LQI values between nodes?, cause maybe the LQI value obtained from the node a with respect to the b is not the same from the node b with respect to the a.

Any documentation (explaining the LQI and RSSI calculations and description) will be help full, the previous datasheet only explain too little about the both values (explain more about RSSI), here is a list of the devices that I’m using:

ConnectPort X4 - ZNet 2.5 with ethernet. (X4-B11-E-A)
XBee RS-485 Adapter - ZNet 2.5 (formerly Series 2) (XA-B14-CS3R)
XBee ZB/ZNet 2.5 Development Kit w/ 2 XBee-PRO modules & 3 regular XBee modules (XB24-BPDK)

Hi Matalalento,

Because the DB register is an 8 bit register, at the very most it will have a range of 0-255. I did a quick check through the manual and its measured in negative dBm, in other words, the lower the number the RSSI value is, the stronger the signal strength. For example, if the code above returns a 20, that indicates a stronger signal then if it returned a 40.

Keep in mind the signal strength is only measuring the last hop of the transmission, and the last received packet. For accurate signal strength testing, one would have to take many measurements over time from each hop on the route.

Hi Matalalento,

The amount of time for the command to return varies depending on the following properties and conditions:

If the 16 bit address of the node is not known, a network address discovery takes place. If the 16 bit address node is not discovered at this time, the command will return with an error at this time.

If the 16 bit address is known, but a route is not defined in the transmitter’s routing table, a route discovery will take place. If the route is not discovered, the command will return with an error at this time.

Once the 16 bit address and the route is defined, a transmission will take place.

There are 2 timeout categories defined here:

Transmitting to a router or coordinator
Transmitting to a child end device

Transmitting to a router or coordinator has its timeout in ms defined to:

3 * ((50 * NH) + 100)

NH = 30 (Default on ZB firmware)

3 * ((50 * 30) + 100) = 1600 or 1.6 seconds.

Transmitting to a child end device has a timeout dependent on the SP parameter, with the minimum buffer time of 1.2 seconds:

3 * ((50 * NH) + (1.2 * SP))

NH = 30
SP = 32 (Default on ZB firmware)

3 * ((50 * 30) + (1.2 * 32)) = 4615 or 4.6 seconds

Timeouts can be tricky! The above information only applies to the ZB RF protocol.

Mawr

HI balart40 , I am in need of the python code to read LQI values Can you help us with your complete code for our work.

How are you fetching the LQI value? Are you sending a ZDP (ZigBee Device Profile) request to the ZDO endpoint, cluster 0x8031?

If so, the LQI value is defined in the ZigBee specification. The way it is derived is complex and only a portion of it is computed from RSSI.

Jordan

Yes I’m requesting the LQI value with the cluster 0x31, i already readied the zigbee specification, my question about the calculation of the LQI because i thought that the zigbee devices of digi have a specific way to calculate it, in the zigbee specification say how to calculate the link cost (3.6.3.1 Routing Cost, pages 413,414) but the variable “pl” (probability of packet delivery on the link l) is not explained.

Does digi zigbee devices have a specific way to calculate the LQI, if so is there documentation about that?

My application is on python, i already getting the LQI values, now that it see that is possible to get the RSSI values (by python) with the previous code:

import zigbee, struct
rssi_raw = zigbee.ddo_get_param(‘[00:13:a2:00:40:0a:12:96]!’, ‘DB’)

rssi_val = struct.unpack(‘=B’, rssi_raw)

With the LQI request i can get the value between nodes (not from nodes to the gateway) with the previous code (or other way by python code )

can i get the RSSI values between nodes?

I ask this cause if not, i want to see if there is a way to calculate RSSI from LQI, and if possible calculate SNR from LQI