Code Monkey home page Code Monkey logo

loranow's Introduction

LoRaNow

LoRaNow is a open source communication protocol to make easier to understand the concept of Node / Gateway communication using LoRa technology.

This library was design using the Arduino LoRa Library by Sandeep Mistry.

Features

  • Hardware Compatibility - Compatible with Arduino and ESP boards with a LoRa module attached.
  • Id - Each node has an identification, by default the library creates a unique id for the node.
  • Checksum - Each payload has a checksum to verify if the data is corrupted.
  • State Machine - The library has a state machine algorithm to manage the LoRa module, open an RX window after sending data and put the module to sleep.

Compatible Hardware

The main focus hardware is Arduino and ESP boards with RFM95W LoRa module.

RFM95W

The default pinout connection is like the table below.

RFM95W Arduino ESP8266 ESP32
VCC 3.3V 3.3V 3.3V
GND GND GND GND
SCK SCK SCK SCK
MISO MISO MISO MISO
MOSI MOSI MOSI MOSI
SS 10 gpio16 gpio18
DIO0 2 gpio15 gpio26

SS, and DIO0 pins can be changed by using LoRaNow.setPins(ss, dio0) or LoRaNow.setPinsSPI(sck, miso, mosi, ss, dio0). DIO0 pin is needed, it must be interrupt capable via attachInterrupt(...).

Ferquency

You can use this table to lookup the available frequencies by your country. The selectable frequency also depends on your hardware.

You can select the frequency using LoRaNow.setFrequency(frequency) or you can select the frequency by country.

  • LoRaNow.setFrequencyCN() - Select the frequency 486.5 MHz - Used in China
  • LoRaNow.setFrequencyEU() - Select the frequency 868.3 MHz - Used in Europe
  • LoRaNow.setFrequencyUS() - Select the frequency 904.1 MHz - Used in USA, Canada and South America
  • LoRaNow.setFrequencyAU() - Select the frequency 917.0 MHz - Used in Australia, Brazil and Chile

Protocol Payload

This is the payload format, this protocol don't have any kind of encryption.

Protocol Device ID Count Length CheckSum Payload
1 Byte 4 Bytes 1 Byte 1 Byte 1 Byte N Bytes

Installation

Examples

The library comes with examples. After installing the library you need to restart the Arduino IDE before they can be found under File > Examples > LoRaNow.

API

See API.md.

License

This library is licensed under the MIT Licence.

To do

  • Example for ESP8266 board
  • Example for ESP32 board
  • Improve documentation
  • State machine

See news and other projects on my blog

Do you like this library? Please star this project on GitHub!

loranow's People

Contributors

agmuntianu avatar per1234 avatar ricaun 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

loranow's Issues

ttgo lora 32 got problems

i just set LoRa.setPins(18, 26); // set CS, reset, IRQ pin

.
Connected to sungerbob
IP address: 192.168.0.25
HTTP server started
LoRa init failed. Check your connections.

Problem AutoReset ESP32 Gateway - ESP32 Version 1.0.2

For some reason, the new version of the ESP32 board 1.0.2 makes the gateway to reset when the gateway sends a message from the onMessage callback.

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x4008161a PS : 0x00050031 A0 : 0x800d1021 A1 : 0x3ffbe7c0
A2 : 0x00000040 A3 : 0x00018040 A4 : 0x000637ff A5 : 0x3ffbe7a0
A6 : 0x00000000 A7 : 0x3ffbfe5c A8 : 0x00000000 A9 : 0x04000000
A10 : 0x00000001 A11 : 0x00000000 A12 : 0x80080e7c A13 : 0x3ffbe780
A14 : 0x00000000 A15 : 0x3ffb0060 SAR : 0x0000000e EXCCAUSE: 0x0000001c
EXCVADDR: 0x800d102d LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff
Core 1 was running in ISR context:
EPC1 : 0x4008161a EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x40082835

