1. Skip to Menu
  2. Skip to Content
  3. Skip to Footer>

Expert Sessions!

LoRa - KPN - HANA - an interesting story

Saturday, 16 July 2016 19:05

Written by Prakash Palani

Print E-mail

Aah! Finally, have got some time to write a technical blog to share one of the very interesting IoT scenario using LoRa-KPN-HANA combination. Through this blog, I intent to take you through step-by-step approach to implement this scenario. I am not a core developer, but a guy with the enterprise architect background, my overall objective was to understand the architecture to be able to implement this kind of IoT scenarios.

HANA is something inevitable in today’s SAP world, and every customer is moving ahead with implementing it, so my idea was to understand how Lora-KPN can be combined with the power of HANA to bring out the best of both the technologies.

This technical blog is about making use of LoRAWAN in SAP HANA space, how we can make use of LoRAWAN to transfer things data to HANA in real-time.


With HANA XS, it opens up number of possibilities for a company to make use of existing investments to implement IoT scenarios.

Please note that I have not focused on how KPN network setup to be done, as the instructions will anyway be part of the package once you subscribe for the same.

Enough of introduction, let’s get in to the nuts and bolts of it..

Technologies Used in this scenario :

LoraWAN : LoRAWAN is a technology enabling two-way RADIO communication , dedicated to the Internet of Things solutions.

Node-Red : Node-RED is a tool for wiring together hardware devices, APIs and online services in new and interesting ways.

HANA and SAPUI5 : I guess, they do not need an introduction for SAP folks

Architecture :

Below is the architecture, it took me a day to complete the entire setup, so it’s pretty easy to develop and realize this scenario (of course, you need to have basic setup like HANA)



What do you need to be able to implement this scenario ?

  • SODAQ Autonomo Board
  • SODAQ LoRabee Module
  • Grove TH Sensor
  • Grove Shield


  • Marvin Board (LoRaPi module) from IoT Academy (yet to be released) (iotacademy.nl)
  • Grove TH Sensor


  • Live KPN LoRa Network with credentials

Step 1 : Preparation at thingspark – KPN

  • www.kpn-lora.com/deviceManager
  • Right Click Devices -> Create Device - >
    • Enter the Name
    • DevEUI & DevAddr (sent by KPN)
    • Nwkey (choose 32 characters string or numbers) – to be used in Arduino Sketch
    • Device Profile – Semtech LoRaMote fw3 Class A”
    • Connectivity Plan – shared by KPN
    • Application Server routing profile - > for now choose default
    • AppSKey (choose another 32 characters string or numbers) – to be used in Arduino Sketch

Step 2 :  Preparation for Arduino

  • Download Arduino IDE from https://www.arduino.cc/en/Main/Software
  • Install Arduino IDE
  • Open Arduino IDE
  • Connect Marvin into the USB Port of you PC
  • Tools -> Port - > Arduino Leonardo
  • Tools - > Board - > Arduino Leonardo

Step 3 : Port the below code into Marvin to send out the sensor reading

Copy the Code Below, and paste it into Arduino IDE: (please make sure to replace the Keys marked in Red)



Basic controls of IoT Academy Marvin LoRa Development board.

This version supports:

- Sending LoRa uplink messages using ABP

- Blink three times when sending data


- In Arduino IDE select Arduino Leonardo and com port of your device

- Please adjust ABP-key parameters below to match yours

- Adjust input of send_lora_data() in void loop() to send your own data




int a;

float temperature;

int B=3975;                  //B value of the thermistor

float resistance;

int     defaultBaudRate = 57600;

int     set_port  = 1;

int     reset_port = 5;

//*** Set parameters here BEGIN ---->

String  set_nwkskey = "0000000000000000000000000000000";

String  set_appskey =  "0000000000000000000000000000000";

String  set_devaddr =  "00000000";

//*** <---- END Set parameters here

