Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… main
  • Loading branch information
SylvainMontagny committed May 15, 2024
2 parents 52a9d94 + aa4dbda commit ef8a4e0
Show file tree
Hide file tree
Showing 12 changed files with 418 additions and 159 deletions.
20 changes: 17 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,23 @@


## Knows limitation
- Tested on "EU868" & "US915".
- Tested compatibility only with "Leonardo" and "Zero" Arduino boards.
- "LoRaWAN modem is busy" message may occurs for Class C/ABP.
* Tested on "EU868" & "US915".
* Tested compatibility only with:
1. "Leonardo", "Zero" and "Due" Arduino boards,
2. "ESP32_DevKitc_V4" Espressif board,
3. "F446RE" and "L073RZ" Nucleo boards,
4. "Wio Terminal" Seeed board,
* "LoRaWAN modem is busy" message may occurs for Class C/ABP.

## Version: V3.0.0 | 2024-05-14

### Added
- A “config_board.h” header to manage several defined boards and allow you to choose the serial configuration for the others.
- Implement a setup_hardware() method.

### Modified
- "USB_Serial" has been replaced by "Debug_Serial".
- Renamed setup() method to setup_lorawan().


## Version: V2.0.0 | 2024-04-22
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,22 @@ This library has only been tested with an **Arduino Leonardo** and an **Arduino

## 2.2. Arduino Hardware

This library works with any Arduino boards with two serial ports (or one USB + one Serial). It has been tested on an Arduino **Leonardo & Zero** boards with:
- USB_Serial: Connection to computer: 115200 baud.
This library works with any Arduino boards with two serial ports (or one USB + one Serial). It has been tested on an Arduino **Leonardo, Zero & Due** boards with:
- Debug_Serial: Connection to computer: 115200 baud.
- LoRa_Serial: Serial link for the communication between the Arduino MCU and the LoRa-E5 LoRaWAN module.

Your LoRa-E5 module need to be connected to the RX-TX arduino header pin.

It also works with :
- Espressif "ESP32_DevKitc_V4" board,
- Nucleo "F446RE" and "L073RZ" boards,
- Seeed "Wio Terminal" board,


## 2.3. How to use this library

- Set up the parameters in **config_application.h** file. If you use ABP, you need to configure devAdddr, nwkSKey and appSKey. If you use OTAA you need to configure devEUI, appEUI and appKey.
- Set up the LoRaWAN parameters in **config_application.h** file. If you use ABP, you need to configure devAdddr, nwkSKey and appSKey. If you use OTAA you need to configure devEUI, appEUI and appKey.
- Set up the hardware parameters in **config_board.h** file. Choose the right setting for your board (Serial or Pins).
- Set up your Gateway or use a public coverage.
- Register your Device on a Network Server (TTN, Actility, LORIOT, ...)
- Open the Serial Monitor in the arduino IDE to see the logs. :warning: 115200 baud.
Expand All @@ -64,5 +70,4 @@ Your LoRa-E5 module need to be connected to the RX-TX arduino header pin.

## 2.5. Best practices

- It is recommended to opt for OTAA over ABP for the Activation Mode.

- It is recommended to opt for OTAA over ABP for the Activation Mode.
6 changes: 4 additions & 2 deletions examples/LoRaWAN_Class_A/LoRaWAN_Class_A.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <Arduino.h>
#include "lorae5.h"
#include "config_application.h"
#include "config_board.h"

uint8_t sizePayloadUp = 4;
uint8_t sizePayloadDown = 0;
Expand All @@ -15,11 +16,12 @@ LORAE5 lorae5(devEUI, appEUI, appKey, devAddr, nwkSKey, appSKey);
/***********************************************************************/

