sandeepmistry / arduino-LoRa

An Arduino library for sending and receiving data using LoRa radios.
MIT License
1.61k stars 621 forks source link

LoRa.enableCRC(), does not enable CRC on RFM95 #589

Closed i-g-g-y closed 1 year ago

i-g-g-y commented 1 year ago

Hello.

I am trying to enable CRC on RFM95.

` LoRa.setPreambleLength(8); LoRa.setCodingRate4(5); LoRa.enableCrc(); LoRa.setSpreadingFactor(10); LoRa.setSignalBandwidth(125E3); LoRa.setTxPower(20); LoRa.enableCrc();

//replace the LoRa.begin(---E-) argument with your location's frequency //433E6 for Asia //866E6 for Europe //915E6 for North America while (!LoRa.begin(866E6)) { Serial.print("."); delay(500); }

// Change sync word (0xF3) to match the receiver // The sync word assures you don't get LoRa messages from other LoRa transceivers // ranges from 0-0xFF LoRa.setSyncWord(0xF3); Serial.println("LoRa Initializing OK!");

pinMode(LED_BUILTIN, OUTPUT);

Serial.println("Setting-up WiFi:"); setup_wifi();

LoRa.dumpRegisters(Serial);

`

Here is the result of the RFM95 register dump, showing the CRC check is not enabled:

` LoRa Start Initializing LoRa Initializing OK! Setting-up WiFi: **192.168.12.112 0x0: 0x27 0x1: 0x81 0x2: 0x1A 0x3: 0xB 0x4: 0x0 0x5: 0x52 0x6: 0xD8 0x7: 0x80 0x8: 0x0 0x9: 0x8F 0xA: 0x9 0xB: 0x2B 0xC: 0x23 0xD: 0x1 0xE: 0x0 0xF: 0x0 0x10: 0x0 0x11: 0x0 0x12: 0x0 0x13: 0x0 0x14: 0x0 0x15: 0x0 0x16: 0x0 0x17: 0x0 0x18: 0x10 0x19: 0x0 0x1A: 0x0 0x1B: 0x0 0x1C: 0x0 0x1D: 0x72 0x1E: 0x70 0x1F: 0x64 0x20: 0x0 0x21: 0x8 0x22: 0x1 0x23: 0xFF 0x24: 0x0 0x25: 0x0 0x26: 0x4 0x27: 0x0 0x28: 0x0 0x29: 0x0 0x2A: 0x0 0x2B: 0x0 0x2C: 0x0 0x2D: 0x50 0x2E: 0x14 0x2F: 0x45 0x30: 0x55 0x31: 0xC3 0x32: 0x5 0x33: 0x27 0x34: 0x1C 0x35: 0xA 0x36: 0x3 0x37: 0xA 0x38: 0x42 0x39: 0xF3 0x3A: 0x49 0x3B: 0x1D 0x3C: 0x0 0x3D: 0xAF 0x3E: 0x0 0x3F: 0x0 0x40: 0x0 0x41: 0x0 0x42: 0x12 0x43: 0x24 0x44: 0x2D 0x45: 0x0 0x46: 0x3 0x47: 0x0 0x48: 0x4 0x49: 0x23 0x4A: 0x0 0x4B: 0x9 0x4C: 0x5 0x4D: 0x84 0x4E: 0x32 0x4F: 0x2B 0x50: 0x14 0x51: 0x0 0x52: 0x0 0x53: 0x11 0x54: 0x0 0x55: 0x0 0x56: 0x0 0x57: 0xF 0x58: 0xE0 0x59: 0x0 0x5A: 0xC 0x5B: 0x0 0x5C: 0x7 0x5D: 0x0 0x5E: 0x5C 0x5F: 0x78 0x60: 0x0 0x61: 0x1C 0x62: 0xE 0x63: 0x5B 0x64: 0xCC 0x65: 0x0 0x66: 0x1 0x67: 0x50 0x68: 0x0 0x69: 0x0 0x6A: 0x0 0x6B: 0x0 0x6C: 0x0 0x6D: 0x0 0x6E: 0x0 0x6F: 0xB 0x70: 0xD0 0x71: 0x0 0x72: 0x13 0x73: 0x0 0x74: 0x0 0x75: 0x0 0x76: 0x0 0x77: 0x0 0x78: 0x0 0x79: 0x0 0x7A: 0x0 0x7B: 0x0 0x7C: 0x0 0x7D: 0x0 0x7E: 0x0 0x7F: 0x0

`

i-g-g-y commented 1 year ago

I performed a manual reset, so a reset of RFM95 before I assigned pins to LoRa module. I also changed order of Lora.begin and initialisation to:

` while (!LoRa.begin(866E6)) { Serial.print("."); delay(500); }

LoRa.setPreambleLength(8); LoRa.setCodingRate4(5); LoRa.enableCrc(); LoRa.setSpreadingFactor(10); LoRa.setSignalBandwidth(125E3); LoRa.setTxPower(20); LoRa.enableCrc(); `

To conclude, and I suspect this is an important step, I loaded the code to the board, unplugged it, wait a bit and re-plugged it into power.

Then my HW CRC started working, togather with a change in other settings.

I am still testing, I now have 2x CRC check, one HW and one SW, but I suspect it will be OK now.

i-g-g-y commented 1 year ago

After extensive testing this works, no corrupted packet gets through, so CRC works for sure. My error rate is roughly 60 lost packets in 12h, with -60dB RSSI.