Node based on Raspberry?

I’m facing the same issues as you describe.

As you can see, all values corresponds with the TheThingsNetwork Console, but ttn-otaa hang on EV_JOINING.

Also the spi-scan reports correctly the Dragino GPS/Lora HAT

Anyone with some suggestions to try? Could this mean there isn’t any Lora-gateway reporting to the TTN? According to the TTN-Map there should be multiple TTN-Gateways in range on our university campus.

Using a Raspberry Pi 3 Model B with the latest Raspbian.

It depends on how this gateways you see on the map are configured. As someone mentioned above, e.g. single channel gateways wouldn’t might not work with OTAA.

Maybe just for testing you could try ABP as activation, just to ensure, that not your node is the problem.

I also ordered a Arduino module from Dragino. Lets try if this will give better results. Otherwise I’ll setup the Rpi + Dragino HAT as Single Channel gateway.

Keep you posted.

BTW, does somebody found a nice library/framework for the Dragino Rpi HAT?

I implemented Hardware Abstraction Layer (HAL) code for LMIC 1.6 targeted to Raspberry Pi for Dragino GPS/Lora HAT.
Having that done, I now can use LMIC 1.6 and this HAL to write node applications on the RPi.

  • Joining the TTN using OTAA works using a fully-functional Kerlink IoT Gateway(LMIC examples/join)
  • Sending periodic sensor values to TTN works (LMIC examples/periodic)

I plan to provide the code for the HAL on github soon.

2 Likes

Ok it turns out that the nearest gateway (400 meters away) has a really poor RSSI and SNR values…

I just ordered bigger antenna’s (5dBi), because I’m unsure if the low link budget is due to my setup (Dragino Rpi HAT and Dragino Arduino Shiel with the same antenna) or it’s due to the poor gateway setup at my university.

Guys

As suggested @matthijs here increasing clock error for receive windows solved all my OTAA join with LMIC (on Arduino Zero) but may apply on RPI, worth trying this fix (here 1% error more) you can con even on 2% or 3%

LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100);

Works perfectly with Loraspi board with RFM95

1 Like

For users of a Dragino LoRa/GPS HAT (for Raspberry Pi) I have implemented a Hardware Abstraction Layer for the IBM LMIC 1.6 communication stack. This is similar to the solution of Ernst de Vreede, but as a difference it is based on IBM LMIC 1.6, which seems to be the most recent version of this communication stack. I tried not to touch the LMIC stack itself but only provide a HAL for RPi + LoRa HAT. I also tried not to put too much CPU load on the RPi when waiting for incoming messages.

Find the code in github at https://github.com/wklenk/lmic-rpi-lora-gps-hat

The following LMIC examples are working yet with this HAL and TTN:

  • examples/hello - Not using radio at all
  • examples/join - Join the TTN using OTAA (over the air activation)
  • examples/periodic - Join and periodically send a sensor value to TTN.

I would appreciate to get feedback if this stack also works for you, and if it was easy to use this piece of software.

Note: I tested it with a Kerlink IoT Gateway. Single Channel Gateways won’t work.

6 Likes

I’ll test this next week more extensively!

Quick look: https://github.com/wklenk/lmic-rpi-lora-gps-hat/blob/master/examples/ping/main.c still contains your keys/ids!

You my friend are a legend for making it clear that it will only work with a proper gateway. I struggled for days to get nodes working with single channel gateways :slight_smile:

I use the LMIC stack for some nodes, and it works great with my single channel gateway!

Your SGC works great. Is there any chance that you port it to Pi 1/2/Zero?

Hi @wklenk,

Thank you very much for your Dragino LoRa/GPS HAT Hardware Abstraction Layer for the IBM LMIC library.

I’m trying to use it on my rPi 3 and Dragino HAT but I encounter some problems

I thing I have all prerequisites to run your Hello example but unfortunately it doesn’t work :smirk:

# ./build/hello.out
000000000 HAL: Initializing ...
000000001 HAL: Set radio RST pin to 0x00
000000001 HAL: Wait until 000000002 ms
000000002 HAL: Set radio RST pin to 0x02
000000002 HAL: Wait until 000000007 ms
000000008 HAL: Failed. Aborting.

