GithubHelp home page GithubHelp logo

mayeranalytics / pysx127x Goto Github PK

View Code? Open in Web Editor NEW
170.0 25.0 115.0 125 KB

This is a python interface to the Semtech SX127x, HopeRF RFM9x, Microchip RN2483 long range, low power transceiver families.

License: GNU Affero General Public License v3.0

Python 100.00%

pysx127x's Introduction

Overview

This is a python interface to the Semtech SX1276/7/8/9 long range, low power transceiver family.

The SX127x have both LoRa and FSK capabilities. Here the focus lies on the LoRa spread spectrum modulation hence only the LoRa modem interface is implemented so far (but see the roadmap below for future plans).

Spread spectrum modulation has a number of intriguing features:

  • High interference immunity
  • Up to 20dBm link budget advantage (for the SX1276/7/8/9)
  • High Doppler shift immunity

More information about LoRa can be found on the LoRa Alliance website. Links to some LoRa performance reports can be found in the references section below.

Motivation

Transceiver modules are usually interfaced with microcontroller boards such as the Arduino and there are already many fine C/C++ libraries for the SX127x family available on github and mbed.org.

Although C/C++ is the de facto standard for development on microcontrollers, python running on a Raspberry Pi (NanoPi, BananaPi, UDOO Neo, BeagleBoard, etc. etc.) is becoming a viable alternative for rapid prototyping.

High level programming languages like python require a full-blown OS such as Linux. (There are some exceptions like MicroPython and its fork CircuitPython.) But using hardware capable of running Linux contradicts, to some extent, the low power specification of the SX127x family. Therefore it is clear that this approach aims mostly at prototyping and technology testing.

Prototyping on a full-blown OS using high level programming languages has several clear advantages:

  • Working prototypes can be built quickly
  • Technology testing ist faster
  • Proof of concept is easier to achieve
  • The application development phase is reached quicker

Hardware

The transceiver module is a SX1276 based Modtronix inAir9B. It is mounted on a prototyping board to a Raspberry Pi rev 2 model B.

Proto board pin RaspPi GPIO Direction
inAir9B DIO0 GPIO 22 IN
inAir9B DIO1 GPIO 23 IN
inAir9B DIO2 GPIO 24 IN
inAir9B DIO3 GPIO 25 IN
inAir9b Reset GPIO ? OUT
LED GPIO 18 OUT
Switch GPIO 4 IN

Todo:

  • Add picture(s)
  • Wire the SX127x reset to a GPIO?

Code Examples

Overview

First import the modules

from SX127x.LoRa import *
from SX127x.board_config import BOARD

then set up the board GPIOs

BOARD.setup()

The LoRa object is instantiated and put into the standby mode

lora = LoRa()
lora.set_mode(MODE.STDBY)

Registers are queried like so:

print(lora.version())        # this prints the sx127x chip version
print(lora.get_freq())       # this prints the frequency setting 

and setting registers is easy, too

lora.set_freq(433.0)       # Set the frequency to 433 MHz 

In applications the LoRa class should be subclassed while overriding one or more of the callback functions that are invoked on successful RX or TX operations, for example.

class MyLoRa(LoRa):

  def __init__(self, verbose=False):
    super(MyLoRa, self).__init__(verbose)
    # setup registers etc.

  def on_rx_done(self):
    payload = self.read_payload(nocheck=True) 
    # etc.

In the end the resources should be freed properly

BOARD.teardown()

More details

Most functions of SX127x.Lora are setter and getter functions. For example, the setter and getter for the coding rate are demonstrated here

print(lora.get_coding_rate())                # print the current coding rate
lora.set_coding_rate(CODING_RATE.CR4_6)     # set it to CR4_6

@todo

Installation

Make sure SPI is activated on you RaspberryPi: SPI pySX127x requires these two python packages:

  • RPi.GPIO for accessing the GPIOs, it should be already installed on a standard Raspian Linux image
  • spidev for controlling SPI

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

At this point you may want to confirm that the unit tests pass. See the section Tests below.

You can now run the scripts. For example dump the registers with lora_util.py:

rasp$ sudo ./lora_util.py
SX127x LoRa registers:
 mode               SLEEP
 freq               434.000000 MHz
 coding_rate        CR4_5
 bw                 BW125
 spreading_factor   128 chips/symb
 implicit_hdr_mode  OFF
 ... and so on ....

