Skip to Content
Author's profile photo Rui Nogueira

RaspberryPi on SAP HCP – IoT blog series part 1: Setting-up your RaspberryPi

As described in the master document for this blog post series, in the first blog post we’ll prepare a RaspberryPi so that we can run our next exercises on it.

Table of Contents

Get a Raspberry Pi

So the first thing to do is to get hold of a Raspberry Pi (or Pi as I’ll call it from now on). The Pi I’m using is a so called Raspberry Pi revision B with 2 USB ports. The blog post series might also work with the revision A and the revision B+, but I can’t test it for now.

I got my Raspberry Pi for Christmas last year so it was an easy experience for me :-).

But you can get Pi’s from many vendors.

In addition to the Pi you also need to get

  • a power supply with micro USB (5V, minimum of 700mA)
  • an SD memory card (8GB, class 4 or higher)
  • an ethernet network cable
  • an HDMI cable to connect your Pi to a TV
  • ideally also a case so your Pi doesn’t look too scary for non-techies 🙂
  • an USB keyboard, at least for the beginning 🙂
  • a digital temperature sensor DS18B20

IMG_0640.jpg

Get an image

The next thing you need to do is to get an image for your Pi. On the Pi we’ll use the Linux OS called Raspian which is in essence a Debian OS which was adapted to run properly fast on a Pi.

I’ve take the current Raspian image ( Release date 2014-09-09) from the Raspberry Pi download area and downloaded it.

Install the image on your Pi

To install the image just follow the instructions on the corresponding pages from the Raspberry Pi foundation.

Once you have the image on the SD card we go for the next step.

Connecting your Pi

To make it run for the first time go through the following steps

  • insert the imaged SD card into your Pi
  • connect the ethernet cable with your Pi and your network
  • connect the HDMI cable to your Pi and your TV
  • connect the USB keyboard to your Pi
  • switch on your TV
  • as a last step plug in the power supply to your Pi

As a next step you’ll watch how the Raspian OS boots-up your Pi and start the configuration tool for Raspian.

The default user is Pi. The default password for that user is raspberry.

Configure your Pi

Follow the instructions provided at the Pi documentation for configuring your Pi.

IMG_0641.jpg

I’ve changed my Pi setting for

  • Expand filesystem (using the full memory size of my SD card)
  • Change password
  • Change timezone (adapted to my timezone)
  • Change keyboard layout (adapted to the keyboard layout I have on my USB keyboard)
  • Hostname (I’ve set it to rasppirui)

After changing the settings I’ve clicked on the “Finish” button so that the Pi reboots with the new settings.

You should see also your IP-address (I’ve masked mine below).

IMG_0642.jpg

Switching to an SSH connection (optional)

Once you know the IP-address that your Pi fetched from the DHCP server there is no need to use the keyboard and the separate monitor.

Instead you can connect to your Pi via a so called SSH connection. On windows machines you can install tools like putty to get an SSH client.

Linux or Mac systems already have everything in place.

In case you have a Linux or May system (like I do) simply open the terminal application and type-in the following command where aaa.bbb.ccc.ddd is the IP-address that has been assigned to your Pi:

ssh pi@aaa.bbb.ccc.ddd

Confirm the upcoming message by typing the word yes and you are remotely connected to your Pi via an SSH connection.

TEST.png

Setup the proxy (optional)

In case your Pi works behind a proxy you need to configure your Pi accordingly. To setup the proxy for the duration of a session just enter the following commands on your Pi

sudo export http_proxy=http://proxy:8080

sudo export https_proxy=http://proxy:8080

sudo export no_proxy=”localhost”

The commands are just an example. In case your proxy is called differently and another port is used you need to adapt the lines above to make it match to your network setup.

Updating the OS

Now we should update the OS to the most current version. To do that you login to your Pi again and enter the following commands:

sudo apt-get update

sudo apt-get upgrade

Depending on the internet bandwith your have this may take a while. Whenever the update asks you if you really want to update just press the y key.

Making your Pi Multi-Location Ready

Once you start working with your Pi and turn it off an on again on various locations you always get into trouble to find out the PIs IP address in the network you are using. To avoid this you can make your Pi send you an email whenever it boots up. With that you can always use an SSH shell to access it remotely without having to connect a keyboard and monitor to it.

There is a nice tutorial at http://elinux.org/RPi_Email_IP_On_Boot_Debian that I’ve used to accomplish that.

Just follow the steps there and you get an email with the IP address whenever you switch on your Pi and connect it to a network.

Please check if you need to setup the proxy before. Just in case the location you are in is working behind a proxy!

I’ve created a subfolder called myscripts in the Pi’s home folder and stored the file startup_mailer.py in that folder. After that I’ve adapted the file /etc/rc.local as described in the tutorial and it worked perfectly.