I’m suspecting a pin problems …

I hope, you (or someone else here :blush:) can help me to get it work.

Here is an output of gpio readall just a reboot :

 +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 | ALT0 | 1 |  3 || 4  |   |      | 5v      |     |     |
 |   3 |   9 |   SCL.1 | ALT0 | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 0 |  7 || 8  | 1 | ALT5 | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 0 | ALT5 | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 1 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI | ALT0 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO | ALT0 | 0 | 21 || 22 | 1 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK | ALT0 | 0 | 23 || 24 | 1 | OUT  | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | OUT  | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+

SPI is activated with raspi config here is an lsmod output :

Module                  Size  Used by
evdev                  11396  2
brcmfmac              186403  0
brcmutil                5661  1 brcmfmac
cfg80211              428871  1 brcmfmac
rfkill                 16037  2 cfg80211
hid_apple               4925  0
spi_bcm2835             6678  0
i2c_bcm2708             4834  0
bcm2835_gpiomem         3040  0
bcm2835_wdt             3225  0
uio_pdrv_genirq         3164  0
uio                     8000  1 uio_pdrv_genirq
i2c_dev                 5859  0
ipv6                  347556  32

I just have a doubt about spidev I don’t know how to activate it, a modprobe spidev do nothing …

Wiringpi and bcm2835 are installed too.

Thanks for your help :slight_smile:

Regards

I’m currently testing my RPi Zero W TTN Shield

More on:

3 Likes

@itacos did you got it working?

Yes. Working perfectly. 1 week uptime now with no issue.

2 Likes

Hello,

After some advanced tests, i can say that joining with OTAA and transmit data on my gateways works.

Sometimes, some segmentation faults occurred, randomly at the begin or after some minutes of execution, but I did not identified the root cause yet.

1 Like

Hi Wklenk,
thanks for your awesome solution . I tested the code you provided and the uplink tx seems to work perfectly( I could test only the uplink since my gateway is a single channel based on the modified version of the dual_chan_pkt_fwd). However, my single channel gateway offers a function to send downstream data.
I would like to test is with your implementation of the LMIC v1.6 using the ABP activation method. The point is that I want to send downlink data to my node ( running your software) at a random time and see if the node receives the data. I wanted to modify the periodic example so that it uses the APB method to send data to my local server over my gateway. Can you please guide me on this?

Hi,

some clarifications first:

  • Whether you use OTAA or ABP for activation does have nothing to do with sending download data. It is just the method how to “join” the network. The examples I provide use OTAA. First task would be to get them working using ABP.
  • You cannot send “data to your node at a random time”. With LoRa Class A devices, you can only receive data after you have sent data. But let’s say you get the “periodic” example running with ABP, e.g. sending some dummy data every 5 minutes, and you manage to send something back in the TTN backend, then it should be possible to receive data.
  • But I have made bad experiences with these “single channel” gateways. Are you really sure that it supports downlink messages?

Thanks for your prompt reply and also thanks for the clarifications.
The issue is that I tried your LMIC v1.6 code on my Lora Node (RPI+Dragino) and my gateway based on the same components as my node runs the dual channel packet forwarder from (https://github.com/bokse001/dual_chan_pkt_fwd).
During the test, I realized that server replies to uplinks message but my node never receives them.
Since it is a thesis project, I wanted to make sure that it is not possible to send downlink messages using the RPI+DRAGINO HAT as the gateway. I would like to have your advice on this. That is why I have the following questions:

Q1- Is it possible to have uplink and downlink message on a single channel gateway sending in both directions on the same frequency ( e.g 868.1) and also configuring the client to send then listen on the same frequency?

Note: It is obviously far from being LoRaWAN compliant

I have not been able to get this to work with the Raspberry Pi 3 B+ (esp. for the US). I have it running, but it doesn’t show up in the TTN console (never seen). I did the following:

  1. Change config.h to have: #define CFG_us915 1
  2. Change line 764 of lmic.c to LMIC.channelMapp[channel/16] &= ~(1<<(channel&0F));
  3. Added in all session keys, eui’s and dev address.

Also doesn’t show up in gateway traffic, though it is running.

What am I missing?