void setup() {



pinMode(13, OUTPUT);



void loop() {


resistance=(float)(1023-a)*10000/a; //get the resistance of the sensor;

temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;//convert to temperature via datasheet ;

send_LoRa_data(set_port, float(temperature));





void InitializeSerials(int baudrate)




print_to_console("Serial ports initialised");


void initializeRN2483(int rst_port)


//Disable reset pin

pinMode(rst_port, OUTPUT);

digitalWrite(rst_port, HIGH);


//Configure LoRa module

send_LoRa_Command("sys reset");


send_LoRa_Command("mac set nwkskey " + set_nwkskey);


send_LoRa_Command("mac set appskey " + set_appskey);


send_LoRa_Command("mac set devaddr " + set_devaddr);



//For this commands some extra delay is needed.

send_LoRa_Command("mac set adr on");



send_LoRa_Command("mac save");




send_LoRa_Command("mac join abp");




send_LoRa_Command("radio set crc off");






void print_to_console(String message)





void read_data_from_LoRa_Mod()


if (Serial1.available()) {

String inByte = Serial1.readString();




void send_LoRa_Command(String cmd)


Serial.println("Now sending: " + cmd);




void send_LoRa_data(int tx_port, int rawdata)


send_LoRa_Command("mac tx uncnf " + String(tx_port) + String(" ") + rawdata);


void blinky()


digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)

delay(500);              // wait for a second

digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW

delay(500);              // wait for a second

digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)

delay(500);              // wait for a second

digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW

delay(500);              // wait for a second


Deploy the code into the board (and see whether the LED light is blinking for 3 times)

Step 4 : Create a Node-Red account in IBM Bluemix

  • Upload the below json into your node red
    • [{"id":"7fc3c347.184d3c","type":"http in","z":"260433d6.ed009c","name":"/wlogger","url":"/wlogger","method":"post","swaggerDoc":"","x":65,"y":125,"wires":[["656600c3.e9521","168b30c2.efffbf"]]},{"id":"656600c3.e9521","type":"function","z":"260433d6.ed009c","name":"","func":"function hex2a(hexx) {\n var hex = hexx.toString();//force conversion\n var str = '';\n for (var i = 0; i < hex.length; i += 2)\n str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));\n return str;\n// str;\n}\n\n //msg.txt = hex2a(msg.payload.DevEUI_uplink.payload_hex);\nmsg.txt = msg.payload.DevEUI_uplink.payload_hex\nreturn msg","outputs":1,"noerr":0,"x":297.5,"y":217,"wires":[[]]},{"id":"168b30c2.efffbf","type":"function","z":"260433d6.ed009c","name":"","func":"//sites=USGS:14330000\n//parameterCd=00060,00065,00010\n\nmsg.txt = msg.payload.DevEUI_uplink.payload_hex\n\nvar url=\"http://yourserver.hana.com/touchSensor/Procedures/putSensorReading.xsjs?&id=A001&value=\" + msg.txt;\n\n\nmsg.url = url;\n\nreturn msg;","outputs":1,"noerr":0,"x":290.5,"y":281,"wires":[["b2910311.e4992"]]},{"id":"b2910311.e4992","type":"http request","z":"260433d6.ed009c","name":"","method":"GET","ret":"txt","url":"","tls":"","x":377.5,"y":382,"wires":[["f9c911e6.20288"]]},{"id":"f9c911e6.20288","type":"debug","z":"260433d6.ed009c","name":"","active":true,"console":"false","complete":"url","x":558.5,"y":366,"wires":[]}]
  • Below is how the node—red flow will look like, once the code is imported (mentioned above)

Step 5 : Go back to kpn-lora.com/deviceManager to configure the AS Routing Profile and Application Servers

  • In your application servers configuration, make sure to give bluemix url, for example – myhanaiot. mybluemix.net/wlogger

Step 6 : Create necessary services at the HANA end, you can get the XSJS, hdbprocedures and the SAPUI5 code from the following URL

http://ui5cn.com/sap-hana-iot-arduino-raspberry-pi-5/ - thanks to UI5Community Network for providing such a step-by-step instruction to get the necessary backend components created.

Step 7 : Power it up

Once the SAPUI5 Views, Controls, XSJS Services, hdbprocedures are created, then connect the Lora module to a computer (or) to a power supply, then you should be able to see the data getting posted into HANA.

I have also not focused on the SAPUI5 side, as it has been detailed out very clearly in ui5cn website, it doesn’t really make sense to copy the same content in here. If you are not able to complete the SAPUI5 side of it, leave a comment with your mail id, I’ll ensure to get the code delivered to you.

Hope, this blog has given you some direction on how Lora can be integrated with HANA in a simpler form (of course, security related measures to be considered which will make it little bit complicated). Thanks for reading the entire story, will come up with another interesting concept in my next blog, bye until then.

LoRa - KPN - HANA - an interesting story