It's Thursday and I've never actually done one of those "Throw Back Thursday" things and if I understand right it's typically about photos but since according to the Urban dictionary that has changed I decided why not do my own.
Originally "throwback Thursday" but now often used on other days. Can now stand for "throwback to" to indicate an old photo, thought, idea, etc. Often used in social media to reminisce, as usually social media is supposed to show the "here/now/recently."
So here I am digging into my archives and came across this interesting project I did ages ago and I still pull it out from time to time and the last time I did someone said can't you blog about that? So here we go.
So what was the project? Check out how to grab temperature data from a Raspberry Pi and send it to SAP HANA, and take it a step further to get control values from the system to control physical hardware.
The cool part of this is the fact that we have tutorials online already that will help you accomplish this so I'm not going to walk you through every single aspect here instead I'll point you to existing material and perhaps you'll find some other items in the catalog that could be interesting for you as well.
To start with we need the SAP HANA project, back then it was of course SAP HANA XSC so the best place to get up to speed on that would be the following tutorial series we have published that shows how to create your project, tables, procedures and services to publish data and display data.
This particular series focuses on the Tessel 1st generation device but I'll show you the code for the Raspberry Pi I used. Also it's really only the first 2 steps that are most important, very similar to this series posted as well.
Of course I did not stop there, I wanted data going both to and from the device and not just storing my little temperature sensor.
Here I went a bit more complex (even more so for the final bit that you see in the video above) so I added more components. Namely here I added more lights to visually see the processes happening and I added a fan that in turn cools down the sensor if it reports to hot.
Jumping back to the HANA system I added an additional "control" table that I could read values from to determine if I reached one of the limits or not. To access that table I use and OData service.
# to use Raspberry Pi board pin numbers
# set up GPIO output channel
if (float(currtemp) <= float(maxtemp)):
if (float(currtemp) < float(mintemp)):
print ('>>> HEATER ON ' + currtemp + "c lower than MIN temp of " + str(mintemp) + "c")
print ('HEATER/FAN OFF ' + currtemp + "c within bounds")
print ('>>> FAN ON ' + currtemp + "c exceeds MAX temp of " + str(maxtemp) + "c")
# Loop to next reading
The video shows the "final" version which I added some button controls to but the buttons simply made doing the "demo" easier as I could start and stop the process as I needed to and not just have it all happen at once.