Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: HelTecAutomation/ESP32_LoRaWAN
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: V2.1.1
Choose a base ref
...
head repository: HelTecAutomation/ESP32_LoRaWAN
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Dec 1, 2020

  1. Update readme.md

    Heltec-Aaron-Lee committed Dec 1, 2020
    Copy the full SHA
    146a48d View commit details

Commits on Dec 17, 2020

  1. Copy the full SHA
    e68c468 View commit details
  2. Copy the full SHA
    21aa208 View commit details

Commits on Dec 28, 2020

  1. Copy the full SHA
    8259bc2 View commit details

Commits on Jan 9, 2021

  1. Add HDC1080 sensor LoRaWAN example

    Aaron Lee authored and Aaron Lee committed Jan 9, 2021
    Copy the full SHA
    edfa9de View commit details
  2. Copy the full SHA
    6367df0 View commit details

Commits on Apr 22, 2021

  1. Copy the full SHA
    01dac91 View commit details
  2. Copy the full SHA
    5010d1c View commit details
  3. Copy the full SHA
    274ab9d View commit details

Commits on May 19, 2021

  1. Copy the full SHA
    b5fc882 View commit details

Commits on May 20, 2021

  1. Copy the full SHA
    a9182c8 View commit details
  2. updated factory test

    Heltec-Aaron-Lee committed May 20, 2021
    Copy the full SHA
    2141705 View commit details
  3. updated factory test

    Heltec-Aaron-Lee committed May 20, 2021
    Copy the full SHA
    b0521ee View commit details

Commits on May 21, 2021

  1. Copy the full SHA
    2b11cac View commit details

Commits on Jun 19, 2021

  1. Add chipID to generate DEV_EUI.

    Add chipID to generate DEV_EUI.
    Quency-D committed Jun 19, 2021
    Copy the full SHA
    7104eaa View commit details

Commits on Jun 21, 2021

  1. Merge pull request #63 from Quency-D/master

    Add chipID to generate DEV_EUI.
    Heltec-Aaron-Lee authored Jun 21, 2021
    Copy the full SHA
    2aebe43 View commit details

Commits on Aug 12, 2021

  1. fixed rx packet snr

    Heltec-Aaron-Lee committed Aug 12, 2021
    Copy the full SHA
    5214355 View commit details

Commits on Aug 13, 2021

  1. Update OTAA.ino

    ohioh authored Aug 13, 2021
    Copy the full SHA
    b3a4d2c View commit details

Commits on Aug 18, 2021

  1. Copy the full SHA
    7f4d725 View commit details

Commits on Aug 19, 2021

  1. add LA915

    add LA915
    Quency-D committed Aug 19, 2021
    Copy the full SHA
    a350599 View commit details
  2. Merge pull request #66 from Quency-D/master

    add LA915
    Quency-D authored Aug 19, 2021
    Copy the full SHA
    b216f48 View commit details

Commits on Aug 26, 2021

  1. This will send the humidity and temperature to TTN

    With this change you directly send the data to thethingsnetwork.org. Please note the Payload Formatter in the description which needs to be added into the TTN console, to change the sent data from bytes to numbers. I had to read out the sensor again and stored the data in new variables, I'm fairly sure this can be solved nicer, but this works too.
    patoberli authored Aug 26, 2021
    Copy the full SHA
    51f4c1b View commit details

Commits on Nov 11, 2021

  1. Merge pull request #67 from patoberli/patch-1

    This will send the humidity and temperature to TTN
    Heltec-Aaron-Lee authored Nov 11, 2021
    Copy the full SHA
    c8f289e View commit details
  2. Merge pull request #65 from ohioh/patch-1

    Update OTAA.ino
    Heltec-Aaron-Lee authored Nov 11, 2021
    Copy the full SHA
    fc3ebf4 View commit details

Commits on Jun 10, 2022

  1. Delete rtc-board.S

    maxgerhardt authored Jun 10, 2022
    Copy the full SHA
    879cd3b View commit details
  2. Fix call8 error

    maxgerhardt authored Jun 10, 2022
    Copy the full SHA
    b29f6e4 View commit details