Class Reference

The interface to the SX127x LoRa modem is implemented in the class SX127x.LoRa.LoRa. The most important modem configuration parameters are:

Function Description
set_mode Change OpMode, use the constants.MODE class
set_freq Set the frequency
set_bw Set the bandwidth 7.8kHz ... 500kHz
set_coding_rate Set the coding rate 4/5, 4/6, 4/7, 4/8
@todo

Most set_* functions have a mirror get_* function, but beware that the getter return types do not necessarily match the setter input types.

Register naming convention

The register addresses are defined in class SX127x.constants.REG and we use a specific naming convention which is best illustrated by a few examples:

Register Modem Semtech doc. pySX127x
0x0E LoRa RegFifoTxBaseAddr REG.LORA.FIFO_TX_BASE_ADDR
0x0E FSK RegRssiCOnfig REG.FSK.RSSI_CONFIG
0x1D LoRa RegModemConfig1 REG.LORA.MODEM_CONFIG_1
etc.

Hardware

Hardware related definition and initialisation are located in SX127x.board_config.BOARD. If you use a SBC other than the Raspberry Pi you'll have to adapt the BOARD class.

Script references

Continuous receiver rx_cont.py

The SX127x is put in RXCONT mode and continuously waits for transmissions. Upon a successful read the payload and the irq flags are printed to screen.

usage: rx_cont.py [-h] [--ocp OCP] [--sf SF] [--freq FREQ] [--bw BW]
                  [--cr CODING_RATE] [--preamble PREAMBLE]

Continous LoRa receiver

optional arguments:
  -h, --help            show this help message and exit
  --ocp OCP, -c OCP     Over current protection in mA (45 .. 240 mA)
  --sf SF, -s SF        Spreading factor (6...12). Default is 7.
  --freq FREQ, -f FREQ  Frequency
  --bw BW, -b BW        Bandwidth (one of BW7_8 BW10_4 BW15_6 BW20_8 BW31_25
                        BW41_7 BW62_5 BW125 BW250 BW500). Default is BW125.
  --cr CODING_RATE, -r CODING_RATE
                        Coding rate (one of CR4_5 CR4_6 CR4_7 CR4_8). Default
                        is CR4_5.
  --preamble PREAMBLE, -p PREAMBLE
                        Preamble length. Default is 8.

Simple LoRa beacon tx_beacon.py

A small payload is transmitted in regular intervals.

usage: tx_beacon.py [-h] [--ocp OCP] [--sf SF] [--freq FREQ] [--bw BW]
                    [--cr CODING_RATE] [--preamble PREAMBLE] [--single]
                    [--wait WAIT]

A simple LoRa beacon

optional arguments:
  -h, --help            show this help message and exit
  --ocp OCP, -c OCP     Over current protection in mA (45 .. 240 mA)
  --sf SF, -s SF        Spreading factor (6...12). Default is 7.
  --freq FREQ, -f FREQ  Frequency
  --bw BW, -b BW        Bandwidth (one of BW7_8 BW10_4 BW15_6 BW20_8 BW31_25
                        BW41_7 BW62_5 BW125 BW250 BW500). Default is BW125.
  --cr CODING_RATE, -r CODING_RATE
                        Coding rate (one of CR4_5 CR4_6 CR4_7 CR4_8). Default
                        is CR4_5.
  --preamble PREAMBLE, -p PREAMBLE
                        Preamble length. Default is 8.
  --single, -S          Single transmission
  --wait WAIT, -w WAIT  Waiting time between transmissions (default is 0s)

Tests

Execute test_lora.py to run a few unit tests.

Contributors

Please feel free to comment, report issues, or contribute!

Contact me via my company website Mayer Analytics and my private blog mcmayer.net.

Follow me on twitter @markuscmayer and @mayeranalytics.

Roadmap

95% of functions for the Sx127x LoRa capabilities are implemented. Functions will be added when necessary. The test coverage is rather low but we intend to change that soon.

Semtech SX1272/3 vs. SX1276/7/8/9

pySX127x is not entirely compatible with the 1272. The 1276 and 1272 chips are different and the interfaces not 100% identical. For example registers 0x26/27. But the pySX127x library should get you pretty far if you use it with care. Here are the two datasheets:

HopeRF transceiver ICs

HopeRF has a family of LoRa capable transceiver chips RFM92/95/96/98 that have identical or almost identical SPI interface as the Semtech SX1276/7/8/9 family.

Microchip transceiver IC

Likewise Microchip has the chip RN2483

The pySX127x project will therefore be renamed to pyLoRa at some point.

LoRaWAN

LoRaWAN is a LPWAN (low power WAN) and, and pySX127x has almost no relationship with LoRaWAN. Here we only deal with the interface into the chip(s) that enable the physical layer of LoRaWAN networks. If you need a LoRaWAN implementation have a look at Jeroennijhofs LoRaWAN which is based on pySX127x.

By the way, LoRaWAN is what you need when you want to talk to the TheThingsNetwork, a "global open LoRaWAN network". The site has a lot of information and links to products and projects.

References

Hardware references

LoRa performance tests

Spread spectrum modulation theory

Copyright and License

© 2015 Mayer Analytics Ltd., All Rights Reserved.

Short version

The license is GNU AGPL.

Long version

pySX127x is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

pySX127x is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You can be released from the requirements of the license by obtaining a commercial license. Such a license is mandatory as soon as you develop commercial activities involving pySX127x without disclosing the source code of your own applications, or shipping pySX127x with a closed source product.

You should have received a copy of the GNU General Public License along with pySX127. If not, see http://www.gnu.org/licenses/.

Other legal boredom

LoRa, LoRaWAN, LoRa Alliance are all trademarks by ... someone.

pysx127x's People

Contributors

bjcarne avatar dwhall avatar iz7boj avatar mcmayer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pysx127x's Issues

connecting to Pi

Hi,

This is more of a request than an issue.

Can you post a picture or a diagram of the connections between the Pi and inAir9.

Thanks.

Request, not issue. BeagleBone support

Hi, I'm sorry for putting this in the issues, but I'm new to Github, and I wasn't sure how to send you a request. Is there any way this can be converted to use the Beaglebone platform instead of the Raspberry Pi? I was thinking maybe you would use the Adafruit BBIO library instead of RPi.GPIO? I'm not a developer by any stretch, but I was just wondering what it would take to do something like that? I have a 433Mhz LoRa RFM9 board that uses SPI, but I'm not sure how to get it to talk to my Beaglebone Blue. I wired up the MOSI/MISO, CLK, and CS correctly, but I don't know how to send or listen for packets with it. Any help or comments would be appreciated.

Weird behaviour using the beacon class for some bytes

When sending some byte for example "0x00", or "0x67" the interrupt (TxDone) will not be generated the third time. This is a very weird bug? It can be reproduced by changing the 1-byte message (0x0f) to 0x00 or 0x67 for example in the beacon. When extending the message to multiple bytes the same thing will happen when these bytes are part of the larger message.

Error when we run test_lora.py

/home/pi/Git/Git-clone/pySX127x/SX127x/board_config.py:61: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(BOARD.LED, GPIO.OUT)
/home/pi/Git/Git-clone/pySX127x/SX127x/board_config.py:62: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(BOARD.RST, GPIO.OUT)
Traceback (most recent call last):
File "test_lora.py", line 130, in
lora = LoRa(verbose=False)
File "/home/pi/Git/Git-clone/pySX127x/SX127x/LoRa.py", line 95, in init
BOARD.add_events(self._dio0, self._dio1, self._dio2, self._dio3, self._dio4, self._dio5)
File "/home/pi/Git/Git-clone/pySX127x/SX127x/board_config.py", line 105, in add_events
BOARD.add_event_detect(BOARD.DIO0, callback=cb_dio0)
File "/home/pi/Git/Git-clone/pySX127x/SX127x/board_config.py", line 101, in add_event_detect
GPIO.add_event_detect(dio_number, GPIO.RISING, callback=callback)
RuntimeError: Failed to add edge detection

AssertionError

My project has worked 4 months ago, but i haven't used it since. I am now using a PCB and when i execute the test_lora.py programm i get following error:

=======================================================
FAIL: test_mode (main.TestSX127x)

