Along with the M2M LoRaWan Gateway Shield for Raspberry Pi I also purchased a Low power LoRaWan Node Model A328. After setting the Board in Arduino IDE to Arduino pro mini 8Mhz 3V the device fired up and worked first time.
The device is intended for LoRaWan applications so the samples provided (including a link to application template generator) were not that applicable for my LoRa project so I used the Arduino LoRa library.
const int csPin = 10; // LoRa radio chip select const int resetPin = 9; // LoRa radio reset const int irqPin = 2; // change for your board; must be a hardware interrupt pin byte msgCount = 0; // count of outgoing messages int interval = 2000; // interval between sends long lastSendTime = 0; // time of last packet send void setup() { Serial.begin(9600); // initialize serial while (!Serial); Serial.println("LoRa Duplex - Set sync word"); // override the default CS, reset, and IRQ pins (optional) LoRa.setPins(csPin, resetPin, irqPin);// set CS, reset, IRQ pin if (!LoRa.begin(915E6)) { // initialize ratio at 915 MHz Serial.println("LoRa init failed. Check your connections."); while (true); // if failed, do nothing } LoRa.enableCrc(); LoRa.setSyncWord(0x12); // ranges from 0-0xFF, default 0x34, see API docs LoRa.dumpRegisters(Serial); Serial.println("LoRa init succeeded."); } void loop() { if (millis() - lastSendTime > interval) { String message = "0 Hello Arduino LoRa! "; // send a message message += msgCount; sendMessage(message); Serial.println("Sending " + message); lastSendTime = millis(); // timestamp the message //interval = random(2000) + 1000; // 2-3 seconds interval = 1000; } // parse for a packet, and call onReceive with the result: onReceive(LoRa.parsePacket()); } void sendMessage(String outgoing) { LoRa.beginPacket(); // start packet LoRa.print(outgoing); // add payload LoRa.endPacket(); // finish packet and send it msgCount++; // increment message ID } void onReceive(int packetSize) { if (packetSize == 0) return; // if there's no packet, return // read packet header bytes: String incoming = ""; while (LoRa.available()) { incoming += (char)LoRa.read(); } Serial.println("Message: " + incoming); Serial.println("RSSI: " + String(LoRa.packetRssi())); Serial.println("Snr: " + String(LoRa.packetSnr())); Serial.println(); }
I did find the “grove” connectors weren’t compatible with any of my sensors, but the vendor does include a number of cables DIY connection.
Next I’ll use power conservation modes and see how long I can get a set of AAA batteries to last. The device looks like a good option (esp. with solar power for devices with higher power consumption sensors) for some of the SmartAg projects my students are building.
In my Windows 10 IoT Core test application I could see the enableCrc() method was working according to the RegHopChannel CrcOnPayload flag.
For real deployments of the field gateway I think packets which have no CRC or a corrupted one will be dropped.