Commits on Jun 24, 2022

  1. Fix more calls

    maxgerhardt committed Jun 24, 2022
    Copy the full SHA
    571b96f View commit details

Commits on Jul 14, 2022

  1. Merge pull request #83 from maxgerhardt/master

    Hotfix linker error
    Heltec-Aaron-Lee authored Jul 14, 2022
    Copy the full SHA
    91c609f View commit details

Commits on Jul 20, 2022

  1. Added preamble length setting options.

    Added preamble length setting options.
    Quency-D committed Jul 20, 2022
    Copy the full SHA
    cfae123 View commit details

Commits on Jul 21, 2022

  1. Update .gitignore

    Add entries to gitignore
    kohlschuetter committed Jul 21, 2022
    Copy the full SHA
    85e6058 View commit details
  2. LoRaWanClass: Add missing check for LORAMAC_REGION_LA915 upon init

    We wouldn't print the region upon init if the region was set to LA915.
    kohlschuetter committed Jul 21, 2022
    Copy the full SHA
    278c70d View commit details
  3. LoRaMac: Fix unitializated variable

    Fixes a compiler error where datarate was potentially used unitialized.
    kohlschuetter committed Jul 21, 2022
    Copy the full SHA
    69edfc0 View commit details
  4. Allow code to be used as an ESP-IDF component

    Add configuration files so we can use this code as an ESP-IDF component.
    Just check out the repository into a project's components/ESP32_LoRaWAN
    folder.
    
    This feature depends on Espressif's arduino-esp32 component, which is
    available for ESP-IDF 4.4.
    kohlschuetter committed Jul 21, 2022
    Copy the full SHA
    5d74e55 View commit details

Commits on Sep 19, 2022

  1. Merge pull request #85 from kohlschuetter/pr/ck/esp-idf-component

    Allow code to be used as an ESP-IDF component
    Quency-D authored Sep 19, 2022
    Copy the full SHA
    af84f84 View commit details
  2. Merge pull request #86 from kohlschuetter/pr/ck/code-cleanup

    Fix compiler errors, update .gitignore
    Quency-D authored Sep 19, 2022
    Copy the full SHA
    eace549 View commit details

Commits on Dec 16, 2022

  1. Copy the full SHA
    d4e7120 View commit details

Commits on Dec 20, 2022

  1. Copy the full SHA
    55dac56 View commit details

Commits on Dec 26, 2022

  1. Copy the full SHA
    2bcefde View commit details

Commits on Mar 22, 2024

  1. Document update

    Heltec-Aaron-Lee committed Mar 22, 2024
    Copy the full SHA
    7b5d52b View commit details
