Skip to content

Happy Gecko (SLSTK3400A) interfacing with LoRaWAN using dbprint

Notifications You must be signed in to change notification settings

Fescron/EFM32-RN2483-Masterbuoy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 

Repository files navigation

EFM32-RN2483-Masterbuoy

The code is based on the DRAMCO EFM32-RN2483-LoRa-Node example with functions from dbprint aswell and is designed for use on the EMF32 Happy Ghecko board.

Added code is marked with /* BEGIN ADDED CODE ********/ and /* END ADDED CODE ********/. Code was added in the following files when starting from the DRAMCO example:

  • src/my_lora_device.h (LORAWAN_DEVICE_EUI, LORAWAN_APPLICATION_EUI and LORAWAN_APPLICATION_KEY hidden)
  • lora/lpp.c
  • lora/lpp.h
  • system/leuart.c

Added the following file (declaration of "public" variables):

  • src/main.h

Other useful links:


1 - Documentation

This code receives messages over UART (115200 baudrate) using interrupts, parses the characters back to numbers, repacks it into a LPP (Cayenne Low Power Payload) packet and sends the data to the cloud using a LoRaWAN network.

1.1 - Code flow

The following flowchart mostly describes the added functionality. For the sake of completeness all of the logic states (INIT, ...) are added but not really further discussed. Most of the code was added in the state SEND and SLEEP.

Flowchart

1.1.1 - Extra notes on the flowchart

  • (*1): If there was a line received using interrupts on UART AND there is at least one of the three buffers free, copy the received data to one of those buffers.
  • (*2): Check if one (of three) or more buffers are filled AND at least one of the two data fields (data0 and data1) are free.
  • (*3): Parse the data out of a used buffer into a free data field.

1.1.2 - Processes (= states of the logic) on the flowchart

  • INIT:
    • Initialize system & chip (clocks, ...).
    • Initialize delay function.
    • Initialize interrupts (IRQ).
    • Initialize LED functions to give feedback when there is an error.
    • Initialize buttons and their interrupt functionality.
    • Initialize power management.
    • Initialize ADC for reading the battery voltage.
    • Initialize I²C for sensor readout.
    • Initialize UART using dbprint functionality for:
      • Printing debug messages.
      • Getting input using interrupts.
      • Parsing characters to values.
  • JOIN:
    • Initialize LoRaWAN communications with Over The Air Activation (OTAA).
  • MEASURE:
    • Read battery voltage.
    • Read relative humidity.
    • Read temperature.
      • NOTE: The sensor readouts are not really used since we have a limited amount of bytes we can send to the cloud.
  • SEND:
    • See flowchart.
  • SLEEP:
    • See flowchart.

1.2 - Structure of messages

1.2.1 - UART

The Received UART lines need to have the following structure (the data is in decimal notation):

Data Bouy ID RSSI VBAT
Length 3 chars 2 chars 3 chars
Example 008 66 325

The example data corresponds with:

  • Bouy ID = 8
  • RSSI = (-)66
  • VBAT = 3,25 V
    • NOTE: The VBAT data gets send to "the cloud" with a bouy-ID-offset of "1"!!

1.2.2 - LPP

After parsing the UART characters back to numbers, the retransmitted Cayenne Low Power Payload packet has the following structure (the data is in hexadecimal notation, each column represents one byte):

LPP terminology Data channel Data type Byte 0 Data channel Data type Byte 0 Byte 1
Data Bouy ID Digital Input Bouy ID + 1 Analog Input
Example 08 00 42 09 02 01 45

As noted above, the RSSI value is disguised as an analog input while the VBAT data is disguised as a digital input.

The example data corresponds with:

  • Bouy ID = 0x08 = 8d
  • RSSI = 0x42 = 66d
  • VBAT = 0x0145 = 325d
    • NOTE: The VBAT data gets send to "the cloud" with a bouy-ID-offset of "1"!!