Traceback (most recent call last):
File "test_lora.py", line 43, in wrapper
func(self)
File "test_lora.py", line 62, in test_mode
self.assertEqual(lora.get_mode(), m)
AssertionError: 128 != 129


Thank you in advance.

size of the received payload fixed ?

I am using RBPI3 with Ra_02
I am testing the rx_cont.py example, I have successfully get it to work with my board, however I am only receiving 5 characters payloads
I notice that rx_nb_bytes (which is equal to spi.xfer([REG.LORA.RX_NB_BYTES, 0])) is always returning the same value 9.
so the payload size is fixed to 9 bytes.
in the following example I tried to send the string "hello":
I got:
payload = [255, 255, 0, 0, 104, 101, 108, 108, 111]
first 4 elements are fixed no matter what message I sent.
the next 5 element are the byte representation of the characters that I have sent.
** THE PROBLEM **
why I can't receive more bytes ?

Calculating SNR

I am wondering if the calculation of the SNR is correct. The datasheet (sx1278) says the following:

Estimation of SNR on last packet received.In two’s compliment format multiplied by 4
SNR dB = PacketSnr [twos complement] / 4

This is achieved with the following code:
def get_pkt_snr_value(self): v = self.spi.xfer([REG.LORA.PKT_SNR_VALUE, 0])[1] return float(256-v) / 4.

This is a bit over my head but when i look at the RAW value that i get from the register i see "0b101100" = decimal 44.
256 - 44 = 212
212 / 4 = 53.

What does the 256 - v do?

Error when running test_lora.py

Hi there is already an issue with a similar title but my error is different.
I am using rpi 3 and i have triple checked that my connections are right and soldering is okay.
I get this error when i run the python file:

======================================================================
FAIL: test_mode (main.TestSX127x)


Traceback (most recent call last):
File "./test_lora.py", line 43, in wrapper
func(self)
File "./test_lora.py", line 62, in test_mode
self.assertEqual(lora.get_mode(), m)
AssertionError: 128 != 129


Ran 6 tests in 0.011s

FAILED (failures=1)

Any help will be appreciated.

I can't receive LoRa messages

Hello,
I am using Raspberry pi with inair9 module. I tried to use your library to communicate with the radio module. The tests pass, the radio module seems communicating.
when I lunch the program:
sudo python rx_cont.py -r CR4_5 -s 12 -f 868

I only get the RSSI going up and down. I received no messages.
I am using libelium module to send messages on the correspondant channel and spreading factor and data rate.

however I only notice that the RSSI go down (from -110 to -20) when I sent messages using libelium.
Any idea of what have I missed in the configuration to be able to receive messages?

Thanks!

(small) mistake in documentation

I think there is a (small) mistake in your documentation in board_config.py from line 33

# Note that the BCOM numbering for the GPIOs is used.
DIO0 = 22   # RaspPi GPIO 21
DIO1 = 23   # RaspPi GPIO 22
DIO2 = 24   # RaspPi GPIO 23
DIO3 = 25   # RaspPi GPIO 24
LED  = 18   # RaspPi GPIO 18 connects to the LED on the proto shield
SWITCH = 4  # RaspPi GPIO 4 connects to a switch

Should say DIO0 = 22 # RaspPi GPIO 22 instead of 21

AssertionError

Hi,
I m trying to use your libraray so i can use the sx1276.
I got an error while trying tot run the file lora_util.py even i tried with version3 of python.
the error is he following:

Traceback (most recent call last):
File "lora_util.py", line 35, in
lora = LoRa(verbose=False)
File "/home/pi/Desktop/pySX127x/SX127x/LoRa.py", line 100, in init
self.rx_chain_calibration(calibration_freq)
File "/home/pi/Desktop/pySX127x/SX127x/LoRa.py", line 856, in rx_chain_calibra
self.set_freq(freq_bkup)
File "/home/pi/Desktop/pySX127x/SX127x/LoRa.py", line 282, in set_freq
assert self.mode == MODE.SLEEP or self.mode == MODE.STDBY or self.mode == MO
AssertionError

Can you help me please..??

Data rate received

Hello i use your library to do communication with SX1278 between ESP32 which send the package and Raspberry Pi received the package. In this case i save the data to csv file for the sample rate i get always around 40-80 ms for one data i got around 12 data for one second. For my system i need higher data rate more data received per second i want around more than 500 data per second could you help me how to do this?.

