Close

Getting LoRa Peer to Peer Working​

A project log for LoRa + Neural Network Security System

Spot trespassers with a neural network and transmit basic results via LoRa

capt-flatus-oflahertyCapt. Flatus O'Flaherty ☠ 12/05/2018 at 17:160 Comments

Most info on the interweb about LORA seems to point to the 'Things Network' in which we are all assimilated into some kind of cyber - Borg Utopian style collective in we all cooperate without conflict.. but what if we just want basic data transfer between 2 devices and dont need the whole world to witness our data? Peer to peer is quite possibly the answer.

In this case, a Raspberry Pi with a Draganino LoRa/GPS hat will send data about the security state of a remote location (eg farm gate) to tell us if people are coming in or if someone has stolen one of our cows. The receiver is an Arduino MKRWAN 1300 which has a dedicated LoRa chip soldered onto it. 

BE WARNED: This Arduino is a 3.3V device and will be destroyed by applying 5v to any (or most of) of the pins. Also, never operate either the Dragino hat or the Arduino device without an antenna attached!

As far as code is concerned, both instances are really simple, although it took me a while to work out that I had to flash the Arduino with a firmware upgrade to get it to work properly. The Raspberry Pi was processed as follows:

$ wget https://codeload.github.com/dragino/rpi-lora-tranceiver/zip/master
$ unzip master
$ cd rpi-lora-tranceiver-master/dragino_lora_app
$ make
$ cd rpi-lora-tranceiver-master/dragino_lora_app &&./dragino_lora_app
$ ./dragino_lora_app sender

I've no idea how secure this is, but we can look at that later on.

NB. The RPi MUST have a proper power supply and SPI needs to be activated in the settings. OS used is Raspian stretch.

Setting up the Arduino is just as easy. There's just a cuple of things to watch out for:

Firstly, the Rpi, in my case attempted to transmit 'HELLO' every 3 seconds on 868.1 MHz, so the Arduino needs to be configured accordingly ...... 868.1 MHz = 8681 x 10= 8681E5. Other regions eg USA will use different sets of frequencies.

Download Arduino lora libraries here: (both are required)

https://github.com/sandeepmistry/arduino-LoRa
https://github.com/arduino-libraries/MKRWAN

After installing the libraries in the normal way, open the MKWAN example set and up load 'MKRWANFWUpdate_standalone' to the Arduino and open serial console. You should see the update as it progresses. Next, find the 'LoRa' example set and select 'LoRaReceiver' and upload. Dont forget to edit the frequency as mentioned before! Open the serial console and you should see the HELLO sent from RPI.

A cheapo SDR USB dongle such as RTL-SDR can be very useful for checking that there is a signal being transmitted on the correct frequency. The software used is Zadig + Cubic SDR.

That's it for now. Later on we'll have to edit the main.cpp file in the Rpi to get object detection data, .... but that's another story!

Discussions