Showing with 10,055 additions and 5,352 deletions.
  1. +5 −1 .gitignore
  2. +61 −0 CMakeLists.txt
  3. +9 −0 Kconfig.projbuild
  4. +305 −0 examples/FactoryTest/Factory_Test_Wifi_LoRa32_V2/Factory_Test_Wifi_LoRa32_V2.ino
  5. +102 −0 examples/FactoryTest/Factory_Test_Wifi_LoRa32_V2/images.h
  6. +282 −0 examples/FactoryTest/Factory_Test_Wireless_Stick/Factory_Test_Wireless_Stick.ino
  7. +102 −0 examples/FactoryTest/Factory_Test_Wireless_Stick/images.h
  8. +268 −0 examples/FactoryTest/Factory_Test_Wireless_Stick_Lite/Factory_Test_Wireless_Stick_Lite.ino
  9. +102 −0 examples/FactoryTest/Factory_Test_Wireless_Stick_Lite/images.h
  10. +4 −1 examples/OTAA/OTAA.ino
  11. +3 −0 examples/OTAA_Battery_power/OTAA_Battery_power.ino
  12. +3 −0 examples/OTAA_LED/OTAA_LED.ino
  13. +19 −1 examples/OTAA_OLED/OTAA_OLED.ino
  14. +3 −0 examples/OTAA_OLED_Interrupt_CLASS_A/OTAA_OLED_Interrupt_CLASS_A.ino
  15. +3 −0 examples/OTAA_OLED_interrupt_CLASS_C/OTAA_OLED_interrupt_CLASS_C.ino
  16. +203 −0 examples/Sensor/LoRaWAN_HDC1080/LoRaWAN_HDC1080.ino
  17. +320 −0 examples/WiFi_LoRaWAN/WiFi_LoRaWAN.ino
  18. +15 −0 idf_component.yml
  19. BIN img/03.png
  20. +28 −4 readme.md
  21. +57 −16 src/ESP32_LoRaWAN.cpp
  22. +4 −0 src/ESP32_LoRaWAN.h
  23. +2 −2 src/LoRaMac.c
  24. +1 −0 src/LoRaMac.h
  25. +6,142 −5,286 src/Mcu.S
  26. +5 −0 src/Mcu.h
  27. +3 −3 src/OLEDDisplay.cpp
  28. +13 −10 src/SSD1306Wire.h
  29. +1 −1 src/gpio.h
  30. +77 −0 src/region/Region.c
  31. +1 −1 src/region/RegionAS923.c
  32. +1 −1 src/region/RegionAU915.c
  33. +1 −1 src/region/RegionCN470.c
  34. +1 −1 src/region/RegionCN779.c
  35. +1 −1 src/region/RegionEU433.c
  36. +1 −1 src/region/RegionEU868.c
  37. +1 −1 src/region/RegionIN865.c
  38. +1 −1 src/region/RegionKR920.c
  39. +1,046 −0 src/region/RegionLA915.c
  40. +548 −0 src/region/RegionLA915.h
  41. +1 −1 src/region/RegionUS915-Hybrid.c
  42. +1 −1 src/region/RegionUS915.c
  43. +7 −3 src/rtc-board.S
  44. +157 −0 src/sensor/HDC1080.cpp
  45. +106 −0 src/sensor/HDC1080.h
  46. +14 −11 src/sx1276-board.c
  47. +1 −1 src/sx1276-board.h
  48. +22 −2 src/sx1276.c
  49. +2 −0 src/sx1276.h
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.DS_Store
.vscode
.vscode
*~
.*.swp
.*.swo
/build
61 changes: 61 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
set(srcs
src/LoRaMac.c
src/aes.c
src/LoRaMacCrypto.c
src/Mcu.S
src/gpio.c
src/board.c
src/delay.c
src/gpio-board.c
src/cmac.c
src/OLEDDisplay.cpp
src/fifo.c
src/timer.S
src/region/RegionUS915-Hybrid.c
src/region/RegionAU915.c
src/region/RegionCN470.c
src/region/RegionAS923.c
src/region/Region.c
src/region/RegionCN779.c
src/region/RegionLA915.c
src/region/RegionEU868.c
src/region/RegionKR920.c
src/region/RegionEU433.c
src/region/RegionCommon.c
src/region/RegionIN865.c
src/region/RegionUS915.c
src/rtc-board.S
src/sensor/HDC1080.cpp
src/ESP32_LoRaWAN.cpp
src/utilities.c
src/OLEDDisplayUi.cpp
src/sx1276-board.c
src/sx1276.c
src/LoRaMacConfirmQueue.c
)

set(includedirs
src
src/region
src/sensor
)

set(priv_includes )
set(requires arduino)
set(priv_requires )

idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires})

function(maybe_add_component component_name)
idf_build_get_property(components BUILD_COMPONENTS)
if (${component_name} IN_LIST components)
idf_component_get_property(lib_name ${component_name} COMPONENT_LIB)
target_link_libraries(${COMPONENT_LIB} PUBLIC ${lib_name})
endif()
endfunction()

maybe_add_component(arduino)

target_compile_options(${COMPONENT_TARGET} PUBLIC
-DESP32 -DLORAWAN_PREAMBLE_LENGTH=${CONFIG_LORAWAN_PREAMBLE_LENGTH}
)
9 changes: 9 additions & 0 deletions Kconfig.projbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
menu "LoRaWAN library for ESP32 + LoRa boards made by heltec"

