Skip to Content

So the other week in Las Vegas we had the Hackers’ Lounge for the first time at the event and inside the lounge we had our IoT Lab where you could come by and “try it for yourself”!

We had hardware setup and quick and easy exercises there so you could try connecting a Beagle Bone all the way to SAP HANA and SAP HANA Cloud Platform! So I took the infos with me and I decided to take a Raspberry Pi, a temperature sensor and a HANA server and see what I could put together. After all Berlin is in just a few days and I wanted to share what you can do too!

I used the following link to help get the hardware all connected, and lots of talking to Ian.

image2.JPG

After the hardware was connected it was just a matter of modifying the Python code on the same website to add in the “HTTP POST” to my HANA Server. I’m using actually a SAP HANA Dev Edition but you should be able to use SAP HANA Cloud Platform as well.

Now on my server I created a XS application.

Screen Shot 2014-11-07 at 3.58.31 PM.png

I also set the XS app to an anonymous connection – it is just a demo after all.

First step was to create a table for the data to go into.


namespace iot.data;
@Schema: 'IOT'
context iotsensor {
  type SString : String(40);
  type LString : String(100);
  type SDate : UTCTimestamp;
    type tt_error {
         HTTP_STATUS_CODE: Integer;
         ERROR_MESSAGE: String(100);
         DETAIL: String(200);
    };
  @Catalog.tableType : #COLUMN
  Entity Details {
  key ID: Integer;
  TDATE: SDate;
  SENTEMP: Decimal(9,3);
  SENNAME: LString;
    };
};

Throw in a sequence to auto increment the ID field and a procedure to handle the insert.


PROCEDURE "SYSTEM"."iot.procedures::newSensorData" ( IN row IOT."iot.data::iotsensor.Details", OUT error IOT."iot.data::iotsensor.tt_error" )
 LANGUAGE SQLSCRIPT
 SQL SECURITY INVOKER
 DEFAULT SCHEMA IOT
 AS
BEGIN
/*****************************
  Write your procedure logic
*****************************/
declare lv_date timestamp;
declare lv_sentemp decimal(9,3);
declare lv_name string;
select TDATE, SENTEMP, SENNAME into lv_date, lv_sentemp, lv_name from :row;
if :lv_date = ' ' then
 error = select 400 as http_status_code,
  'invalid date' as error_message,
  'Invalid response from sensor' as detail from dummy;
else
 insert into "iot.data::iotsensor.Details" values ("iot.data::id_seq".NEXTVAL, now(), lv_sentemp, lv_name); 
end if;
END;

Round it off with the XSODATA service and voila we have the data ready to go.


service namespace "iot" {
 "IOT"."iot.data::iotsensor.Details" as "SENSOR"
  create using "iot.procedures::newSensorData";
}

From this point on the data was flying in, so I asked Ian to throw his on as well and we could see if the data from two remote locations were able to go into the server.

Screen Shot 2014-11-07 at 3.39.50 PM.png

Every second Ian and I were both pushing data to the server and were able to see it live on a website! In Ian’s line there you an even see where he brought his “typical” cup of tea in and sat it down next to his sensor. You can even see when he picked it up to drink. I on the other hand had to put my finger on the sensor to get it to heat up above his but apparently London is warmer than Germany.

Find this interesting then be sure to come by the Hackers’ Lounge on the show floor this coming week in Berlin and try this all for yourself!

Many thanks to Thomas Jung for helping me with some of the coding!

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Martin Fischer

    Hi Craig,

    I just got inspired by all that IoT at TechEd && d-code.

    I saw you used different hardware stuff: Raspberry Pi, Arduino and Beagle Board.

    Are there major differences between the hardware platforms or is it more or less a personal decision? What be easiest to start with?

    Cheers,

    Martin

    (0) 
    1. Craig Cmehil Post author

      There are difference between the different types and as I’ve learned most is a personal preference. The RPi requires you to connect to the device either via SSH or with a keyboard and monitor. The Beagle Bone lets you connect via USB – so really depends on how you want to work. Technically there more differences and then it depends on what you are wanting to do with the device.

      (0) 

Leave a Reply