pySX127 @ 915 Mhz, files to be changed

Hi There

I'm wondering if someone can help me to sort out what other changes must be applied to work with a SX1276 LoRa Module, 915MHz.
Also just wondering in class BOARD, what exactly the function of SWITCH is?
Thanks in advance

Tried to send data from RPi to Arduino but Arduino did not receive data

Hello, i am trying to perform the client and the server side of which arduino is the client and RPi is the server based on the rpsreal/LoRa_Ra-02_Arduino given examples. However, when RPi send data to Arduino, Arduino does not receive data from the RPi.
I have changed nothing from the code. I use sx1278 Ra-02 module.

Question about link rates and multicast

I have a unique use case that I am considering pySX127x for and I am curious if this would be a possible configuration. I have a large number of sensors which receive information in a one-way serial fashion, using a UART speed of 115.2K. These are broadcast messages that go to all end nodes and without a requirement for two way communications. Is this a possibility with the Semtech line and pySX127x?

Also I can't make heads or tails out of the Semtech datasheet and data calculator table for coding rates, any ideas what an appropriate coding rate for 115.2K would be?

More of a question, since I didn't see where to post this here...

I have a Cypress USB-UART that has the SX1272 chipset. Looking to use this on my Windows 7 Pro 64-bit laptop. As a receiver, since the transmitter is an Arduino Uno with a Dragino Lora GPS shield on top of it. The transmitter is working fine. Would like to avoid setting up another Arduino for the receiver, since my laptop already has WinPython on it.

Will your Python library work under Windows?

Unable to run - AssertionError

I receiving this error while trying to run lora_util.py
/home/pi/2/pySX127x/SX127x/board_config.py:51: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(BOARD.LED, GPIO.OUT)
Traceback (most recent call last):
File "lora_util.py", line 35, in
lora = LoRa(verbose=False)
File "/home/pi/2/pySX127x/SX127x/LoRa.py", line 100, in init
self.rx_chain_calibration(calibration_freq)
File "/home/pi/2/pySX127x/SX127x/LoRa.py", line 856, in rx_chain_calibration
self.set_freq(freq_bkup)
File "/home/pi/2/pySX127x/SX127x/LoRa.py", line 282, in set_freq
assert self.mode == MODE.SLEEP or self.mode == MODE.STDBY or self.mode == MODE.FSK_STDBY
AssertionError

Microchip

"Microchip transceiver IC

Likewise Microchip has the chip RN2483"

Microchip only exposes an uart interface so SPI is going to be useless here I think.

Not able to transmit or receive data using "Socket_transceiver.py" with another lora connected with Arduino.

Hi,

I am new to loRa technology. I am trying to connect create a LoRa gateway using raspberry pi, which collects and sends the data to loRa node(Arduino& LoRa). I have tried your "socket_transceiver.py" program in raspberry pi.. and I am using the below code for arduino..

but i am not able to see the connection happening in between these two LoRa devices.

I am able to send the socket data using a client tool and raspberry pi able to receive that, but i am not able to confirm whether the raspberry pi transmitting the data via lora or not..

I have tried with connecting two raspberry pi nodes but i am not able to see the data transmission.

Please confirm any other settings/configurations needs to be done in raspberry pi side..

Transmitting lora in 434MHz.

Arduino code:

#include <SPI.h> // include libraries
#include <LoRa.h>

const int csPin = 7; // LoRa radio chip select
const int resetPin = 6; // LoRa radio reset
const int irqPin = 1; // change for your board; must be a hardware interrupt pin

String outgoing; // outgoing message

byte msgCount = 0; // count of outgoing messages
byte localAddress = 0xBB; // address of this device
byte destination = 0xFF; // destination to send to
long lastSendTime = 0; // last send time
int interval = 2000; // interval between sends

void setup() {
Serial.begin(9600); // initialize serial
while (!Serial);

Serial.println("LoRa Duplex");

// override the default CS, reset, and IRQ pins (optional)
LoRa.setPins(csPin, resetPin, irqPin);// set CS, reset, IRQ pin

if (!LoRa.begin(915E6)) { // initialize ratio at 915 MHz
Serial.println("LoRa init failed. Check your connections.");
while (true); // if failed, do nothing
}

Serial.println("LoRa init succeeded.");
}

