Open peach-e opened 3 years ago
I modified my lora_node.py script to print out the AT commands sent into the modem and the responses.
Script
#!/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 = 'US915'
lora.set_config(dev_eui='34*********************14',
app_eui='70*********************06',
app_key='E8***************************14')
lora.set_config(ch_mask = '0,FF00')
lora.set_config(ch_mask = '1,0000')
lora.set_config(ch_mask = '2,0000')
lora.set_config(ch_mask = '3,0000')
lora.set_config(ch_mask = '4,0000')
lora.join_otaa()
lora.dr = 5
lora.send('Hello world')
lora.close()
Result
$ sudo ./lora_node.py
2021-06-09 12:29:07,355 - rak811.serial - DEBUG - Serial initialized
2021-06-09 12:29:09,377 - rak811.serial - DEBUG - Sending: >at+mode=0\r\n<
2021-06-09 12:29:10,597 - rak811.serial - DEBUG - Ignoring untagged: ><
2021-06-09 12:29:10,715 - rak811.serial - DEBUG - Ignoring untagged: >Selected LoraWAN 1.0.2 Region: US915 <
2021-06-09 12:29:10,820 - rak811.serial - DEBUG - Ignoring untagged: ><
2021-06-09 12:29:10,925 - rak811.serial - DEBUG - Received: >OK<
2021-06-09 12:29:11,029 - rak811.serial - DEBUG - Sending: >at+band=US915\r\n<
2021-06-09 12:29:11,038 - rak811.serial - DEBUG - Received: >OK<
2021-06-09 12:29:11,143 - rak811.serial - DEBUG - Sending: >at+set_config=dev_eui:34**********14&app_eui:70*********06&app_key:E8*********************14\r\n<
2021-06-09 12:29:12,366 - rak811.serial - DEBUG - Received: >OK<
2021-06-09 12:29:12,471 - rak811.serial - DEBUG - Sending: >at+set_config=ch_mask:0,FF00\r\n<
2021-06-09 12:29:13,686 - rak811.serial - DEBUG - Received: >OK<
2021-06-09 12:29:13,790 - rak811.serial - DEBUG - Sending: >at+set_config=ch_mask:1,0000\r\n<
2021-06-09 12:29:15,005 - rak811.serial - DEBUG - Received: >OK<
2021-06-09 12:29:15,109 - rak811.serial - DEBUG - Sending: >at+set_config=ch_mask:2,0000\r\n<
2021-06-09 12:29:16,324 - rak811.serial - DEBUG - Received: >OK<
2021-06-09 12:29:16,429 - rak811.serial - DEBUG - Sending: >at+set_config=ch_mask:3,0000\r\n<
2021-06-09 12:29:17,644 - rak811.serial - DEBUG - Received: >OK<
2021-06-09 12:29:17,748 - rak811.serial - DEBUG - Sending: >at+set_config=ch_mask:4,0000\r\n<
2021-06-09 12:29:18,963 - rak811.serial - DEBUG - Received: >OK<
2021-06-09 12:29:19,068 - rak811.serial - DEBUG - Sending: >at+join=otaa\r\n<
Traceback (most recent call last):
File "./lora_node.py", line 31, in <module>
lora.join_otaa()
File "/usr/local/lib/python3.7/dist-packages/rak811/rak811.py", line 411, in join_otaa
self._send_command('join=otaa')
File "/usr/local/lib/python3.7/dist-packages/rak811/rak811.py", line 237, in _send_command
response = self._serial.receive()
File "/usr/local/lib/python3.7/dist-packages/rak811/serial.py", line 157, in receive
raise Rak811TimeoutError('Timeout while waiting for data')
rak811.serial.Rak811TimeoutError: Timeout while waiting for data
So it looks like that at+join=otaa
command is gumming up the modem. Not even $ rak811 -vd reset lora
will fix it; I actually have to power-cycle my Pi to get back to square 1.
Looking at the AT command reference here: https://downloads.rakwireless.com/LoRa/RAK811/Application_Notes/RAK811_AT_Command_Manual_V1.0.pdf
It looks like at+join
does not accept any arguments. I'd investigate farther, but I'm having a heck of a time probing the serial port directly.
Question
Can someone please tell me a command that will let me talk to the modem with AT commands? I've been trying
$ picocom -b 115200 -d 8 -y n -p 1 /dev/serial0
But nothing appears in the console when I type things.
All right. The correct serial command is
$ picocom --baud 115200 --echo --omap crcrlf /dev/serial0
And now I can run AT commands manually.
at+reset=0
OK
Welcome to RAK811
Selected LoraWAN 1.0.2 Region: US915
at+mode=0
Selected LoraWAN 1.0.2 Region: US915
OK
at+version
OK2.0.3.0
at+set_config=dev_eui:34*******14
OK
at+set_config=app_eui:70*********06
OK
at+set_config=app_key:E8*****************14
OK
at+join=otaa
It looks like I'm using the old version of the firmware, for which at+join=otaa
is in fact a reasonable command (https://github.com/AmedeeBulle/pyrak811/blob/main/DOCS/RAK811%C2%A0LoRa%C2%A0AT%C2%A0Command%C2%A0V1.5.pdf).
But the command never returns it the modem doesn't get a lock on a gateway, so it just sits there without responding until I cycle the power. No wonder the serial interface was timing out.
Would upgrading the firmware help with this? I thought someone would have a gateway near here; the LoRa promotional material advertised a 10km radius and I'm in a populated area.
I'm trying to follow the LoRA Node tutorial for Raspberry Pi here: https://learn.pi-supply.com/make/getting-started-with-the-raspberry-pi-lora-node-phat
I'm getting stuck during the hello world script due to the serial interface timing out. But not all the time. Sometimes it times out waiting for a response from a gateway (I don't have my own) and once or twice I got a handshake to appear on the TTN console.
Using
Steps to Reproduce
dtoverlay=pi3-miniuart-bt
in/boot/config.txt
as per tutorial.Get Device EUI with commands:
ttn-handler-eu
(Automatically selected)OTAA
MAC V1.0.2
nam1.cloud.thethings.network
PHY V1.0.2 REV B
.US915 FSB 2
from rak811 import Mode, Rak811
doesn't work any more. Now, you have to usefrom rak811.rak811 import Mode, Rak811
.lora.set_config(dev_eui, app_eui, app_key)
andlora.join_otaa()
commands.chmod +x
on the script.Expected Behavior
It either works, or maybe I'll get errors about talking to a gateway because I live a long ways away from one. (I bought the device for P2P communication primarily)
Observed Behavior
I get "Timeout while waiting for data" on the
lora.join_otaa()
step.Run the script again. This time I get a similar timeout error on
lora.mode = Mode.LoRaWan
.Okay, so I've got serial problems. But why did the first couple of commands go through? Let's try them again.
Any ideas?