{"id":15142164,"url":"https://github.com/aallan/pico-lorawan-circuitpython","last_synced_at":"2025-09-01T12:07:20.296Z","repository":{"id":66719998,"uuid":"362030926","full_name":"aallan/pico-lorawan-circuitpython","owner":"aallan","description":"Raspberry Pi Pico and LoRaWAN from CircuitPython","archived":false,"fork":false,"pushed_at":"2021-07-01T09:09:29.000Z","size":1495,"stargazers_count":28,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-30T04:28:58.998Z","etag":null,"topics":["circuitpython","lorawan","raspberry-pi-pico"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aallan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-27T08:05:24.000Z","updated_at":"2025-08-25T09:25:54.000Z","dependencies_parsed_at":"2023-04-12T05:34:36.655Z","dependency_job_id":null,"html_url":"https://github.com/aallan/pico-lorawan-circuitpython","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aallan/pico-lorawan-circuitpython","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aallan%2Fpico-lorawan-circuitpython","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aallan%2Fpico-lorawan-circuitpython/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aallan%2Fpico-lorawan-circuitpython/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aallan%2Fpico-lorawan-circuitpython/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aallan","download_url":"https://codeload.github.com/aallan/pico-lorawan-circuitpython/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aallan%2Fpico-lorawan-circuitpython/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273122111,"owners_count":25049539,"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","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["circuitpython","lorawan","raspberry-pi-pico"],"created_at":"2024-09-26T09:24:09.975Z","updated_at":"2025-09-01T12:07:20.251Z","avatar_url":"https://github.com/aallan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Raspberry Pi Pico and LoRaWAN from CircuitPython\n\n![Hero image](/images/hero-image.jpg)\n\nEnable LoRaWAN communications on your [Raspberry Pi Pico](https://www.raspberrypi.org/products/raspberry-pi-pico/) or any RP2040-based board using [CircuitPython](https://circuitpython.org/board/raspberry_pi_pico/) and the Adafruit [TinyLoRa](https://github.com/adafruit/Adafruit_CircuitPython_TinyLoRa) library. Based on the TinyLoRa [example code](https://learn.adafruit.com/using-lorawan-and-the-things-network-with-circuitpython/using-tinylora#the-code-3010429-2) by Adafruit.\n\n## Bill of Materials\n\nThe following hardware is needed:\n\nItem | Link \n------------ | -------------\nRaspberry Pi Pico | https://www.raspberrypi.org/products/raspberry-pi-pico/\nAdafruit RFM95x Lora Radio | https://www.adafruit.com/product/3072\nEdge-Mount SMA Connector | https://www.adafruit.com/product/1865\n868MHz or 915MHz Antenna | https://www.adafruit.com/product/3340\nMale-Female Jumper Wires | https://www.adafruit.com/product/1953\nBreadboard | https://www.adafruit.com/product/64\n\n## Wiring the RFM9x Radio Module\n\n![Wiring diagram](/images/pico-and-rfm9x.png)\n\nAfter [soldering](https://learn.adafruit.com/adafruit-rfm69hcw-and-rfm96-rfm95-rfm98-lora-packet-padio-breakouts/assembly#step-2433237) your RFM95x module and attaching [an antenna](https://learn.adafruit.com/adafruit-rfm69hcw-and-rfm96-rfm95-rfm98-lora-packet-padio-breakouts/assembly#antenna-options-2433239-6) the mapping between the pins on the module breakout board and your Pico should be as follows:\n\nPico | RP2040 | SX1276 Module | RFM95W Breakout\n------------ | ------------- | ------------ | -------------\n3V3 (OUT) | — | VCC | VIN\nGND | GND | GND | GND\nPin 10 | GP7 | DIO0 | G0\nPin 11 | GP8 | NSS | CS\nPin 12 | GP9 | RESET | RST\nPin 14 | GP10 | DIO1 | G1\nPin 21 | GP16 (SPI0 RX) | MISO | MISO\nPin 24 | GP18 (SPI0 SCK) | SCK | SCK\nPin 25 | GP19 (SPI0 TX) | MOSI | MOSI\n\n## The Things Network\n\nTo make use of a LoraWAN-enabled Pico you’re going to need to be in range of a LoRa gateway. Fortunately there is [The Things Network](https://www.thethingsnetwork.org/), an open-source community LoRaWAN network that has [global coverage](https://www.thethingsnetwork.org/map). Depending on where you are located, it’s quite possible that you’re already in coverage. However, if you aren’t, then you needn’t worry too much, the days when the cost of a LoRaWAN base station was of the order of several thousand dollars are long gone. You can now pick up a LoRa gateway for [under $100](https://amzn.to/3tFwFMZ).\n\nWhile any LoRa device in range of your new gateway will have its packets received and sent upstream to The Things Network, the data packets will be dropped on the ground unless they have somewhere to go. In other words, The Things Network needs to know where to route the packets your gateway is receiving.\n\n### Setting up The Things Network\n\nAdafruit has written up a [full walkthrough](https://learn.adafruit.com/using-lorawan-and-the-things-network-with-circuitpython/tinylora-ttn-setup) on how to set up and application and register your device with The Things Network. You'll need to set three unique identifiers in the [`code.py`](https://github.com/aallan/pico-lorawan-circuitpython/blob/main/src/code.py) file; the Device Address, Network Session Key, and Application Session Key. These can be found [on the Device Overview page](https://learn.adafruit.com/using-lorawan-and-the-things-network-with-circuitpython/using-tinylora#setting-up-the-code-for-the-things-network-3010430-10).\n\n**NOTE:** The example code uses ABP rather than OTAA as the Activation Method.\n\n## Deploying to your Pico\n\nCopy the contents of the [`src/`](https://github.com/aallan/pico-lorawan-circuitpython/tree/main/src) directory in the repo to your `CIRCUITPY` drive. This includes the `code.py` file and the `lib/` folder and all of its contents, including subfolders and any `.mpy` files present in the library directory.\n\n## Sending data\n\nRestart the board. The code should start running immediately, there will be debug output available on the USB CDC Serial console. If you see \"Packet Sent!\" then the packets are being sent up to The Things Network via LoRaWAN and you should be able to see your data arriving in the Network Console.\n\n## Adding a decoder\n\nWe're sending out temperature reading as a byte array.\n\n```C\ntemp = microcontroller.cpu.temperature\ntemp = int(temp * 100)\n\ndata = bytearray(2)\ndata[0] = (temp \u003e\u003e 8) \u0026 0xFF\ndata[1] = temp \u0026 0xFF\n```\n\nBy default the payload is displayed as a hexidecimal values in the Network Console. However we can [add a data decoder](https://learn.adafruit.com/using-lorawan-and-the-things-network-with-circuitpython/using-tinylora#decoding-the-payload-3010444-33);\n\n```javascript\nfunction Decoder(bytes, port) {\n  var decoded = {};\n  var celciusInt = (bytes[0] \u003c\u003c 8) | bytes[1];\n  decoded.temp = celciusInt / 100;\n\n  return decoded;\n```\n\nthis will auto-magically decode the raw payload and display the real value in The Things Network Console.\n\n## More information\n\nYou can find more information about [using LoRaWAN and The Things Network from CircuitPython](https://learn.adafruit.com/using-lorawan-and-the-things-network-with-circuitpython/overview) in the Adafruit RFM95x tutorial pages. Alternatively you may want to use the RFM95x module using C, in which case you should take a look at Sandeep Mistry's [`pico-lorawan`](https://github.com/sandeepmistry/pico-lorawan) library, and [getting started instructions](https://www.raspberrypi.org/blog/how-to-add-lorawan-to-raspberry-pi-pico/).\n\n## Libraries\n\nThe following libraries are used:\n\nLibrary | License | Github\n------------ | ------------- | -------------\nBus Device | MIT | https://github.com/adafruit/Adafruit_CircuitPython_BusDevice\nRFM95x | MIT | https://github.com/adafruit/Adafruit_CircuitPython_RFM9x\nTinyLoRa | LGPL | https://github.com/aallan/pico-lorawan-circuitpython\n\n## License\n\nThis software is released under the [MIT License](https://opensource.org/licenses/MIT).\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faallan%2Fpico-lorawan-circuitpython","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faallan%2Fpico-lorawan-circuitpython","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faallan%2Fpico-lorawan-circuitpython/lists"}