void loop() {
if (millis() - lastSendTime > interval) {
String message = "HeLoRa World!"; // send a message
sendMessage(message);
Serial.println("Sending " + message);
lastSendTime = millis(); // timestamp the message
interval = random(2000) + 1000; // 2-3 seconds
}

// parse for a packet, and call onReceive with the result:
onReceive(LoRa.parsePacket());
}

void sendMessage(String outgoing) {
LoRa.beginPacket(); // start packet
LoRa.write(destination); // add destination address
LoRa.write(localAddress); // add sender address
LoRa.write(msgCount); // add message ID
LoRa.write(outgoing.length()); // add payload length
LoRa.print(outgoing); // add payload
LoRa.endPacket(); // finish packet and send it
msgCount++; // increment message ID
}

void onReceive(int packetSize) {
if (packetSize == 0) return; // if there's no packet, return

// read packet header bytes:
int recipient = LoRa.read(); // recipient address
byte sender = LoRa.read(); // sender address
byte incomingMsgId = LoRa.read(); // incoming msg ID
byte incomingLength = LoRa.read(); // incoming msg length

String incoming = "";

while (LoRa.available()) {
incoming += (char)LoRa.read();
}

if (incomingLength != incoming.length()) { // check length for error
Serial.println("error: message length does not match length");
return; // skip rest of function
}

// if the recipient isn't this device or broadcast,
if (recipient != localAddress && recipient != 0xFF) {
Serial.println("This message is not for me.");
return; // skip rest of function
}

// if message is for this device, or broadcast, print details:
Serial.println("Received from: 0x" + String(sender, HEX));
Serial.println("Sent to: 0x" + String(recipient, HEX));
Serial.println("Message ID: " + String(incomingMsgId));
Serial.println("Message length: " + String(incomingLength));
Serial.println("Message: " + incoming);
Serial.println("RSSI: " + String(LoRa.packetRssi()));
Serial.println("Snr: " + String(LoRa.packetSnr()));
Serial.println();
}

MAX_PAYLOAD_LENGTH typo

In constants.py clss REG class LORA both PAYLOAD_LENGTH and MAX_PAYLOAD_LENGTH are indicating register 0x22. I assume this is a typo, MAX PAYLOAD should refer to reg 0x23.

SX1301

Since the project is going to be named pyLora, are you going to make the project to work with SX1301?

I did try this with SX1301 using Multitech's Lora on Raspberry Pi but it did not work.

Send text

Hi,
I'm trying to communicate an arduino and a raspberry Pi through two RA-02 lora modules. I am using the RadioHead library in the Ardino and I'm trying to use this python library on the side of Raspberry Pi.
Communication between two arduinos works fine, the library on raspberry pi does not report errors, but the communication between arduino and raspberry pi just works by using the raspberry pi as receiver. Sending messages from the raspberry pi is not recollected by the arduino.
It looks like a coding problem used when the message is sent that is not collected by the RadioHead library and therefore discarded.
Is there a way to send a string, instead of the 0x0f byte sent in tx_beacon.py?
I have spent days around this code and have not yet come up with any solutions, any help is welcome.

sx1278 reciving problem

Hello,
I want to use sx1278 with raspberry pi 4 to receive data from Arduino with the same module. I don't get any message and when I run test_lora.py i get one test fails.

F.....
======================================================================
FAIL: test_mode (__main__.TestSX127x)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/pi/pySX127x/test_lora.py", line 43, in wrapper
    func(self)
  File "/home/pi/pySX127x/test_lora.py", line 62, in test_mode
    self.assertEqual(lora.get_mode(), m)
AssertionError: 128 != 129

----------------------------------------------------------------------
Ran 6 tests in 0.006s

FAILED (failures=1)

I don't really know with what i have problem. Can someone help me? Thank you in advance.

Burst in write_payload

When writing multiple bytes in burst mode; for example 'Hello'

write_payload([0x48, 0x65, 0x6c, 0x6c, 0x6f])

get_rx_nb_bytes only returns one byte in FIFO memory (of the receiver)

I'm not sure where the problem is? Because the datasheet says burst mode is supported

update: I read out the FIFO memory (sender) and the data is contained in the FIFO so it is not an SPI problem.

