Lora rak811 con Raspberry PI 3

Good morning,

I am working with the rak811 and I followed the next tutorial provided by rackwireless, every step has worked excellent until the test which command is “at+send=lora:2:123456” however when I tried to connect the rak with another device how raspberry Pi 3 (with Python 3 code) it does’t work. The issue is the port which does not work in the stipulate time, in another words, my code run but appear a problem with the serial port “rak811.serial.Rak811TimeoutError: Timeout while waiting for response”
Do you know which could the problem be?

Struggling with that myself. As far as I can tell, the only way to clear this problem is to cycle power to the rak811… which given the hat I’m using means power-cycling the whole Pi.

If there’s a way to fix this in software I’d very much appreciate hearing about it.

Hi @acb ,

Can you please provide more info? What is the version of RAK811? What code are you using to communicate with RAK811?

Hi,

I am having a similar problem as explained in the first message. I have a Lora Gateway rak833 ttn registered; I am now trying to register a rak811 but I am having some trouble.

  1. I have followed this tutorial Getting Started with the Raspberry Pi LoRa Node pHAT
  2. I have created a python script with the follwoing:
#!/usr/bin/env python3
from rak811 import Mode, Rak811

lora = Rak811()
lora.hard_reset()
lora.mode = Mode.LoRaWan
lora.band = 'EU868'
lora.set_config(app_eui='1234567890',
                app_key='1234567890xxxxxxxxxxxxxxxxxxxxxxx')
lora.join_otaa()
lora.dr = 5
lora.send('Hello world')
lora.close()

When I run the script I get the this output:


Traceback (most recent call last):
  File "lora_node-2.py", line 2, in <module>
    from rak811 import Mode, Rak811
ImportError: cannot import name 'Mode' from 'rak811' (/usr/local/lib/python3.7/dist-packages/rak811/__init__.py)

Other info:

  • LoRaWAN version MAC V1.0.2
  • Regional Parameters version PHY V1.0.2 REV B.
  • Server eu1.cloud.thethings.network
  • Frequency Plan: Europe 863-870 Mhz (SF9 for RX2 - Recommended)
  • rak811 version: 2.0.3.0

How can I fix this issue?

Thanks

Welcome to RAK forum @lls :slight_smile:

The issue seems related to python (but I am not 100% sure).

What OS do you have and how did you install python (what version?), pip3 and the rak811 library?

Hi carlowan,

thank you for your reply. I have the following:

  • Python 3.7.3
  • pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
  • RPi Zero W - Buster

I think one of the problems was coming from line 2 from rak811 import Mode, Rak811. I have changed this line with from rak811.rak811 import Mode, Rak811 and added some debug function. Now, the python script looks like this:

#!/usr/bin/env python3
import logging
import sys

root = logging.getLogger()
root.setLevel(logging.DEBUG)

handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
root.addHandler(handler)

from rak811.rak811 import Mode, Rak811

lora = Rak811()
lora.hard_reset()
lora.mode = Mode.LoRaWan
lora.band = 'EU868'
lora.set_config(app_eui='1234567890',
                app_key='1234567890xxxxxxxxxxxxxxxxxxxxxx')
lora.join_otaa()
lora.dr = 5
lora.send('Hello world')
lora.close()

And this is the output:

2021-08-06 07:34:21,614 - rak811.serial - DEBUG - Serial initialized
2021-08-06 07:34:21,660 - rak811.serial - DEBUG - Ignoring untagged: >Welcome to RAK811<
2021-08-06 07:34:21,764 - rak811.serial - DEBUG - Ignoring untagged: ><
2021-08-06 07:34:21,880 - rak811.serial - DEBUG - Ignoring untagged: >Selected LoraWAN 1.0.2 Region: EU868 <
2021-08-06 07:34:21,984 - rak811.serial - DEBUG - Ignoring untagged: ><
2021-08-06 07:34:23,646 - rak811.serial - DEBUG - Sending: >at+mode=0\r\n<
2021-08-06 07:34:24,843 - rak811.serial - DEBUG - Ignoring untagged: ><
2021-08-06 07:34:24,963 - rak811.serial - DEBUG - Ignoring untagged: >Selected LoraWAN 1.0.2 Region: EU868 <
2021-08-06 07:34:25,068 - rak811.serial - DEBUG - Ignoring untagged: ><
2021-08-06 07:34:25,173 - rak811.serial - DEBUG - Received: >OK<
2021-08-06 07:34:25,277 - rak811.serial - DEBUG - Sending: >at+band=EU868\r\n<
2021-08-06 07:34:25,286 - rak811.serial - DEBUG - Received: >OK<
2021-08-06 07:34:25,391 - rak811.serial - DEBUG - Sending: >at+set_config=app_eui:1234567890&app_key:1234567890xxxxxxxxxxxxxxxxxxxxxx\r\n<
2021-08-06 07:34:26,594 - rak811.serial - DEBUG - Received: >OK<
2021-08-06 07:34:26,699 - rak811.serial - DEBUG - Sending: >at+join=otaa\r\n<
2021-08-06 07:34:26,747 - rak811.serial - DEBUG - Received: >OK<
Traceback (most recent call last):
  File "lora_node-2.py", line 22, in <module>
    lora.join_otaa()
  File "/usr/local/lib/python3.7/dist-packages/rak811/rak811.py", line 413, in join_otaa
    for event in self._get_events():
  File "/usr/local/lib/python3.7/dist-packages/rak811/rak811.py", line 262, in _get_events
    self._serial.receive(single=False, timeout=timeout)]
  File "/usr/local/lib/python3.7/dist-packages/rak811/serial.py", line 156, in receive
    raise Rak811TimeoutError('Timeout while waiting for data')