Backtrace: 0x4008161a:0x3ffbe7c0 0x400d101e:0x3ffb1f90 0x400d2ae9:0x3ffb1fb0 0x40087911:0x3ffb1fd0

Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:928
ho 0 tail 12 room 4
load:0x40078000,len:8424
ho 0 tail 12 room 4
load:0x40080400,len:5868
entry 0x4008069c
LoRaNow Simple Gateway

If you have the same problem you can downgrade the version to 1.0.1, for some reason the new version cause the board to reset.

This is a temporary solution until I discover what's going on.

Feature request: ProbeRequest protocol

Thank you for your LoRaNow Code. I have been trying to implement low power network devices without using rather expensive Lora modules. I think lora devices are the only low power solution for long range communication but if you need small range of few meters like home environment my code is suitable without complexity of extra lora hardware. Please look at my code and see if you an add it as an option to your code. Code is below :

https://github.com/happytm/BatteryNode

Thanks.

ESP32 Gateway crashes on onDio0Rise

I'm getting messages over LoRa and sending to HTTPS server over WiFi.
All works except once in a few hours (quite randomly) board crashes. I tried with ESP32 v 1.0.2 and 1.0.3.

I suspect that issue is with interrupt not having ICACHE_RAM_ATTR as it is needed for ESP32. Simply adding it won't help as per ESP doc: "Not only that, but the entire function tree called from the ISR must also have the ICACHE_RAM_ATTR declared."
So all functionality from interrupt should be moved to the main Loop?!?

As Gateway I'm using Heltec ESP32 - Heltec WiFi Lora 32(v2).
Top of stack almost always is:

Decoding stack results
0x401624e6: spiGetClockDiv at /Users/aaa/Library/Arduino15/packages/esp32/hardware/esp32/1.0.3-rc1/cores/esp32/esp32-hal-spi.c line 291
0x400d543f: SPIClass::beginTransaction(SPISettings) at /Users/aaa/Library/Arduino15/packages/esp32/hardware/esp32/1.0.3-rc1/libraries/SPI/src/SPI.cpp line 130
0x400d4b30: LoRaClass::singleTransfer(unsigned char, unsigned char) at /Users/aaa/Documents/ArduinoESP32/libraries/LoRaNow/src/utility/LoRa.cpp line 755
0x400d4b64: LoRaClass::readRegister(unsigned char) at /Users/aaa/Documents/ArduinoESP32/libraries/LoRaNow/src/utility/LoRa.cpp line 741
0x400d4ba5: LoRaClass::available() at /Users/aaa/Documents/ArduinoESP32/libraries/LoRaNow/src/utility/LoRa.cpp line 356
0x400d4a02: LoRaNowClass::onReceive(int) at /Users/aaa/Documents/ArduinoESP32/libraries/LoRaNow/src/LoRaNow.cpp line 585
0x400d5282: LoRaClass::handleDio0Rise() at /Users/aaa/Documents/ArduinoESP32/libraries/LoRaNow/src/utility/LoRa.cpp line 724
0x400d52a6: LoRaClass::onDio0Rise() at /Users/aaa/Documents/ArduinoESP32/libraries/LoRaNow/src/utility/LoRa.cpp line 767
0x40080f81: __onPinInterrupt at /Users/aaa/Library/Arduino15/packages/esp32/hardware/esp32/1.0.3-rc1/cores/esp32/esp32-hal-gpio.c line 220
...

SF dont Work after power reboot.

Heii

Nice library :)

If I set SF to something else like 7, then the gateway forgets it, as soon as you take the power from the device (tested on esp32 + esp8266) after the power reconnect, It start to receive on SF 7 again..? It works fine on the Node. here it holds the SF after a power cycle.
Any idears?

I have try to reset the ESP 100%.
Try SF 8, 9, 10, 11 and 12 - same behavier.
Try to chance the default SF in the library - same behavier.

ESP8266 crash "ISR not in IRAM"

With Arduino 1.8.10, ESP8266 library v2.62, ESP12 module,
serial monitor reports
"ISR not in IRAM"

