Skip to Content
Author's profile photo Andreas Gautsch

Connecting your Android phone to the SAP Cloud Platform IoT Service CF

There are already a lot of excellent blogs about how to connect Things to the SAP Cloud platform. For example the blog series of Fabian Lehmann: Connect a device to the SAP Cloud Platform Internet of Things Cloud Foundry Environment.

TI Sensor Tag, Rasperry PI, … are undoubtful cool things, but somehow I think I have already enough electronical stuff lying around at home and at work and beside that I love the good old JAVA language which can be used on my Android phone.

Maybe I am becoming a bit old-fashioned and get too old to keep up with the amazing speed of the new technologies, but that’s another story 😉

Thus I decided to build for my IoT demo at the SAP Inside Track in Frankfurt (an awesome event) an Android Demo App which should work without manual tasks for certificate installation, device registration and other mandatory tasks when connecting to the IoT service.

The only necessary remaining task should be to enter the credentials for the Cloud Platform instance. With the  SAP IoT Starterkit  there is already a perfect starting point for a Java-based project. This repository was also my starting point and with some adaptions and extensions I created the Android App, the name to download it from the Google Play Store you can find on the right side. The entire source code is available at https://github.com/andau/SCP_ANDROID 

A description of the necessary changes which were applied on top of the SAP IoT StarterKit can be found in the readme file of this repository.

The app is mainly for demo purposes but also intended to serve as starting point for building real use cases with more sophisticated sensors like the camera, GPS or the NFC sensor.

After downloading it from the Google Play Store or building it on your own with the Android Studio (step 1) there are only three parameters to enter in the settings view of the App (Step 2):

  • hostname
  • username  and
  • password

After completing this, the App is ready to start the transmission of data from the light sensor to the Cloud Platform by pressing the “SEND DATA” button (Step 3).

STEP 1 STEP 2 STEP 3
           

Some parts are still there which have to be fixed and improved but if you have already an instance of the SAP Cloud Platform Internet of Things service (Cloud foundry version) available, feel free to use or adapt this App to your needs.

Assigned Tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Andreas

      we are trying connect a smartphone with our SCP via your app, and we are getting this message:

      "No online Gateways with protocol ID 'rest' found"

      Can you help us? Thanks in advance.

      Author's profile photo Andreas Gautsch
      Andreas Gautsch
      Blog Post Author

      Hi!

      I never got this message, but it seems that the connection to the IoT Gateway is not working. Please take a look in the Service Cockpit under the menu point "Gateways", do you have the two gateways in state online there, or at least that with the protocol "rest"?

      Greetings, Andreas

      Author's profile photo Ajith Cheruvally
      Ajith Cheruvally

      Thanks Andreas.

      I have tried this and its working. Wish it can also do the self device registeration!!!!

      Ajith Cheruvally

      Author's profile photo Andreas Gautsch
      Andreas Gautsch
      Blog Post Author

      The device registration should work too, if you connect with an user which has administrator permissions.

      Greetings, Andreas

      Author's profile photo Siva rama Krishna Pabbraju
      Siva rama Krishna Pabbraju

      Hi Andreas,

      When I use my host, app says "INIT FAILED - RETRY". Please let me know how to proceed further.

       

      Host: xxx.eu10.cp.iot.sap

      Regards,

      Siva

       

      Author's profile photo Andreas Gautsch
      Andreas Gautsch
      Blog Post Author

      Hei Siva!

      There could be several reasons. One possible reason is that the provided user has no administrator privilege on the iot cloud instance - this is necessary for creation the device information.

      I am also not able to check if the app is generally compatible to the latest release of the Iot service as I have currently no access to such an instance.

      Greetings, Andreas

      Author's profile photo Siva rama Krishna Pabbraju
      Siva rama Krishna Pabbraju

      Hi Andreas,

       

      I do have admin privileges but it was not connecting so far.

      Suddenly it got connected 🙂 and after few mins app got crashed. 🙁

       

      Regards,

      Siva

       

      Author's profile photo Siva rama Krishna Pabbraju
      Siva rama Krishna Pabbraju

      Hey,

      At last everything is working fine. Thanks Andreas.

      Regards,

      Siva

       

      Author's profile photo Andreas Gautsch
      Andreas Gautsch
      Blog Post Author

      Hi Siva!

      Cool to hear that the app is still working with the latest version.

      Greetings, Andreas

      Author's profile photo Torben Raulfs
      Torben Raulfs

      Hey Andreas, nice App!

      At the moment, I don’t see any options to set my sensors with the sensor ID as described in step 2.

      I can only set my deviceID in the app-settings, but I don’t receive any data in the IoT Cockpit, because there aren’t matching sensors for my device. If I don’t select a device ID in the settings, a device with the name “Android phone” is automatically created, but without any sensors or any incoming data. The connection in the app is successful, so this is not the problem…

      So how can I get and see my incoming data?

      Greetings, Torben