rak811.serial.Rak811TimeoutError: Timeout while waiting for data

That looks a bit better, but I still cannot send the message to the Gateway which is one meter next to the node.

Any idea how to make this right?

You are sure that your FW is not yet V3 right? That’s why you are still using the example code for the old RAK811 FW? (I think you are since you are getting replies).

Some are having issues on that Timeout Error on any rak811 commands · Issue #19 · AmedeeBulle/pyrak811 · GitHub

You are having time out errors in at+join=otaa because probably you are not having a successful join.

What is shown in the Live Data tab of your application when you try to join? Can you turn on the verbose stream so we can have more details?

Do you have access on the gateway? Can you see if join uplinks are sent?

To be honest, I am not sure about the FW. Should I try another code?

The Live Data tab of the application shows nothing. But in the Live Data tab of the gateway I can see the following, with the DevEUI of my device:

09:39:34 Receive uplink message JoinEUI 39xxxxxxxxxxxxxx217 DevEUI39xxxxxxxxxxxxxx217 Data rate SF7BW125 SNR 10 RSSI -76

09:39:32 Receive uplink message DevAddr 260B8151 FCnt 5601 FPort 85 Data rate SF7BW125 SNR 9.75 RSSI -89

$ rak811v3 -v -d set-config lora:work_mode:0

DEBUG:rak811.serial:Serial initialized
DEBUG:rak811.serial:Sending: >at+set_config=lora:work_mode:0\r\n<
DEBUG:rak811.serial:Received: >ERROR-1<
RAK811 timeout: Timeout while waiting for data

$ rak811 version

2.0.3.0

$ rak811v3 version

Traceback (most recent call last):
  File "/usr/local/bin/rak811v3", line 10, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/rak811/cli_v3.py", line 146, in version
    click.echo(lora.version)
  File "/usr/local/lib/python3.7/dist-packages/rak811/rak811_v3.py", line 435, in version
    return(self._send_command('version'))
  File "/usr/local/lib/python3.7/dist-packages/rak811/rak811_v3.py", line 251, in _send_command
    response = self._serial.receive()
  File "/usr/local/lib/python3.7/dist-packages/rak811/serial.py", line 156, in receive
    raise Rak811TimeoutError('Timeout while waiting for data')
rak811.serial.Rak811TimeoutError: Timeout while waiting for data

So, looks like the command rak811 works but not rak811v3

Here, I am a bit lost

Also, the device status in the application shows Unknown. I don’t think is has been registered properly but I don’t know what should be changed.

Can you confirm that that is the JoinEUI/AppEUI? Also why there is a DevAddress and FCnt is 5601 if you have no successful join.

If there are no live data on The Thing Stack, it can mean few things.

  1. There is no RF signal transmitted by the device.
  2. It wasn’t received by the gateway.
  3. The AppEUI and DevEUI is wrong.
  4. Frequency plan of the device and the gateway is not the.

These are the possible 4 reasons why you don’t see any Live Data on the device.

I see, JoinEUI and DevEUI are the same. Now the device is registered and seen.

Receive uplink message JoinEUI 39xxxxxxxxxxxxxx217 DevEUI 39xxxxxxxxxxxxxx217 Data rate SF12BW125 SNR 10.25 RSSI -69

Many thanks! That was very helpful to put on the right track.

Good to hear that.

But I don’t understand what happened? :sweat_smile:

:grinning_face_with_smiling_eyes:

I was trying to register my end device on TTN but it was shown as “unknown”. Now I have both a gateway and an end device registered and exchanging data.

To be honnest, I also don’t fully understand… :upside_down_face: I am learning about IoT and possible usage.

In any case, thank you so much for taking the time to reply and help!