Screen Shot 2014-10-15 at 10.15.17.png

Enable Modules for Sensors

At a later point in time in this blog post series we’ll connect an external temperature sensor to our Pi. To be able to use them you need to add 2 modules that are loaded to your Raspberry Pi at boot time. To do that proceed as follows.

Type in

sudo nano /etc/modules

to open the /etc/modules file to edit it.

Now add the following two lines to the file and after that save the file (ctrl + X key and confirm with y)

w1-gpio

w1-therm

Screen Shot 2014-10-15 at 10.26.05.png

You can find out if that worked out fine by rebooting your Pi with

sudo shutdown -r now

and by typing the command

lsmod

to see the list of loaded modules after the reboot. You should see in the output the 2 newly added modules.

Screen Shot 2014-10-15 at 10.32.41.png

Java

We’ll also use Java on our Pi in the next blog posts. If you took the Raspian release that I took, Java is already pre-installed on your Pi. You can check it with the following command that should output the installed Java version on your Pi

java -version

In case you are using an older Raspian release just install it with the following command

sudo apt-get update && sudo apt-get install oracle-java7-jdk

Ready to go

Now that we have prepared our Raspberry Pi we can tackle our next challenge to actually send sensor data from our Raspberry Pi to your free developer account on SAP HANA Cloud Platform.

Stay tuned and check out the master document listing all blogs posts of this series around the Raspberry Pi and the SAP HANA Cloud Platform. In the next blog post we’ll build an app on your developer account to receive and persist the sensor data.

Best,

Rui

