Skip to content

dmartauz/pySX127x

 
 

Repository files navigation

The goal of this project is to establish a hardware abstraction layer (HAL) for the LoRa enabled Semtech products (SX127x family of products) and develop a new lightweight MAC on top of that HAL.

The HAL is called pySX127x and is based on a fork from mayeranalytics/pySX127x. While that library does support most of the HAL structure and functionality it misses some core components in its implementation that make a working mac possible. This forks hopes to solve these problems.

On top of the HAL I propose a new frame and MAC: https://docs.google.com/document/d/1Sq9PpJEgrIUhoHNiEBYE2o-o-eLmORtiXB1pQK6GBKQ/edit?usp=sharing

This is still a work in progress. Code is being updated every day and not stable!

Hardware

I'm using a Rasberry Pi Model B+ + Mbed LoRa SX1276 module. I designed a simple 'shield' PCB that interfaces between the Mbed PCB and the Raspberry Pi. Should you be interested you can contact me.

Installation

enable SPI on the raspberry pi by using

sudo raspi-config 

and enabling the SPI module

after that install spidev

can update Rasperry Pi

sudo apt-get update
sudo apt-get install python-dev

spidev files are included in repo

mkdir git-repos
git clone https://github.com/thomasverbeke/pySX127x.git
git config --global user.email 'thomasverbeke@gmail.com'
git config --global user.name 'Thomas Verbeke'

cd pi-spidev
sudo python setup.py install

Git commands

git status
git commit -a
git push

In order to install spidev download the source code and run setup.py manually:

wget https://pypi.python.org/packages/source/s/spidev/spidev-3.1.tar.gz
tar xfvz  spidev-3.1.tar.gz
cd spidev-3.1
sudo python setup.py install

LoRaMAC features:

*ETSI compliance is imposed with duty cycle limit/ band
    *Payload header for packet filtering (iterative algortihm)
    *Optional ACK in receive window and retransmissions
    *MAC commands to change SF/Channel/Power
    *Flexible network architecture

Future: I want to add retransmission, multiple frame, clock sync, calc param based on interval needs,...

Examples:

Name Details
Ping-Pong Classic ping-pong without MAC. Pong.py should be started first. Pong starts in continuous listening mode. After receiving a "PING" message, it answers with a "PONG" message and goes back into continous transmission mode. *
Listen Listener for LoRa communication. Will display data in both hex and byte format *
Beacon Transmit message over regular interval*
Listen ON MAC Listener for LoRaMAC communication, when valid frame is received an ACK is send
Beacon ON MAC Send a string over LoRa in a regular interval and open a short receive window to receive ACK
RangeTest ON MAC Loop over all channels for alle spreading factors. Signal listener before switching channel/sf (and change settings on ACK)

* This code does not comply with RF regulations; so the time interval should be set according to local regulations (ETSI, REC,..)

update: listen.py is a work in progress: In the future demo's will be split into demo's running on the HAL and demo's running on the new MAC.

About

This is a python interface to the Semtech SX127x long range, low power transceiver family.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%