1、sx1268原厂只有基于单片机的参考代码:https://github.com/Lora-net/LoRaMac-node
2、如果基于linux平台使用,可以使用 github上sx1268代码
https://github.com/YukiWorkshop
https://github.com/YukiWorkshop/sx126x_linux_driver
需要Linux4.8以上才能使用。
3、调试过程供电和晶振都会影响到DIO的输出,需要测试各种电源和晶振。
4、可以通过测试用例先测试下spi读写是否是否ok。(注意cs引脚需要另外选择)
printf("chipid=0x%x\n",Radio.ReadReg(0x0740));
Radio.WriteReg(0x0740,0x34);
printf("chipid=0x%x\n",Radio.ReadReg(0x0740));
printf("chipid=0x%x\n",Radio.ReadReg(0x0741));
Radio.WriteReg(0x0741,0x44);
printf("chipid=0x%x\n",Radio.ReadReg(0x0741));
5、可以通过/sys/class/gpio来测试busy, nrst, nss, dio,这几个引脚是否ok?
// struct PinConfig {
// int16_t busy = -1, nrst = -1, nss = -1, dio1 = -1, dio2 = -1, dio3 = -1;
// int16_t tx_en = -1, rx_en = -1;
//};
echo 7 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio7/direction
echo 1 > /sys/class/gpio/gpio7/value
如下:
SX126x_Linux Radio("/dev/spidev2.0", 0,
{
5, 6, 4,
3, -1,-1,
2, -1
}
);
6、以上都ok后,如果发送成功,可以收到Wow RX done,如果没收到,需要两下DIO1引脚(DIO是默认低电平,cpu端也需要设置为默认低电平)
7、即为发送ok,在通过另外一个设置设置为接受,即lora初步调试ok
8、如果需要与其他lora模块通信,即使bw cr ,sf都一致,也可以收到其他厂家的lora数据,但是数据被处理了,数据不对。
SF | BW | Code Rate | Data Rate(bps) | SF | BW | Code Rate | Data Rate(bps) | SF | BW | Code Rate | Data Rate(bps) | ||
5 | 125000 | 0.8000 | 15625.00 | 5 | 250000 | 0.8000 | 31250.00 | 5 | 500000 | 0.8000 | 62500.00 | ||
6 | 125000 | 0.8000 | 9375.00 | 6 | 250000 | 0.8000 | 18750.00 | 6 | 500000 | 0.8000 | 37500.00 | ||
7 | 125000 | 0.8000 | 5468.75 | 7 | 250000 | 0.8000 | 10937.50 | 7 | 500000 | 0.8000 | 21875.00 | ||
8 | 125000 | 0.8000 | 3125.00 | 8 | 250000 | 0.8000 | 6250.00 | 8 | 500000 | 0.8000 | 12500.00 | ||
9 | 125000 | 0.8000 | 1757.81 | 9 | 250000 | 0.8000 | 3515.63 | 9 | 500000 | 0.8000 | 7031.25 | ||
10 | 125000 | 0.8000 | 976.56 | 10 | 250000 | 0.8000 | 1953.13 | 10 | 500000 | 0.8000 | 3906.25 | ||
11 | 125000 | 0.8000 | 537.11 | 11 | 250000 | 0.8000 | 1074.22 | 11 | 500000 | 0.8000 | 2148.44 | ||
12 | 125000 | 0.8000 | 292.97 | 12 | 250000 | 0.8000 | 585.94 | 12 | 500000 | 0.8000 | 1171.88 | ||
| | | | | | | | | | | | | |
SF | BW | Code Rate | Data Rate(bps) | SF | BW | Code Rate | Data Rate(bps) | SF | BW | Code Rate | Data Rate(bps) | ||
5 | 125000 | 0.6667 | 13020.83 | 5 | 250000 | 0.6667 | 26041.67 | 5 | 500000 | 0.6667 | 52083.33 | ||
6 | 125000 | 0.6667 | 7812.50 | 6 | 250000 | 0.6667 | 15625.00 | 6 | 500000 | 0.6667 | 31250.00 | ||
7 | 125000 | 0.6667 | 4557.29 | 7 | 250000 | 0.6667 | 9114.58 | 7 | 500000 | 0.6667 | 18229.17 | ||
8 | 125000 | 0.6667 | 2604.17 | 8 | 250000 | 0.6667 | 5208.33 | 8 | 500000 | 0.6667 | 10416.67 | ||
9 | 125000 | 0.6667 | 1464.84 | 9 | 250000 | 0.6667 | 2929.69 | 9 | 500000 | 0.6667 | 5859.38 | ||
10 | 125000 | 0.6667 | 813.80 | 10 | 250000 | 0.6667 | 1627.60 | 10 | 500000 | 0.6667 | 3255.21 | ||
11 | 125000 | 0.6667 | 447.59 | 11 | 250000 | 0.6667 | 895.18 | 11 | 500000 | 0.6667 | 1790.36 | ||
12 | 125000 | 0.6667 | 244.14 | 12 | 250000 | 0.6667 | 488.28 | 12 | 500000 | 0.6667 | 976.56 | ||
| | | | | | | | | | | | | |
SF | BW | Code Rate | Data Rate(bps) | SF | BW | Code Rate | Data Rate(bps) | SF | BW | Code Rate | Data Rate(bps) | ||
5 | 125000 | 0.5714 | 11160.71 | 5 | 250000 | 0.5714 | 22321.43 | 5 | 500000 | 0.5714 | 44642.86 | ||
6 | 125000 | 0.5714 | 6696.43 | 6 | 250000 | 0.5714 | 13392.86 | 6 | 500000 | 0.5714 | 26785.71 | ||
7 | 125000 | 0.5714 | 3906.25 | 7 | 250000 | 0.5714 | 7812.50 | 7 | 500000 | 0.5714 | 15625.00 | ||
8 | 125000 | 0.5714 | 2232.14 | 8 | 250000 | 0.5714 | 4464.29 | 8 | 500000 | 0.5714 | 8928.57 | ||
9 | 125000 | 0.5714 | 1255.58 | 9 | 250000 | 0.5714 | 2511.16 | 9 | 500000 | 0.5714 | 5022.32 | ||
10 | 125000 | 0.5714 | 697.54 | 10 | 250000 | 0.5714 | 1395.09 | 10 | 500000 | 0.5714 | 2790.18 | ||
11 | 125000 | 0.5714 | 383.65 | 11 | 250000 | 0.5714 | 767.30 | 11 | 500000 | 0.5714 | 1534.60 | ||
12 | 125000 | 0.5714 | 209.26 | 12 | 250000 | 0.5714 | 418.53 | 12 | 500000 | 0.5714 | 837.05 | ||
| | | | | | | | | | | | | |
SF | BW | Code Rate | Data Rate(bps) | SF | BW | Code Rate | Data Rate(bps) | SF | BW | Code Rate | Data Rate(bps) | ||
5 | 125000 | 0.5000 | 9765.63 | 5 | 250000 | 0.5000 | 19531.25 | 5 | 500000 | 0.5000 | 39062.50 | ||
6 | 125000 | 0.5000 | 5859.38 | 6 | 250000 | 0.5000 | 11718.75 | 6 | 500000 | 0.5000 | 23437.50 | ||
7 | 125000 | 0.5000 | 3417.97 | 7 | 250000 | 0.5000 | 6835.94 | 7 | 500000 | 0.5000 | 13671.88 | ||
8 | 125000 | 0.5000 | 1953.13 | 8 | 250000 | 0.5000 | 3906.25 | 8 | 500000 | 0.5000 | 7812.50 | ||
9 | 125000 | 0.5000 | 1098.63 | 9 | 250000 | 0.5000 | 2197.27 | 9 | 500000 | 0.5000 | 4394.53 | ||
10 | 125000 | 0.5000 | 610.35 | 10 | 250000 | 0.5000 | 1220.70 | 10 | 500000 | 0.5000 | 2441.41 | ||
11 | 125000 | 0.5000 | 335.69 | 11 | 250000 | 0.5000 | 671.39 | 11 | 500000 | 0.5000 | 1342.77 | ||
12 | 125000 | 0.5000 | 183.11 | 12 | 250000 | 0.5000 | 366.21 | 12 | 500000 | 0.5000 | 732.42 |
标签:SFBWCode,Rate,RateData,sx1268,bps,Radio,ReadReg,imx6ull,调试 From: https://blog.51cto.com/u_15904120/5917895