config LORAWAN_PREAMBLE_LENGTH
int "LoRaWAN preamble length"
default 8
help
The length of the LoRaWAN premable.

endmenu
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@
#include <ESP32_LoRaWAN.h>
#include "Arduino.h"
#include "WiFi.h"
#include "images.h"

#define USER_KEY 0
#define YOUR_SSID "your ssid"
#define YOUR_PASSWORD "your password"

#define RF_FREQUENCY 868000000 // Hz

#define TX_OUTPUT_POWER 14 // dBm

#define LORA_BANDWIDTH 0 // [0: 125 kHz,
// 1: 250 kHz,
// 2: 500 kHz,
// 3: Reserved]
#define LORA_SPREADING_FACTOR 7 // [SF7..SF12]
#define LORA_CODINGRATE 1 // [1: 4/5,
// 2: 4/6,
// 3: 4/7,
// 4: 4/8]
#define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT 0 // Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON false
#define LORA_IQ_INVERSION_ON false


#define RX_TIMEOUT_VALUE 1000
#define BUFFER_SIZE 30 // Define the payload size here

char txpacket[BUFFER_SIZE];
char rxpacket[BUFFER_SIZE];

static RadioEvents_t RadioEvents;
void OnTxDone( void );
void OnTxTimeout( void );
void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr );

typedef enum
{
STATUS_LOWPOWER,
STATUS_RX,
STATUS_TX
}States_t;


int16_t txNumber;
States_t state;
bool sleepMode = false;
int16_t Rssi,rxSize;

uint32_t license[4] = {0xD5397DF0, 0x8573F814, 0x7A38C73D, 0x48E68607};

void WIFISetUp(void)
{
// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.disconnect(true);
delay(100);
WiFi.mode(WIFI_STA);
WiFi.setAutoConnect(true);
WiFi.begin(YOUR_SSID,YOUR_PASSWORD);//fill in "Your WiFi SSID","Your Password"
delay(100);

byte count = 0;
while(WiFi.status() != WL_CONNECTED && count < 10)
{
count ++;
delay(500);
Display.drawString(0, 0, "Connecting...");
Display.display();
}

Display.clear();
if(WiFi.status() == WL_CONNECTED)
{
Display.drawString(0, 0, "Connecting...OK.");
Display.display();
}
else
{
Display.clear();
Display.drawString(0, 0, "Connecting...Failed");
Display.display();
//while(1);
}
Display.drawString(0, 10, "WIFI Setup done");
Display.display();
delay(500);
}

void WIFIScan(unsigned int value)
{
unsigned int i;
WiFi.mode(WIFI_STA);

for(i=0;i<value;i++)
{
Display.drawString(0, 20, "Scan start...");
Display.display();

int n = WiFi.scanNetworks();
Display.drawString(0, 30, "Scan done");
Display.display();
delay(500);
Display.clear();

if (n == 0)
{
Display.clear();
Display.drawString(0, 0, "no network found");
Display.display();
//while(1);
}
else
{
Display.drawString(0, 0, (String)n);
Display.drawString(14, 0, "networks found:");
Display.display();
delay(500);

for (int i = 0; i < n; ++i) {
// Print SSID and RSSI for each network found
Display.drawString(0, (i+1)*9,(String)(i + 1));
Display.drawString(6, (i+1)*9, ":");
Display.drawString(12,(i+1)*9, (String)(WiFi.SSID(i)));
Display.drawString(90,(i+1)*9, " (");
Display.drawString(98,(i+1)*9, (String)(WiFi.RSSI(i)));
Display.drawString(114,(i+1)*9, ")");
// display.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
delay(10);
}
}

Display.display();
delay(800);
Display.clear();
}
}
bool resendflag=false;
bool deepsleepflag=false;
void interrupt()
{
delay(10);
if(digitalRead(USER_KEY)==0)
{
if(digitalRead(LED)==LOW)
{
state=STATUS_TX;
}
else
{
deepsleepflag=true;
}
}
}
void logo(){
Display.clear();
Display.drawXbm(0,5,logo_width,logo_height,(const unsigned char *)logo_bits);
Display.display();
}
void setup()
{
pinMode(LED,OUTPUT);

Serial.begin(115200);
while (!Serial);
factory_test=true;

uint64_t chipid=ESP.getEfuseMac();//The chip ID is essentially its MAC address(length: 6 bytes).
Serial.printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes
Serial.printf("%08X\n",(uint32_t)chipid);//print Low 4bytes.
delay(100);

SPI.begin(SCK,MISO,MOSI,SS);
Mcu.init(SS,RST_LoRa,DIO0,DIO1,license);

pinMode(Vext,OUTPUT);
digitalWrite(Vext,LOW);
delay(20);
Display.init();

logo();
delay(300);
Display.clear();

WIFISetUp();
WiFi.disconnect(); //重新初始化WIFI
WiFi.mode(WIFI_STA);
delay(100);

WIFIScan(1);

txNumber=0;
Rssi=0;

RadioEvents.TxDone = OnTxDone;
RadioEvents.TxTimeout = OnTxTimeout;
RadioEvents.RxDone = OnRxDone;

Radio.Init( &RadioEvents );
Radio.SetChannel( RF_FREQUENCY );
Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
LORA_SPREADING_FACTOR, LORA_CODINGRATE,
LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
true, 0, 0, LORA_IQ_INVERSION_ON, 3000 );

