Coder Social home page Coder Social logo

lightlora_micropython's Introduction

A MicroPython Library for Controlling a Semtech SX127x LoRa Chip

This is yet another library for controlling an SX127x Semtech chip. This is entirely interrupt driven (transmit and receive) with callbacks.

For power usage, you can sleep the CPU while waiting for an interrupt during transmit and receive cycles.

There is a nearly exact copy of this library for Arduino here https://github.com/MZachmann/LightLora_Arduino

Installation

The library (LightLora) folder can just be copied and used as-is in a project.

Usage

During setup call

from LightLora import lorautil

lru = lorautil.LoraUtil()

During the loop you can

if lru.isPacketAvailable():
	pkt = lru.readPacket()
	print(pkt.msgTxt)
...
txt = "Hello World"
lru.sendPacket(0xff, 0x11, txt.encode()) # random dst, src at

The packet definition is:

class LoraPacket:
	def __init__(self):
		self.srcAddress = None
		self.dstAddress = None
		self.srcLineCount = None
		self.payLength = None
		self.msgTxt = None
		self.rssi = None
		self.snr = None

Customization

The ports for the LoRa device are set in spicontrol.py for now.

The _doTransmit and _doReceive methods in lorautil.LoraUtil are the callbacks on interrupt.

Changelog: Jul 3, 2018 -

  • In lorarun.py (the example) make lr a global so comm options can be changed manually before calling doreader()
  • Add a synchronous send method in lorarun.py since the sendPacket method is now asynchronous
  • add reset, sleep, isPacketSent, and setFrequency methods to LoraUtil to mimic the Arduino implementation
  • add power_pin option to sx127x parameter set
  • use signal bandwidth as integer

lightlora_micropython's People

Contributors

mzachmann avatar torntrousers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lightlora_micropython's Issues

License file?

The license terms are unclear at the moment. Is this another MIT-licensed project?

AttributeError: 'module' object has no attribute 'SpiControl'

I test this code to pyboard,but some error info as follow show:

from LightLora import sx127x
from LightLora import spicontrol
from LightLora import lorautil
l = lorautil.LoraUtil()
Traceback (most recent call last):
File "", line 1, in
File "LightLora/lorautil.py", line 32, in init
AttributeError: 'module' object has no attribute 'SpiControl'

How to solve this issue.Thanks!

Doesn't work with Loboris MicroPython

Thanks for the great library. There doesn't appear to be any other easy to use Lora library that works with MicroPython with a liberal license, so happy to find yours.

It doesn't work with the Loboris version of MicroPython though and that seems by far the best version for ESP32's - https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo

The only change needed is in sx127x _prepIrqHandler. Would you accept a pull request for this?

_thread library needs updating

I'm not good with this pull request technology. I got it working (I think) with, in sx127x.py:

	self._lock = _thread.allocate_lock()

and then:

def acquire_lock(self, lock=False):
	if self._lock:
		if lock:
			self._lock.acquire()
		else:
			self._lock.release()

Also, I think it would be easier for folks if it indented with spaces instead of tabs

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.