See
esp8266/Arduino#6127
in particular,
esp8266/Arduino#6127 (comment)
and the two comments that follow that, where they specifically cite LoRa.cpp, including:
"Is that code doing an spi transaction from an ISR???
There are strict timing requirements on the exec time of an ISR in the ESP.
Blocking operations are a big no no, and in general ISRs shouldn't take more than a few us.
At a glance, I don't think that code will work, at least not with wifi running.
I would advise an ESP user to set a flag in the ISR and execute from the loop,
or use the scheduled function api (runs a cb as though it were in the loop)."

Additionally, I see that a LoRa.cpp file is contained inside the LoRaNow src directory.
Perhaps this is some prior version of SandeepMistry's code.
Perhaps this library be included rather than copied?
If it was included, the current version has a macro to define ISR_PREFIX as ICACHE_RAM_ATTR
but doesn't really address the fundamental points in the comments cited above.

This is related to
#6

Lora Nodes communication without using internet

First of all i would like to thank you for all your studies.
I want to make the lora nodes network(more than 5 nodes) those have their id and communicate with each other without using internet. I am using just LoRa Ra-02 SX1278 433 Mhz modules and Arduino Unos .Could you help me?

ESP.DeepSleep() issue on ESP8266

Hi team,

Have anyone tested this library with ESP.deepSleep(20e6, WAKE_RF_DISABLED) on the node?
It is for whatever reason stopping the node to send the message to the gateway.
I appreciate if anyone has same problem and how to resolve it.

Thanks,
T

Not receive messages in gateway mode

Hi,
I tried the gateway example together with the node example with two esp32 + RFM95 at 868 Mhz. The node is working fine, but the esp gateway is not receiving any messages. All parameters are the same (SF, Freq, ...).
I changed the gateway source as follows:
`LoRaNow.send (); //added

LoRaNow.onMessage (onMessage);

LoRaNow.gateway (); `

and it works correctly. The gateway function appears to not initialize the hardware correctly.

Thanks.
Maurizio

LoraNow Nodes downlink?

Hello,

Would it be possible to send a message to the node taking advantage of the ack message that the gateway returns?

I wish I could establish downlink messages from the cloud. The idea would be to glue the messages on the gateway and be able to send them to the correct node id when it queries the gateway. Is this viable?

Possibility to set the TxPower

I wanted to have the possibility to set the TxPower of my sensors so nearby nodes can be set to a lower power to save the batteries. I changed in my local copy of LoRaNow the following to add this (the sf was already in the lib, but I set it in the text for orientation):

LoRaNow.h:
#define LORANOW_DEFAULT_SF 7
#define LORANOW_DEFAULT_POWER 10

class LoRaNowClass : public Stream
{
private:
uint8_t sf = LORANOW_DEFAULT_SF;
uint8_t txpower = LORANOW_DEFAULT_POWER;

void setSpreadingFactor(int _sf);
void setTxPower(uint8_t _power );

LoRaNow.cpp:
void LoRaNowClass::setSpreadingFactor(int _sf)
{
sf = _sf;
}

void LoRaNowClass::setTxPower(uint8_t _power )
{
txpower = _power;
}

void LoRaNowClass::txMode()
{
LORANOW_DEBUG_PRINT(millis());LORANOW_DEBUG_PRINTLN("[ln] txMode");
LoRa.idle();
LoRa.setFrequency(frequency);
LoRa.setSpreadingFactor(sf);
LoRa.setTxPower(txpower);

==
Maybe this addition is also handy for other users.

Gateway não recebe dados

Olá,

Estou usando os exemplos de node e gateway, mas não esta funcionando, o gateway não recebe os pacotes de dados.

Finallyyy...

i been really really serching beautiful library.. and you got you bro..

please do not support this baby..

thanks :)

Is LoRaNow.loop() necessary during sleeping

Dear Ricaun,

I am learning to use your library.
I have a question about the LoRaNow.loop() method and the State Machine.
Can I sleep de uC in the onSleep callback for a long time (i.e. 15 minutes) without calling LoRaNow.loop()?

Besides I found this small typo in the API.
imagen
Kind regards from Madrid

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.