Skip to content

Integrating Xandar Kardian Sensor Into Chirpstack

Sho edited this page Feb 22, 2023 · 11 revisions

Steps to integrate Xandar Kardian (XK) sensors into Chirpstack

Xandar Kardian People Counting Sensor

Prerequisites

  1. Connect the Xandar Kardian People Counting Sensor into the Xandar Kardian gateway (GW) as described in the installation manual https://www.xkcorp.com/company/manuals-and-datasheet/

  2. Make sure the GW is receiving signals from the connected sensor(s). You can verify this from the GW Radar tab. The Application number, Serial Number and data from the sensor(s) are visible on the tab.

  3. Take note of the GW EUI number and the GW product code or model number (e.g. XL300). You may use the product code or model number for naming purposes.

  4. Secure a copy of the Javascript codec code from Xandar Kardian.

Steps

  1. Login into Chirpstack WebUI (Web User Interface). The Chirpstack is a software module in the controller/server. It talks with Lorawan enabled devices like the XK Gateway. The default Chirpstack WebUI port is 8080.

Example:

http://192.168.15.190:8080/
  1. Create a gateway profile for Xandar Kardian GW.

Use the following settings. Make sure to enable the channels from 8-15.

Name: <your desired name for the gateway profile, e.g. au915-1>
Stats interval (seconds): 30
Enabled channels: 8, 9, 10, 11, 12, 13, 14, 15
  1. Create a gateway using the gateway profile created in Step#2. You should have already created a service profile prior to this step. In the service profile make sure the "Add gateway meta-data" option is ticked.

  2. Create a device profile for Xandar Kardian devices.

Use the following settings. Leave the default values if not included below.

General:
  - Device profile name: <Your desired name for the device profile, e.g. XK300>
  - LoRaWAN MAC version: 1.0.3
  - LoRaWAN Regional Parameters revision: B

JOIN (OTAA / BP):
  - Device supports OTAA: Checked

CODEC:
  - Decode JS codec code: <Copy and paste the decode JS codec code from XK>
  - Encode JS codec code: <Copy and paste the encode JS codec code from XK>
  1. Create an application instance if you have not created one. Select the service profile from Step#3.

  2. Open the application instance you created in Step#5. Switch to DEVICES tab.

  3. Create a new device instance.

Use the following settings. Leave the default values if not included below.

GENERAL:
  - Device name: <Your desired device name. You can use the product code or model number e.g. XL300)>
  - Device description: <The device description>
  - Device EUI: <The device EUI. See the Prerequisites section>
  - Device Profile: <Select the device profile you created in Step#4>
  - Disable frame-counter validation: Checked
  1. Update the frequency plan of the controller/server and GW. This is needed because the GW by default is set on the 1st band. SSH into the controller.

Example:

ssh pi@192.168.15.190

Execute the update scripts. The affected modules will be restarted automatically. You do not need to restart them.

cd /home/pi/lorawan-complete-2.3.1
sudo bash change-freq-gateway.sh -b 1 -c pico
sudo bash change-freq-server.sh -b 1
  1. Check the Chirpstack packet forwarder logs if it is receiving the signals from the XK GW.
sudo journalctl -u lorawan-gateway.service -f

You should see similar logs like below.

