{"id":16963130,"url":"https://github.com/amedeebulle/pyrak811","last_synced_at":"2025-06-21T05:06:20.796Z","repository":{"id":34174011,"uuid":"171058410","full_name":"AmedeeBulle/pyrak811","owner":"AmedeeBulle","description":"RAK811 Python 3 library for Raspberry Pi","archived":false,"fork":false,"pushed_at":"2022-02-27T10:20:17.000Z","size":3560,"stargazers_count":51,"open_issues_count":3,"forks_count":25,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-02T05:41:53.828Z","etag":null,"topics":["lora","lorawan","rakwireless","raspberry-pi"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AmedeeBulle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-16T22:26:02.000Z","updated_at":"2024-11-07T00:48:49.000Z","dependencies_parsed_at":"2022-07-24T18:02:07.288Z","dependency_job_id":null,"html_url":"https://github.com/AmedeeBulle/pyrak811","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/AmedeeBulle/pyrak811","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmedeeBulle%2Fpyrak811","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmedeeBulle%2Fpyrak811/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmedeeBulle%2Fpyrak811/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmedeeBulle%2Fpyrak811/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AmedeeBulle","download_url":"https://codeload.github.com/AmedeeBulle/pyrak811/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmedeeBulle%2Fpyrak811/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261066504,"owners_count":23104768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lora","lorawan","rakwireless","raspberry-pi"],"created_at":"2024-10-13T23:23:41.652Z","updated_at":"2025-06-21T05:06:15.786Z","avatar_url":"https://github.com/AmedeeBulle.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RAK811 Python 3 library for Raspberry Pi\n\n[![Latest Version](https://img.shields.io/pypi/v/rak811.svg)](https://pypi.org/project/rak811/)\n[![GitHub Action (Test and Publish)](https://github.com/AmedeeBulle/pyrak811/actions/workflows/test-and-publish.yml/badge.svg)](https://github.com/AmedeeBulle/pyrak811)\n[![codecov](https://codecov.io/gh/AmedeeBulle/pyrak811/branch/main/graph/badge.svg)](https://codecov.io/gh/AmedeeBulle/pyrak811)\n\n## About\n\nRAK811 Python 3 library and command-line interface for use with the Raspberry Pi LoRa (p)HAT.\n\nThe library exposes the RAK811 module AT commands as described in the following documents:\n\n- [RAK811 Lora AT Command User Guide V1.5](https://github.com/AmedeeBulle/pyrak811/blob/main/DOCS/RAK811%C2%A0LoRa%C2%A0AT%C2%A0Command%C2%A0V1.5.pdf) for modules with the V2.0.x firmware.\n- [RAK811 AT Command Manual V1.0](https://github.com/AmedeeBulle/pyrak811/blob/main/DOCS/RAK811_AT_Command_Manual_V1.0.pdf) for modules with the V3.0.x firmware.\n\nThe command-line interface exposes all API calls to the command line.\n\n## Requirements\n\n- A Raspberry Pi!\n- A RAK811 LoRa module ([PiSupply IoT LoRa Node pHAT for Raspberry Pi](https://uk.pi-supply.com/products/iot-lora-node-phat-for-raspberry-pi) / [RAK811 WisNode - LoRa](https://news.rakwireless.com/wisnode-lora-quick-start/))\n- On the Raspberry Pi the hardware serial port must be enabled and the serial console disabled (use `raspi-config`)\n- The user running the application must be in the `dialout` and `gpio` groups (this is the default for the `pi` user)\n\n## Install the rak811 package\n\nThe package is installed from PyPI:\n\n```shell\nsudo pip3 install rak811\n```\n\nThe `pip3` command is part of the `python3-pip` package. If it is missing on your system, run:\n\n```shell\nsudo apt-get install python3-pip\n```\n\n[PiSupply](https://uk.pi-supply.com/) provides [detailed instructions](https://learn.pi-supply.com/make/getting-started-with-the-raspberry-pi-lora-node-phat/) for configuring your Raspberry Pi.\n\n## Usage\n\n### Quick start with The Things Network\n\n#### Identify your device\n\nIf you don't know the firmware level of you module run the following commands:\n\n```shell\nrak811 hard-reset\nrak811 version\n```\n\nFor V2.0.x firmware use the `rak811` command and python module, for V3.0.X use `rak811v3` command and `rak811_v3` python module.\n\n#### Register your device\n\nRegister you device on [TheThingsNetwork](https://www.thethingsnetwork.org) using the unique id of your RAK811 module (Device EUI).  \nYou can retrieve your Device EUI with the following command (V2.0.x):\n\n```shell\nrak811 hard-reset\nrak811 get-config dev_eui\n```\n\n_Note_: the `rak811 hard-reset` command is only needed once after (re)booting your Raspberry Pi to activate the module.\n\nor (V3.0.x):\n\n```shell\nrak811v3 set-config lora:join_mode:0\nrak811v3 get-config lora:status | grep DevEui\n```\n\n#### Hello World\n\nSend your first LoRaWan message wit the following python code snippet:  \n(The App EUI and App Key are copied verbatim from the TTN console)\n\n```python\n#!/usr/bin/env python3\n# V2.0.x firmware\nfrom rak811.rak811 import Mode, Rak811\n\nlora = Rak811()\nlora.hard_reset()\nlora.mode = Mode.LoRaWan\nlora.band = 'EU868'\nlora.set_config(app_eui='70B3D5xxxxxxxxxx',\n                app_key='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')\nlora.join_otaa()\nlora.dr = 5\nlora.send('Hello world')\nlora.close()\n```\n\n```python\n#!/usr/bin/env python3\n# V3.0.x firmware\nfrom rak811.rak811_v3 import Rak811\n\nlora = Rak811()\nlora.set_config('lora:work_mode:0')\nlora.set_config('lora:join_mode:0')\nlora.set_config('lora:region:EU868')\nlora.set_config('lora:app_eui:70B3D5xxxxxxxxxx')\nlora.set_config('lora:app_key:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')\nlora.join()\nlora.set_config('lora:dr:5')\nlora.send('Hello world')\nlora.close()\n```\n\nYour first message should appear on the TTN console!\n\n### Next steps\n\nSee the [example directory on GitHub](https://github.com/AmedeeBulle/pyrak811/tree/main/examples):\n\n- `api_demo.py`: demo most of the V2.0.x API calls\n- `otaa.py` / `otaa_v3.py`: OTAA example\n- `otaa_v3_class_c.py`: OTAA example with device in Class C mode\n- `abp.py` / `abp_v3.py`: ABP example\n- `p2p.py` / `p2p_v3.py`: P2P example\n- `p2p.sh` / `p2p_v3.sh`: P2P example based on the command-line interface (see below)\n\nTo run the examples, first copy the `ttn_secrets_template.py` to `ttn_secrets.py` and enter your LoRaWan [TheThingsNetwork](https://www.thethingsnetwork.org) keys.\n\n_Note_: you do not need to `hard_reset` the module each time you run a script.\nHowever you must do it the first time after a (re)boot to activate the module.\n\n### balenaCloud\n\nSample code to use the library with [balenaCloud](https://www.balena.io/): [\nBasic RAK811 example with balenaCloud](https://github.com/AmedeeBulle/pyrak811-balena) (V2.0.x firmware).\n\n## Command-line interface\n\n### V2.0.x firmware\n\nThe `rak811` command exposes all library calls to the command line:\n\n```console\n$ rak811 --help\nUsage: rak811 [OPTIONS] COMMAND [ARGS]...\n\n  Command line interface for the RAK811 module.\n\nOptions:\n  -v, --verbose  Verbose mode\n  --help         Show this message and exit.\n\nCommands:\n  abp-info            Get ABP info.\n  band                Get/Set LoRaWan region.\n  clear-radio-status  Clear radio statistics.\n  dr                  Get/set next send data rate.\n  get-config          Get LoraWan configuration.\n  hard-reset          Hardware reset of the module.\n  join-abp            Join the configured network in ABP mode.\n  join-otaa           Join the configured network in OTAA mode.\n  link-cnt            Get up \u0026 downlink counters.\n  mode                Get/Set mode to LoRaWan or LoRaP2P.\n  radio-status        Get radio statistics.\n  recv-ex             RSSI \u0026 SNR report on receive.\n  reload              Set LoRaWan or LoRaP2P configurations to default.\n  reset               Reset Module or LoRaWan stack.\n  send                Send LoRaWan message and check for downlink.\n  set-config          Set LoraWAN configuration.\n  signal              Get (RSSI,SNR) from latest received packet.\n  sleep               Enter sleep mode.\n  version             Get module version.\n  wake-up             Wake up.\n```\n\nSession example:\n\n```console\n$ rak811 -v reset lora\nLoRa reset complete.\n$ rak811 -v set-config app_eui=70B3D5xxxxxxxxxx app_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nLoRaWan parameters set\n$ rak811 -v join-otaa\nJoined in OTAA mode\n$ rak811 -v dr\n5\n$ rak811 -v dr 4\nData rate set to 4.\n$ rak811 -v send Hello\nMessage sent.\nNo downlink available.\n$ rak811 -v send --port 4 --binary '01020211'\nMessage sent.\nDownlink received:\nPort: 1\nRSSI: -56\nSNR: 31\nData: 123456\n```\n\n_Note_: for your first session after boot, you will need to do a `hard-reset` instead of a `reset lora` command to activate the module.\n\n### V3.0.x firmware\n\nThe `rak811v3` command exposes the following library calls to the command line:\n\n```console\n$ rak811v3 --help\nUsage: rak811v3 [OPTIONS] COMMAND [ARGS]...\n\n  Command line interface for the RAK811 module.\n\nOptions:\n  -v, --verbose  Verbose mode\n  -d, --debug    Debug mode\n  --version      Show the version and exit.\n  --help         Show this message and exit.\n\nCommands:\n  get-config   Execute get_config RAK811 command.\n  hard-reset   Hardware reset of the module.\n  help         Print module help.\n  join         Join the configured network.\n  receive-p2p  Get LoraP2P message.\n  run          Exit boot mode and enter normal mode.\n  send         Send LoRaWan message and check for downlink.\n  send-p2p     Send LoRa P2P message.\n  send-uart    Send data to UART.\n  set-config   Execute set_config RAK811 command.\n  version      Get module version.\n```\n\nSession example:\n\n```console\n$ rak811v3 -v set-config lora:work_mode:0\nConfiguration done\nLoRa (R) is a registered trademark or service mark of Semtech Corporation or its affiliates. LoRaWAN (R) is a licensed mark.\nRAK811 Version:3.0.0.14.H\nUART1 work mode: RUI_UART_NORMAL, 115200, N81\nUART3 work mode: RUI_UART_NORMAL, 115200, N81\nLoRa work mode:LoRaWAN, join_mode:OTAA, MulticastEnable: false, Class: A\n$ # The following is not necessary as in this case the module is already in OTAA mode!\n$ rak811v3 -v set-config lora:join_mode:0\nConfiguration done\n$ rak811v3 -v set-config lora:app_eui:70B3D5xxxxxxxxxx\nConfiguration done\n$ rak811v3 -v set-config lora:app_key:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nConfiguration done\n$ rak811v3 -v join\nJoined!\n$ rak811v3 get-config lora:status | grep 'Current Datarate'\nCurrent Datarate: 4\n$ rak811v3 -v set-config lora:dr:5\nConfiguration done\n$ rak811v3 -v send 'Hello'\nMessage sent.\nNo downlink available.\n$ rak811v3 -v set-config lora:confirm:1\nConfiguration done\n$ rak811v3 -v send --port 4 --binary '01020211'\nMessage sent.\nSend confirmed.\nRSSI: -66\nSNR: 6\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famedeebulle%2Fpyrak811","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famedeebulle%2Fpyrak811","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famedeebulle%2Fpyrak811/lists"}