Giter Site home page Giter Site logo

ulora's Introduction

Disclaimer

Although successfully tested with limited functionality, this project is still currently work in progress and there is no guarantee that it works as intended.

Introduction

This is an experimental port of Adafruit's CircuitPython Tiny LoRa / LoRaWAN driver to MicroPython which allows IoT things to transmit light payloads to The Things Network (TTN).

Original Adafruit repository from which this project has been forked is available here:

https://github.com/adafruit/Adafruit_CircuitPython_TinyLoRa

Objecive

The aim is to enable LoRa / LoRaWAN capability on MicroPython ESP32 builds, using only minimal (and where possible) native MicroPython libraries. By in large the code resembles the original, but where applicable, libraries and syntax have been adapted for MicroPython. One notable modification is the omission of Adafruit's Bus Device library (replaced with native SPI libraries).

Being tested on

The project is currently being tested in a limited capacity using:

The premise of the port is that CircuitPython is equipped with a RF module, namely the RFM9x module. As the LoRa component of the RFM module is based on a Semtech SX1276, all of the code relating to the SPI communication should be transferrable. It may work with other SX127X variants.

docs/heltec_esp32_lora_v2.JPG

Further information on CircuitPython can be found here:

https://learn.adafruit.com/using-lorawan-and-the-things-network-with-circuitpython/overview

Usage example

Note that DEVADDR, NWKEY and APP are shown against your device in the TTN console (if ABP has been configured).

SX1276 module requires a number of standard SPI pins (CS, SCK, MOSI and MISO), as well as IRQ and RST.

import utime
from ulora import TTN, uLoRa
# Refer to device pinout / schematics diagrams for pin details
LORA_CS = const(18)
LORA_SCK = const(5)
LORA_MOSI = const(27)
LORA_MISO = const(19)
LORA_IRQ = const(26)
LORA_RST = const(14)
LORA_DATARATE = "SF9BW125"  # Choose from several available
# From TTN console for device
DEVADDR = bytearray([0x00, 0x00, 0x00, 0x00])
NWKEY = bytearray([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
APP = bytearray([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
TTN_CONFIG = TTN(DEVADDR, NWKEY, APP, country="EU")
FPORT = 1
lora = uLoRa(
    cs=LORA_CS,
    sck=LORA_SCK,
    mosi=LORA_MOSI,
    miso=LORA_MISO,
    irq=LORA_IRQ,
    rst=LORA_RST,
    ttn_config=TTN_CONFIG,
    datarate=LORA_DATARATE,
    fport=FPORT
)
# ...Then send data as bytearray
lora.send_data(data, len(data), lora.frame_counter)

Throughout, the region (and therefore frequencies) defaults to "EU" unless explicitly specified.

Further information

The Semtech SX1276 LoRA transceiver datasheet can be found here:

The LoRaWAN specification can be found here:

Rosie the Red Robot blog post detailing the experience with this driver can be found here:

ulora's People

Contributors

brentru avatar fantasticdonkey avatar jerryneedell avatar kattni avatar ladyada avatar philwilkinson40 avatar siddacious avatar sommersoft avatar thekitty avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.