Radio.SetRxConfig( MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,
LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,
LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON,
0, true, 0, 0, LORA_IQ_INVERSION_ON, true );
state=STATUS_TX;
pinMode(USER_KEY,INPUT_PULLUP);
attachInterrupt(USER_KEY,interrupt,FALLING);
}


void loop()
{
switch(state)
{
case STATUS_TX:
delay(1000);
txNumber++;
sprintf(txpacket,"%s","hello");
sprintf(txpacket+strlen(txpacket),"%d",txNumber);
sprintf(txpacket+strlen(txpacket),"%s"," Rssi : ");
sprintf(txpacket+strlen(txpacket),"%d",Rssi);

Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket));

Radio.Send( (uint8_t *)txpacket, strlen(txpacket) );
state=STATUS_LOWPOWER;
break;
case STATUS_RX:
Serial.println("into RX mode");
Radio.Rx( 0 );
state=STATUS_LOWPOWER;
break;
case STATUS_LOWPOWER:
LoRaWAN.sleep(CLASS_C,0);
if(deepsleepflag)
{
delay(200);
LoRaWAN.sleep(CLASS_C,0);
Serial.println("lowpower");
Radio.Sleep();
pinMode(LED,INPUT);
pinMode(4,INPUT);
pinMode(5,INPUT);
pinMode(14,INPUT);
pinMode(15,INPUT);
pinMode(16,INPUT);
pinMode(17,INPUT);
pinMode(18,INPUT);
pinMode(19,INPUT);
pinMode(26,INPUT);
pinMode(27,INPUT);
digitalWrite(Vext,HIGH);
delay(2);
esp_deep_sleep_start();
}
break;
default:
break;
}
}

void OnTxDone( void )
{
Serial.print("TX done......");
displayInof();
state=STATUS_RX;
}

void OnTxTimeout( void )
{
Radio.Sleep( );
Serial.print("TX Timeout......");
state=STATUS_TX;
}
void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
{
digitalWrite(LED,HIGH);
Rssi=rssi;
rxSize=size;
memcpy(rxpacket, payload, size );
rxpacket[size]='\0';
Radio.Sleep( );

Serial.printf("\r\nreceived packet \"%s\" with Rssi %d , length %d\r\n",rxpacket,Rssi,rxSize);
Serial.println("wait to send next packet");
displayInof();
state=STATUS_TX;
}

void displayInof()
{
Display.clear();
Display.drawString(0, 50, "Packet " + String(txNumber,DEC) + " sent done");
Display.drawString(0, 0, "Received Size" + String(rxSize,DEC) + " packages:");
Display.drawString(0, 15, rxpacket);
Display.drawString(0, 30, "With rssi " + String(Rssi,DEC));
Display.display();
}
Loading