Difference between revisions of "JF's note on PineDio devices"

Jump to navigation Jump to search
no edit summary
(Created page with "== USB LoRa adapter == 500px The Pine64 USB LoRa adapter is based on the Semtech SX1262 LoRa module and the CH341 USB bus converter chip....")
Tags: Mobile web edit Mobile edit
 
Line 244: Line 244:
* CH341 datasheet : [[File:CH341DS1.pdf]]
* CH341 datasheet : [[File:CH341DS1.pdf]]
* Semtech SX1262 datasheet : [https://semtech.my.salesforce.com/sfc/p/#E0000000JelG/a/2R000000HT76/7Nka9W5WgugoZe.xwIHJy6ebj1hW8UJ.USO_Pt2CLLo File on Semtech website (file is too big for the wiki)]
* Semtech SX1262 datasheet : [https://semtech.my.salesforce.com/sfc/p/#E0000000JelG/a/2R000000HT76/7Nka9W5WgugoZe.xwIHJy6ebj1hW8UJ.USO_Pt2CLLo File on Semtech website (file is too big for the wiki)]
== RAW LoRa communication between USB LoRa adapter and PineDio STACK ==
=== Test setup ===
* One Pine64 USB LoRa adapter (SX1262 + CH341)
* One PineDio STACK (BL604 + SX1262)
* One PyCom Lopy board (dev board based on ESP32 + LoRa module, MicroPython)
* One NooElec SDR adapter and GQRX running on my PC
The goal is to implement RAW LoRa communication between Pine64 LoRa devices (USB adapter + PineDio STACK at first, pinephone adapter later on).
The Lopy board allows me to debug my setup easily, as I know it's working correctly in both RX and TX.
I'm writing this section to share my experiments with RAW LoRa on those devices and maybe get some help on some issues. I'm a noob in RF and LoRa technologies !
=== RX on Pine64 devices ===
Setup : The Lopy board emits 16 Bytes every 5s
Using default TX settings on the Lopy (868Mhz, BW 125Khz, SF7, 8 preamble symbols, CR 4/5, IQ not inverted), the reception on both Pine64 devices was really poor : they would detect the preamble most of the time, but fail to check the CRC of the header or of the payload.
Then I change those settings : 868Mhz, BW 500Khz, SF12, 8 preamble symbols, CR 4/5, IQ inverted. Magically, the reception on both device was perfect!
Question : why the RX was not working with original settings and would work with the new ones?
=== TX from Pine64 devices ===
Using the same TX parameters as the previous test : 868Mhz, BW 500Khz, SF12, 8 preamble symbols, CR 4/5, IQ inverted
==== TX from the USB LoRa Adapter ====
On the SDR acquisition, the TX power seems lower than the Lopy board, even with TX power set to +22dB
[[File:USB-tx.png]]
The Lopy does not receive anything.
The STACK detects the message but detects a bad CRC. Indeed, the messages is scrambled...
[[File:Stack-rx.png]]
The RSSI and SNR are displayed. I notice that the RSSI is much lower for messages coming from the USB adapter than for messages coming from the Lopy
Questions :
- Is it normal that the power of the TX from the USB adapter looks much lower than the power from the lopy?
- What about the RSSI that is much lower on messages comng from the USB adapter?
- Why are the messages and CRC corrupted ?
==== TX from the PineDio STACK ====
On the SDR acquisition, the signal power looks similar than the Lopy.
[[File:Tx-stack.png]]
The Pine64 USB adapter receives the message but detects a bad CRC.
[[File:USB-rx.png]]
The Lopy board does not receive anything (probably because of messages with bad CRC that are dropped in lower level layers).
Questions :
- Why are the messages corrupted?
=== Code ===
==== PineDio STACK ====
Based on this driver: https://github.com/lupyuen/bl_iot_sdk/blob/pinedio/components/3rdparty/lora-sx1262/src/radio.c
  <nowiki>
  RadioEvents_t RadioEvents;
  RadioEvents.RxDone = OnRadioRxDone;
  RadioEvents.RxError = OnRadioRxError;
  RadioEvents.TxDone = OnRadioTxDone;
  Radio.Init(&RadioEvents);
  Radio.SetPublicNetwork(false);
  Radio.SetChannel(868000000);
  Radio.SetRxConfig(
          MODEM_LORA,
          2, //500khz
          12, //SF12
          1, // CR 4/5
          0, // N/A
          8, // preamble
          7, // symbol timeout
          0, // dynamic length
          0, // payload length
          1, // crc enabled
          0, // freq hoping disabled
          0, // hop period
          1, // no iq inversion
          1// continous receive
          );
  Radio.SetTxConfig(
          RadioModems_t::MODEM_LORA,
          0, // power
          0, //N/A
          2, // 500 khz
          12, // SF12
          1, // CR4/5
          8, // preamble
          false, // dynamic length
          true, // CRC ON
          false, // hop
          0, // hop period
          true, // invert iq
          0xffffffff // timeout
          );
  // RX
  Radio.Rx(0);
  while(1) {
    Radio.IrqProcess();
    vTaskDelay(100);
  }
  // OR TX
  const char msg[] = {"Hello, I'm a PineDio STACK!"};
  int i = 0;
  while(1) {
    Radio.IrqProcess();
    vTaskDelay(100);
    if((i % 30) ==0){
      printf("send...\r\n");
      Radio.Send((uint8_t *) msg, strlen(msg));
    }
    i++;
  }
</nowiki>
==== USB adapter ====
Based on this driver: https://github.com/YukiWorkshop/sx126x_driver
<nowiki>
  radio.Init();
  radio.SetRfFrequency(868000000);
  radio.SetBufferBaseAddresses(0, 0);
  SX126x::ModulationParams_t modulationParams;
  modulationParams.PacketType = SX126x::RadioPacketTypes_t::PACKET_TYPE_LORA;
  modulationParams.Params.LoRa.SpreadingFactor = SX126x::RadioLoRaSpreadingFactors_t::LORA_SF12;
  modulationParams.Params.LoRa.CodingRate = SX126x::RadioLoRaCodingRates_t::LORA_CR_4_5;
  modulationParams.Params.LoRa.Bandwidth = SX126x::RadioLoRaBandwidths_t::LORA_BW_500;
  modulationParams.Params.LoRa.LowDatarateOptimize = false;
  radio.SetModulationParams(modulationParams);
  SX126x::PacketParams_t packetParams;
  packetParams.PacketType = SX126x::RadioPacketTypes_t::PACKET_TYPE_LORA;
  packetParams.Params.LoRa.PreambleLength = 8;
  packetParams.Params.LoRa.HeaderType = SX126x::RadioLoRaPacketLengthsMode_t::LORA_PACKET_VARIABLE_LENGTH;
  packetParams.Params.LoRa.PayloadLength = 27;
  packetParams.Params.LoRa.CrcMode = SX126x::RadioLoRaCrcModes_t::LORA_CRC_ON;
  packetParams.Params.LoRa.InvertIQ = SX126x::RadioLoRaIQModes_t::LORA_IQ_INVERTED;
  radio.SetPacketParams(packetParams);
  radio.SetTxParams(22, SX126x::RADIO_RAMP_3400_US);
  radio.SetRegulatorMode(SX126x::RadioRegulatorMode_t::USE_DCDC);
  radio.SetDioIrqParams(0xffff, 0x0001, 0, 0);
 
// RX
  radio.SetRx(0xffffffff);
  while (1) {
    radio.ProcessIrqs();
    std::this_thread::sleep_for(std::chrono::milliseconds(500));
    }
// OR TX
  while (1) {
    radio.SetPayload(data, 27);
    radio.SetTx(0xffffffff);
    radio.ProcessIrqs();
    std::this_thread::sleep_for(std::chrono::milliseconds(500));
  }
</nowiki>
64

edits

Navigation menu