void setup() {
lorae5.setup(REGION, ACTIVATION_MODE, CLASS, SPREADING_FACTOR, ADAPTIVE_DR, CONFIRMED, PORT_UP, SEND_BY_PUSH_BUTTON, FRAME_DELAY);
lorae5.setup_hardware(&Debug_Serial, &LoRa_Serial);
lorae5.setup_lorawan(REGION, ACTIVATION_MODE, CLASS, SPREADING_FACTOR, ADAPTIVE_DR, CONFIRMED, PORT_UP, SEND_BY_PUSH_BUTTON, FRAME_DELAY);
lorae5.printInfo();

if(ACTIVATION_MODE == OTAA){
USB_Serial.println("Join Procedure in progress...");
Debug_Serial.println("Join Procedure in progress...");
while(lorae5.join() == false);
delay(2000);
}
Expand Down
42 changes: 42 additions & 0 deletions examples/LoRaWAN_Class_A/config_board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef CONFIG_BOARD_H
#define CONFIG_BOARD_H

//////////////////////////////////////////////
// If you use an ARDUINO or ESP32 board
//////////////////////////////////////////////
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_WIO_TERMINAL)
#define Debug_Serial Serial // Select the right SerialX for Debug

// Arduino's Serial Documentation : https://www.arduino.cc/reference/en/language/functions/communication/serial/
// ESP32 Documentation
#define LoRa_Serial Serial1 // Select the right SerialX for the LoRaE5 connection

//////////////////////////////////////////////
// If you use a STM32 NUCLEO board
//////////////////////////////////////////////
#elif defined(ARDUINO_ARCH_STM32)
#define RX_PIN_DEBUG PA3 // Select UART RX Pin for Debug
#define TX_PIN_DEBUG PA2 // Select UART TX Pin for Debug
HardwareSerial Debug_Serial(RX_PIN_DEBUG, TX_PIN_DEBUG);

#define RX_PIN_LORA PA1 // Select UART RX Pin for the LoRaE5 connection
#define TX_PIN_LORA PA0 // Select UART TX Pin for the LoRaE5 connection
HardwareSerial LoRa_Serial(RX_PIN_LORA, TX_PIN_LORA);


//////////////////////////////////////////////
// /!\ Your card has never been tested yet !
// Please let us know if you find the PIN configuration of your board
// So we can add it to the next version of this code
//////////////////////////////////////////////

#else
#warning "Your board has never been tested with this lib"
#warning "Select the right Serial for Debug and LoRaE5 connection in config_board.h"

#define Debug_Serial Serial
#define LoRa_Serial Serial1

#endif

#endif //CONFIG_BOARD_H
8 changes: 5 additions & 3 deletions examples/LoRaWAN_Class_C/LoRaWAN_Class_C.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <Arduino.h>
#include "lorae5.h"
#include "config_application.h"
#include "config_board.h"

uint8_t sizePayloadUp = 4;
uint8_t sizePayloadDown = 0;
Expand All @@ -15,11 +16,12 @@ LORAE5 lorae5(devEUI, appEUI, appKey, devAddr, nwkSKey, appSKey);
/***********************************************************************/

void setup() {
lorae5.setup(REGION, ACTIVATION_MODE, CLASS, SPREADING_FACTOR, ADAPTIVE_DR, CONFIRMED, PORT_UP, SEND_BY_PUSH_BUTTON, FRAME_DELAY);
lorae5.setup_hardware(&Debug_Serial, &LoRa_Serial);
lorae5.setup_lorawan(REGION, ACTIVATION_MODE, CLASS, SPREADING_FACTOR, ADAPTIVE_DR, CONFIRMED, PORT_UP, SEND_BY_PUSH_BUTTON, FRAME_DELAY);
lorae5.printInfo();

if(ACTIVATION_MODE == OTAA){
USB_Serial.println("Join Procedure in progress...");
Debug_Serial.println("Join Procedure in progress...");
while(lorae5.join() == false);
delay(2000);
}
Expand All @@ -42,4 +44,4 @@ void loop() {

void processDownlink() {
// You have received "sizePayloadDown" bytes stored in the table "payloadDown"
}
}
42 changes: 42 additions & 0 deletions examples/LoRaWAN_Class_C/config_board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef CONFIG_BOARD_H
#define CONFIG_BOARD_H

//////////////////////////////////////////////
// If you use an ARDUINO or ESP32 board
//////////////////////////////////////////////
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_WIO_TERMINAL)
#define Debug_Serial Serial // Select the right SerialX for Debug

