skruglewicz
Published

Research & Experimentation with the LoraWAN Dev Kit

Here are my notes that I took while following the steps in the getting started guide card included in the kit.

BeginnerProtip5 hours263
Research & Experimentation with the LoraWAN Dev Kit

Things used in this project

Hardware components

Seeed Studio LoRaWAN Dev Kit
Seeed Studio LoRaWAN Dev Kit
×1

Software apps and online services

Edge Impulse Studio
Edge Impulse Studio
Getting-Started-with-Seeed-Studio-LoRaWAN-Dev-Kit

Story

Read more

Code

Lightsensor-send-data.ino

Arduino
Send data via Grove LoRa E5
	#include <Arduino.h>
	#include "disk91_LoRaE5.h"
	
	Disk91_LoRaE5 lorae5(&Serial); // Where the AT command and debut traces are printed
	
	#define Frequency DSKLORAE5_ZONE_EU868
	/*
	Select your frequency band here.
	DSKLORAE5_ZONE_EU868
	DSKLORAE5_ZONE_US915
	DSKLORAE5_ZONE_AS923_1
	DSKLORAE5_ZONE_AS923_2
	DSKLORAE5_ZONE_AS923_3
	DSKLORAE5_ZONE_AS923_4
	DSKLORAE5_ZONE_KR920
	DSKLORAE5_ZONE_IN865
	DSKLORAE5_ZONE_AU915
	 */
	
	char deveui[] = "2CF7FXXXXXX0A49F";
	char appeui[] = "80000XXXXXX00009";
	char appkey[] = "2B7E151628XXXXXXXXXX158809CF4F3C";
	
	
	void data_decord(int val, uint8_t data[2])
	{ 
	  data[0] = val >> 8 & 0xFF;
	  data[1] = val & 0xFF;
	}
	
	void setup(void)
	{ 
	  Serial.begin(9600);
	  uint32_t start = millis();
	  while ( !Serial && (millis() - start) < 1500 );  // Open the Serial Monitor to get started or wait for 1.5"
	 
	  // init the library, search the LORAE5 over the different WIO port available
	  if ( ! lorae5.begin(DSKLORAE5_SEARCH_WIO) ) {
	    Serial.println("LoRa E5 Init Failed");
	    while(1); 
	  }
	
	  // Setup the LoRaWan Credentials
	  if ( ! lorae5.setup(
	        Frequency,
	        deveui,
	        appeui,
	        appkey
	     ) ){
	    Serial.println("LoRa E5 Setup Failed");
	    while(1);         
	  }
	}
	 
	void loop(void)
	{
	  int light = analogRead(WIO_LIGHT);  //Get the Wio Terminal light value.
	
	  Serial.print("Light Value: "); Serial.println(light);
	
	  static uint8_t data[2] = { 0x00 };  //Use the data[] to store the values of the sensors
	
	  data_decord(light, data);
	  
	  if ( lorae5.send_sync(              //Sending the sensor values out
	        8,                            // LoRaWan Port
	        data,                         // data array
	        sizeof(data),                 // size of the data
	        false,                        // we are not expecting a ack
	        7,                            // Spread Factor
	        14                            // Tx Power in dBm
	       ) 
	  ) {
	      Serial.println("Uplink done");
	      if ( lorae5.isDownlinkReceived() ) {
	        Serial.println("A downlink has been received");
	        if ( lorae5.isDownlinkPending() ) {
	          Serial.println("More downlink are pending");
	        }
	      }
	  }
	  delay(15000);
	}

Credits

skruglewicz

skruglewicz

19 projects • 9 followers
I am now a retired Senior Software Engineer with a Bachelor’s of Science Degree in Computer Science from Boston University.

Comments