Giter Site home page Giter Site logo

fescron / efm32-rn2483-masterbuoy Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 440 KB

Happy Gecko (SLSTK3400A) interfacing with LoRaWAN using dbprint

C 94.19% C++ 1.54% TeX 4.28%
microcontroller emlib geckoboard emf32 uart putty simplicity-studio slstk3400a happygecko dramco

efm32-rn2483-masterbuoy's Introduction

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"!!

efm32-rn2483-masterbuoy's People

Contributors

fescron avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.