// Arduino's Serial Documentation : https://www.arduino.cc/reference/en/language/functions/communication/serial/
// ESP32 Documentation
#define LoRa_Serial Serial1 // Select the right SerialX for the LoRaE5 connection

//////////////////////////////////////////////
// If you use a STM32 NUCLEO board
//////////////////////////////////////////////
#elif defined(ARDUINO_ARCH_STM32)
#define RX_PIN_DEBUG PA3 // Select UART RX Pin for Debug
#define TX_PIN_DEBUG PA2 // Select UART TX Pin for Debug
HardwareSerial Debug_Serial(RX_PIN_DEBUG, TX_PIN_DEBUG);

#define RX_PIN_LORA PA1 // Select UART RX Pin for the LoRaE5 connection
#define TX_PIN_LORA PA0 // Select UART TX Pin for the LoRaE5 connection
HardwareSerial LoRa_Serial(RX_PIN_LORA, TX_PIN_LORA);


//////////////////////////////////////////////
// /!\ Your card has never been tested yet !
// Please let us know if you find the PIN configuration of your board
// So we can add it to the next version of this code
//////////////////////////////////////////////

#else
#warning "Your board has never been tested with this lib"
#warning "Select the right Serial for Debug and LoRaE5 connection in config_board.h"

#define Debug_Serial Serial
#define LoRa_Serial Serial1

#endif

#endif //CONFIG_BOARD_H
6 changes: 4 additions & 2 deletions examples/LoRaWAN_State-Machine/LoRaWAN_State-Machine.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <Arduino.h>
#include "lorae5.h"
#include "config_application.h"
#include "config_board.h"

uint8_t sizePayloadUp = 4;
uint8_t sizePayloadDown = 0;
Expand All @@ -21,11 +22,12 @@ State currentState = State::SEND_DATA;
/***********************************************************************/

void setup() {
lorae5.setup(REGION, ACTIVATION_MODE, CLASS, SPREADING_FACTOR, ADAPTIVE_DR, CONFIRMED, PORT_UP, SEND_BY_PUSH_BUTTON, FRAME_DELAY);
lorae5.setup_hardware(&Debug_Serial, &LoRa_Serial);
lorae5.setup_lorawan(REGION, ACTIVATION_MODE, CLASS, SPREADING_FACTOR, ADAPTIVE_DR, CONFIRMED, PORT_UP, SEND_BY_PUSH_BUTTON, FRAME_DELAY);
lorae5.printInfo();

if(ACTIVATION_MODE == OTAA){
USB_Serial.println("Join Procedure in progress...");
Debug_Serial.println("Join Procedure in progress...");
while(lorae5.join() == false);
delay(2000);
}
Expand Down
42 changes: 42 additions & 0 deletions examples/LoRaWAN_State-Machine/config_board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef CONFIG_BOARD_H
#define CONFIG_BOARD_H

//////////////////////////////////////////////
// If you use an ARDUINO or ESP32 board
//////////////////////////////////////////////
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_WIO_TERMINAL)
#define Debug_Serial Serial // Select the right SerialX for Debug

// Arduino's Serial Documentation : https://www.arduino.cc/reference/en/language/functions/communication/serial/
// ESP32 Documentation
#define LoRa_Serial Serial1 // Select the right SerialX for the LoRaE5 connection

//////////////////////////////////////////////
// If you use a STM32 NUCLEO board
//////////////////////////////////////////////
#elif defined(ARDUINO_ARCH_STM32)
#define RX_PIN_DEBUG PA3 // Select UART RX Pin for Debug
#define TX_PIN_DEBUG PA2 // Select UART TX Pin for Debug
HardwareSerial Debug_Serial(RX_PIN_DEBUG, TX_PIN_DEBUG);