Dio3 mapping error

Hi,
Could help me with problem on the Jetson Nano dev kit?
We are trying use sx127x to send some information from Jetson nano and use it's app. SX is connected to Jetson correctly, but after start has a proble "dio3 mapping error" or "acceleration error". We've checked all wire, configs and etc, but don't understand why isn't work. SPI works.
If sx127x connected to Jetson Xavier, app work perfectly.

/usr/lib/python3/dist-packages/Jetson/GPIO/gpio.py:411: RuntimeWarning: No channels have been set up yet - nothing to clean up! Try cleaning up at the end of your program instead! "program instead!", RuntimeWarning) Config SPI Setup GPIO++++ Borad conf is: 11 /usr/lib/python3/dist-packages/Jetson/GPIO/gpio.py:386: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings RuntimeWarning) timer start add_event SLEEP = 1 == 128, STDBY = 1 == 129, FSK_STDBY = 1 == 1, SLEEP = 0 == 128, STDBY = 0 == 129, FSK_STDBY = 0 == 1, Unhandled exception in thread started by <function _poll_thread at 0x7fa7dfa598> Traceback (most recent call last): File "otaa_ttn.py", line 211, in <module> lora = LoraWanAllinOne(False) File "otaa_ttn.py", line 26, in __init__ Traceback (most recent call last): File "/usr/lib/python3/dist-packages/Jetson/GPIO/gpio_event.py", line 238, in _poll_thread super(LoraWanAllinOne, self).__init__(verbose, do_calibration) File "/home/nvidia/lorawan_rpi/SX127x/LoRa.py", line 101, in __init__ cb_func() File "/usr/lib/python3/dist-packages/Jetson/GPIO/gpio.py", line 531, in <lambda> self.rx_chain_calibration(calibration_freq) File "/home/nvidia/lorawan_rpi/SX127x/LoRa.py", line 858, in rx_chain_calibration event.add_edge_callback(ch_info.gpio, lambda: callback(channel)) self.set_freq(freq_bkup) File "/home/nvidia/lorawan_rpi/SX127x/LoRa.py", line 196, in _dio3 File "/home/nvidia/lorawan_rpi/SX127x/LoRa.py", line 284, in set_freq raise RuntimeError("unknown dio3 mapping!") RuntimeError: unknown dio3 mapping! assert self.mode == MODE.SLEEP or self.mode == MODE.STDBY or self.mode == MODE.FSK_STDBY AssertionError

test passed
`
nvidia@nvidia-desktop:~/lorawan_rpi$ sudo python3 test.py
[sudo] password for nvidia:
/usr/lib/python3/dist-packages/Jetson/GPIO/gpio.py:411: RuntimeWarning: No channels have been set up yet - nothing to clean up! Try cleaning up at the end of your program instead!
"program instead!", RuntimeWarning)
Config SPI
Setup GPIO++++
Borad conf is: 11
/usr/lib/python3/dist-packages/Jetson/GPIO/gpio.py:386: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings
RuntimeWarning)
timer start
add_event
...SLEEP = 128 == 128, STDBY = 128 == 129, FSK_STDBY = 128 == 1,
SLEEP = 128 == 128, STDBY = 128 == 129, FSK_STDBY = 128 == 1,
SLEEP = 128 == 128, STDBY = 128 == 129, FSK_STDBY = 128 == 1,
SLEEP = 128 == 128, STDBY = 128 == 129, FSK_STDBY = 128 == 1,
...

Ran 6 tests in 0.011s

OK
`

Porting to BeagleBoneBlack

Hi,

Attempted to run this library on the BeagleBoneBlack. Would it require a lot of work or could you point me in the direction of a project that could run on the BBB instead?

Use with Dragino Lora GPS Hat

Hi,

I'm trying to use the library with a Dragino Lora GPS Hat v1.4 board on a RPi3, with no luck so far (assertion error in set_freq during calibration). Has anyone successfully used this board? With what settings?

Thanks,
Viktor

rssi value calculation

Rssi is currently calculated as

return v - 157

which is correct for High Frequency only
See "5.5.5. RSSI and SNR in LoRa TM Mode" (page 87)