Assigned Tags

      26 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo John Astill
      John Astill

      Very nice intro blog to Pi.

      I am using Webiopi for access to my Pi GPIO, it has a very nice rest interface with simple mappings e.g. /bedroom/temperature .

      Looking forward to seeing your Java for pushing data. I currently use shell scripts to push to my HANA system on AWS.

      Cheers

      John

      Author's profile photo John Astill
      John Astill

      I also use SSH when possible, but there are times when I need to see the console running (when I have broken something) and also do not want to plug in a monitor, keyboard etc... I use one of these serial cables USB to TTL Serial Cable - Debug / Console Cable for Raspberry Pi ID: 954 - $9.95 : Adafruit Industries, Unique &… .

      I use it on the Mac which requires that I install a serial driver first. This is the one I used Products , there are others out there.

      With that install I use the screen program in terminal:

      screen /dev/tty.usbserial  115200

      JohnA

      Author's profile photo Rui Nogueira
      Rui Nogueira
      Blog Post Author

      Cool. Will take a look into that. Thanks!

      Best,

      Rui

      Author's profile photo Rui Nogueira
      Rui Nogueira
      Blog Post Author

      So I bought the cable. Very useful. For those of you who've bought it, too, here the pinning for the contacts on your RaspberryPi

      Best,

      Rui

      Author's profile photo Rui Nogueira
      Rui Nogueira
      Blog Post Author

      Thanks John!

      With my next blog post you'll get that. Let's meet at Hacker's night at TechEd in Las Vegas and I'll show you a sneak peek 🙂

      Best,

      Rui

      Author's profile photo Former Member
      Former Member

      Rui, John - I blocked a networking session for "SAP and Robotics" next week - would be fantastic if you could come over. I will bring some toys (robots!!!) and my past projects - including Arduino - HANA communication that I described in a blog a few months ago.

      Wed 1pm and Thu 2:30pm (Lounge 1)

      Author's profile photo Jorge Weiss
      Jorge Weiss

      Thanks a lot Rui!

      It's a very good start.

      Starting to have fun right now!!

      /Weiss

      Author's profile photo Ferry Gunawan
      Ferry Gunawan

      Nice blog Rui! I have also built an IoT using Rpi using the SAP HANA Platform:

      http://scn.sap.com/community/developer-center/hana/blog/2014/07/09/build-a-door-sensor-with-raspberry-pi-and-hana

      Looking forward to your subsequent blogs on Rpi with HANA.

      Best,

      Ferry

      Author's profile photo Somnath Manna
      Somnath Manna

      Rui,

      Cool blog - I was waiting to see this kind of hacking after Marek Kowalkiewicz blogged on his Arduino exploration Let's build a robot! Part 3: Shake it!

      Now its really interesting to see world's one of the smallest single chip computing system RPi pairing up with Enterprise SAP HANA Platform. This is like a David with (not vs) Goliath scenario - need to wait and watch.

      Time has come now to grow up from using RPi for hobby / exploring SonicPi and Scratch with my kids to professional work through possible Enterprise class applications.

      Best regards,

      Somnath

      Author's profile photo Rui Nogueira
      Rui Nogueira
      Blog Post Author

      Thanks Somnath. With the series I simply want to raise awareness around the fact that the SAP HANA Cloud Platform is very versatile and actually try to motivate people to thing about new scenarios that the platform could support.

      If you're in Vegas come to the SAP HANA Cloud Platform booth and ask for the demo from "Rui's Import/Export Inc." 🙂

      Best,

      Rui

      Author's profile photo Former Member
      Former Member

      Rui - I am publicly issuing a challenge - let's try to run SAP HCP on Arduino Yun! I'll come over (with a Yun in my pocket) and let's see if we could do it - would be totally awesome!

      Great post by the way! Thanks for writing it!

      Author's profile photo Jorge Weiss
      Jorge Weiss

      Hi Merek,

      I will try to borrow the Arduino of my son to test it! 🙂

      Regards,

      /Weiss


      Author's profile photo Tsvetan Stoyanov
      Tsvetan Stoyanov

      Rui, I believe bringing together different people and ideas inspires many innovative solutions - just like Raspberry Pi and SAP HCP.

      Actually I made some experiments with RPi including lights, buttons and a DHT22 sensor. To ease my life as a java developer I developed an Eclipse plug-in for running and debugging java projects on a remote RPi system. It integrates seamlessly with the java tooling in Eclipse and allows developers to build RPi applications without installing ssh clients, copying files between systems or struggling how to debug their applications. If you want to give it a try, you can find an update site and the source code here - http://tsvetan-stoyanov.github.io/launchpi/

      Best Regards,

      Tsvetan

      Author's profile photo John Astill
      John Astill

      Hi Tsvetan,

      Any chance you will be at TechEd/d-code?

      JohnA

      Author's profile photo Tsvetan Stoyanov
      Tsvetan Stoyanov

      No chance so far 🙁

      Author's profile photo P. Lans
      P. Lans

      This is going to be fun.

      Got my Pi up and running. Can't wait for the next steps

      Author's profile photo Rui Nogueira
      Rui Nogueira
      Blog Post Author

      Working already on finishing the next blog post. Hopefully by end of this week. Stay tuned 🙂

      Best,

      Rui

      Author's profile photo Rui Nogueira
      Rui Nogueira
      Blog Post Author
      Author's profile photo Former Member
      Former Member

      Unfornately for me, I cannot see the "My IP Address is..." But I borrowed time on a friends TV to do the setup. I wish to continue on my PC via the putty.

      Kindly assist on how I can obtain my IP address to do SSH connection with the putty.

      Thanks a lot!

      IMG_20141202_200354.jpg

      Author's profile photo P. Lans
      P. Lans

      Hi Gabriel,

      From my laptop, I used a tool like wireless network watcher (Wireless Network Watcher - Show who is connected to your wireless network) to find out the IP-address of the PI. In adddition you get to see all other stuff connected to your router.

      Set up putty as described, and you're all set to go

      Author's profile photo Robert Eijpe
      Robert Eijpe

      Hi Rui,

      You mentioned: The blog post series might also work with the revision A and the revision B+, but I can't test it for now.


      I can confirm you that you post series is also running on (my) revision B+.


      Kinds,


      Robert

      Author's profile photo Rui Nogueira
      Rui Nogueira
      Blog Post Author

      Thanks a lot for testing and verifying Robert. Highly appreciated.

      Best,

      Rui

      Author's profile photo Frank Meertens
      Frank Meertens

      Hi Rui:

      Great blog and initiative!  Set-up worked like a charm. I used the hardware that came with my son's Kano (Raspberry Pi with Kano OS to teach kids how to program) and plugged in SD card with Raspian. Following the instructions, I had no problems getting it to work.

      I might try to go back and get it working as well for the Kano OS.

      Looking forward to the next posts.

      Thanks,

      Frank.

      Author's profile photo Gregor Wolf
      Gregor Wolf

      Hi Rui, Hello Raspberry Pi Enthusiasts,

      be aware that after the most recent Rasbian release the  DS18B20 stopped working. Read I2C, SPI, I2S, LIRC, PPS, stopped working? for details. I was able to fix it by adding the line:

      dtoverlay=w1-gpio

      to the /boot/config.txt file.

      Best regards

      Gregor

      Author's profile photo Rui Nogueira
      Rui Nogueira
      Blog Post Author

      Thanks for this hint. It actually saved me a lot of work when I was preparing for an event.

      Best,

      Rui

      Author's profile photo Alejandro Kinsbrunner
      Alejandro Kinsbrunner

      Hi Rui,

      Wonderfull series of posts! I am a newbie and I am thinking of buying the Raspberry Pi 2 + Sense Hat sensors. Do you believe this is a good way of starting?

      Also, I wanted to check about which programming language I should use... I've seen that some people use Python, others Java and others XSODATA. Which one is the standard one? I know some of Java so from my perspective it could be the easier to use for ramping up. What do you think?

      Thanks and regards.

      Alejandro.