---
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: ##### 2023-02-21 13:57:32 GMT #####
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: ### [UPSTREAM] ###
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # RF packets received by concentrator: 1
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # CRC_OK: 100.00%, CRC_FAIL: 0.00%, NO_CRC: 0.00%
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # RF packets forwarded: 1 (36 bytes)
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # PUSH_DATA datagrams sent: 2 (335 bytes)
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # PUSH_DATA acknowledged: 100.00%
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: ### [DOWNSTREAM] ###
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # PULL_DATA sent: 3 (100.00% acknowledged)
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # PULL_RESP(onse) datagrams received: 0 (0 bytes)
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # RF packets sent to concentrator: 0 (0 bytes)
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # TX errors: 0
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # TX rejected (collision packet): 0.00% (req:1, rej:0)
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # TX rejected (collision beacon): 0.00% (req:1, rej:0)
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # TX rejected (too late): 0.00% (req:1, rej:0)
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # TX rejected (too early): 0.00% (req:1, rej:0)
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: ### [JIT] ###
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: src/jitqueue.c:448:jit_print_queue(): INFO: [jit] queue is empty
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: ### [GPS] ###
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: # GPS sync is disabled
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: ##### END #####
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: INFO: host/sx1301 time offset=(1676986469s:214875µs) - drift=-3µs
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: JSON up: {"stat":{"time":"2023-02-21 13:57:32 GMT","rxnb":1,"rxok":1,"rxfw":1,"ackr":100.0,"dwnb":0,"txnb":0}}
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: INFO: [up] PUSH_ACK received in 4 ms
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: INFO: Received pkt from mote: 00D6BAEE (fcnt=4530)
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: JSON up: {"rxpk":[{"tmst":1385932366,"chan":1,"rfch":0,"freq":917.000000,"stat":1,"modu":"LORA","datr":"SF7BW125","codr":"4/5","lsnr":9.8,"rssi":-79,"size":36,"data":"QO661gCAshEClrsXveSNEnXx3rlja1hBq4NCG2VqPxj9JdnW"}]}
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: INFO: [up] PUSH_ACK received in 1 ms
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: INFO: [down] PULL_ACK received in 1 ms
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: INFO: [down] PULL_ACK received in 0 ms
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: INFO: Received pkt from mote: 00D6BAEE (fcnt=4531)
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: JSON up: {"rxpk":[{"tmst":1406081350,"chan":0,"rfch":0,"freq":916.800000,"stat":1,"modu":"LORA","datr":"SF7BW125","codr":"4/5","lsnr":10.2,"rssi":-79,"size":36,"data":"QO661gCAsxECx0JRWfcZySYdl0PVm6gr4Vm6emNVzBGZpjRC"}]}
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: INFO: [up] PUSH_ACK received in 3 ms
Feb 22 00:58:35 raspberrypi lora_pkt_fwd[23616]: INFO: [down] PULL_ACK received in 1 ms
---
  1. View the device data (decoded) sent from the GW in Chirpstack. Open the device instance created in Step#7.

Go to Applications -> application instance -> device instance

Switch to the "DEVICE DATA" tab. The tab shows the decoded messages (in JSON) sent from the GW.

Example:

applicationID:"1"
applicationName:"default-app"
deviceName:"XK300"
devEUI:"60c5a8fffe78db29"
adr:true
dr:5
fCnt:6457
fPort:2
data:"MDMwMTAwMzA3MDAwNzMzMTAzMzAxODk="
appNum:"30"
longTermIndex:"0189"
peopleNum:"033"
presenceStatus:"1"
serialNum:"100307000733"
tags:
confirmedUplink:false
devAddr:"00d6baee"
publishedAt:"2023-02-22T00:44:08.260886247Z"
deviceProfileID:"23e5b639-6fbb-429e-8570-7435fe9e24c7"
deviceProfileName:"XK300"
  1. Check for MQTT publish messages from Chirpstack. You can check and view the published messages on the controller from the command line (via SSH session, see Step#8).
mosquitto_sub -h 127.0.0.1 -p 1883 -t '#'

Example MQTT published message from a XK people counting sensor

{"applicationID":"1","applicationName":"default-app","deviceName":"XK300","deviceProfileName":"XK300","deviceProfileID":"23e5b639-6fbb-429e-8570-7435fe9e24c7","devEUI":"60c5a8fffe78db29","rxInfo":[{"gatewayID":"3338333035003e00","uplinkID":"4de598c9-d374-4051-a40c-2250027c77ec","name":"default-gateway","rssi":-63,"loRaSNR":9,"location":{"latitude":0,"longitude":0,"altitude":0}}],"txInfo":{"frequency":916800000,"dr":5},"adr":true,"fCnt":3366,"fPort":2,"data":"MDMwMTAwMzA3MDAwNzMzMDAwMDAwMDE=","object":{"Radar0":{"appNum":"30","longTermIndex":"0001","peopleNum":"000","presenceStatus":"0","serialNum":"100307000733"}}}