RSSI (dBm) = -157 + Rssi, (when using the High Frequency (HF) port)
or
RSSI (dBm) = -164 + Rssi, (when using the Low Frequency (LF) port)

Set timeout

Hi, I want to make a program that waits for a message and if it doesn't listen anything then do a diferent routine, the problem is that I don't know how to use the timeout_rx function, how can I set it up?

Thanks in regards

AssertionError: lora.get_agc_auto_on() == 1

I am running this with a Ra-02, this is the output.
While I'm using the rpsreal fork, but that fork doesn't have an Issues section enabled, which is why I'm opening the issue here.
image

AssertionError running lora_util.py

Hi,
I am receiving the following after following the 'Installation' section and running 'sudo ./lora_util.py'

/home/pi/projects/pySX127x/SX127x/board_config.py:51: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(BOARD.LED, GPIO.OUT)
Traceback (most recent call last):
File "./lora_util.py", line 35, in
lora = LoRa(verbose=False)
File "/home/pi/projects/pySX127x/SX127x/LoRa.py", line 92, in init
self.rx_chain_calibration(968.)
File "/home/pi/projects/pySX127x/SX127x/LoRa.py", line 835, in rx_chain_calibration
self.set_freq(freq_bkup)
File "/home/pi/projects/pySX127x/SX127x/LoRa.py", line 271, in set_freq
assert self.mode == MODE.SLEEP or self.mode == MODE.STDBY or self.mode == MODE.FSK_STDBY
AssertionError

I have followed the wiring table provided as well as connected the SPI pins from the RPI2 to the LoRa module.

I am running this on a Raspberry Pi 2 Model B with the latest RASPBIAN JESSIE and a InAir4 433Mhz LoRa module.

Could it have something to do with setting the freq to 868 in LoRa.py line 807 when I am using a 433Mhz?

Please let me know if can provide any more information.

Thanks

Converting the payload or data to Float

Is that possible to convert the payload received in the Raspberry Pi to Float, Int, or String if yes how to do it? Could you please give me some idea how to do it. Thank you very much.

overhead class with little different

Hi is there a reason of separating LoRa and LoRa2, BOARD with BOARD2

I check the class it only use different configuration ( pin ,etc ).
All the function is exactly the same.

It should be easy to make it more compact and more object oriented.

Instead of create BOARD outside of class, we could pass it to the LoRa class as variable.
The BOARD also can be created using configuration parameters.

LoraWan

I have a SX127x module (http://modtronix.com/inair9B.html) and trying to connect to the lorawan network.

what parts of the lorawan communication is handled by this module? In the LoRaWan specification I see the Radio PHY layer, PHYPayload layer, MACPayload layer and FHDR. What part am I sending with the write_payload command?

SX128x compatibility ?

Hi everyone,

I'm trying to work on the SX1280 with python for a prototype, do you think this interface can be compatible or could it be a good base for a python interface ?

If you have info on an existing project trying to achieve that, that would be very helpful, because I can't find anything !

Thanks for your help

Having trouble with HopeRF RFM95W

This is the error received when attempting to run test_lora.py

I'm using a raspberry pi zero, and have the pins as described, with 3v3 -> 3.3v, all the GNDs going to separate GNDs on the Pi, SCLK -> CLK and CE0 -> NSS.

/home/pi/pySX127x/SX127x/board_config.py:51: RuntimeWarning: This channel is already in use, continuing anyway.  Use GPIO.setwarnings(False) to disable warnings.
  GPIO.setup(BOARD.LED, GPIO.OUT)
Traceback (most recent call last):
  File "./lora_util.py", line 35, in <module>
    lora = LoRa(verbose=False)
  File "/home/pi/pySX127x/SX127x/LoRa.py", line 100, in __init__
    self.rx_chain_calibration(calibration_freq)
  File "/home/pi/pySX127x/SX127x/LoRa.py", line 843, in rx_chain_calibration
    self.set_freq(freq_bkup)
  File "/home/pi/pySX127x/SX127x/LoRa.py", line 279, in set_freq
    assert self.mode == MODE.SLEEP or self.mode == MODE.STDBY or self.mode == MODE.FSK_STDBY
AssertionError

build folder

am working with this code on ORANGE PI .
I have problems with RPI.GPIO
and I think that I need a build folder to continue.
any ideas ??

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.