#define RX_PIN_LORA PA1 // Select UART RX Pin for the LoRaE5 connection
#define TX_PIN_LORA PA0 // Select UART TX Pin for the LoRaE5 connection
HardwareSerial LoRa_Serial(RX_PIN_LORA, TX_PIN_LORA);


//////////////////////////////////////////////
// /!\ Your card has never been tested yet !
// Please let us know if you find the PIN configuration of your board
// So we can add it to the next version of this code
//////////////////////////////////////////////

#else
#warning "Your board has never been tested with this lib"
#warning "Select the right Serial for Debug and LoRaE5 connection in config_board.h"

#define Debug_Serial Serial
#define LoRa_Serial Serial1

#endif

#endif //CONFIG_BOARD_H
6 changes: 4 additions & 2 deletions examples/MLR003-simulation/MLR003-simulation.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <Arduino.h>
#include "lorae5.h"
#include "config_application.h"
#include "config_board.h"

uint8_t sizePayloadUp = 2;
uint8_t sizePayloadDown = 0;
Expand All @@ -18,11 +19,12 @@ LORAE5 lorae5(devEUI, appEUI, appKey, devAddr, nwkSKey, appSKey);
/***********************************************************************/

void setup() {
lorae5.setup(REGION, ACTIVATION_MODE, CLASS, SPREADING_FACTOR, ADAPTIVE_DR, CONFIRMED, PORT_UP, SEND_BY_PUSH_BUTTON, FRAME_DELAY);
lorae5.setup_hardware(&Debug_Serial, &LoRa_Serial);
lorae5.setup_lorawan(REGION, ACTIVATION_MODE, CLASS, SPREADING_FACTOR, ADAPTIVE_DR, CONFIRMED, PORT_UP, SEND_BY_PUSH_BUTTON, FRAME_DELAY);
lorae5.printInfo();

if(ACTIVATION_MODE == OTAA){
USB_Serial.println("Join Procedure in progress...");
Debug_Serial.println("Join Procedure in progress...");
while(lorae5.join() == false);
delay(2000);
}
Expand Down
42 changes: 42 additions & 0 deletions examples/MLR003-simulation/config_board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef CONFIG_BOARD_H
#define CONFIG_BOARD_H

//////////////////////////////////////////////
// If you use an ARDUINO or ESP32 board
//////////////////////////////////////////////
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_WIO_TERMINAL)
#define Debug_Serial Serial // Select the right SerialX for Debug

// Arduino's Serial Documentation : https://www.arduino.cc/reference/en/language/functions/communication/serial/
// ESP32 Documentation
#define LoRa_Serial Serial1 // Select the right SerialX for the LoRaE5 connection

//////////////////////////////////////////////
// If you use a STM32 NUCLEO board
//////////////////////////////////////////////
#elif defined(ARDUINO_ARCH_STM32)
#define RX_PIN_DEBUG PA3 // Select UART RX Pin for Debug
#define TX_PIN_DEBUG PA2 // Select UART TX Pin for Debug
HardwareSerial Debug_Serial(RX_PIN_DEBUG, TX_PIN_DEBUG);

#define RX_PIN_LORA PA1 // Select UART RX Pin for the LoRaE5 connection
#define TX_PIN_LORA PA0 // Select UART TX Pin for the LoRaE5 connection
HardwareSerial LoRa_Serial(RX_PIN_LORA, TX_PIN_LORA);


//////////////////////////////////////////////
// /!\ Your card has never been tested yet !
// Please let us know if you find the PIN configuration of your board
// So we can add it to the next version of this code
//////////////////////////////////////////////

#else
#warning "Your board has never been tested with this lib"
#warning "Select the right Serial for Debug and LoRaE5 connection in config_board.h"

#define Debug_Serial Serial
#define LoRa_Serial Serial1

#endif

#endif //CONFIG_BOARD_H
Loading

0 comments on commit ef8a4e0

Please sign in to comment.