Skip to Content
Technical Articles
Author's profile photo Marian-Cornel Vatafu

Connecting SAP Build with Arduino board through SAP Cloud Integration and API Management

Scenario Overview


The idea behind this project came as soon as I got my hands on an Arduino ESP32 board. With the help of SAP Build, I created a mobile application that communicates with the board using the architecture provided by the SAP Business Technology Platform and it’s able to do multiple tasks. For the sake of simplicity, we stuck to only turning on and off LEDs that are connected to the Arduino ESP32 board, but this type communication can support any sort of task by controlling the power output of the board pins.


Solution Overview

The following picture gives an overview of the intended setup of the solution and the request flows in between:


Solution Overview


An end user can use the SAP Build mobile application, go into the buttons page and turn ON or OFF the LEDs connected to the Arduino ESP32 board. In the background there are multiple calls being made between several platforms, in the end succesfully changing the output power of the pins.


Technical setup


The first step was to find a way to expose the Arduino ESP32 Board to the Internet, and it meant we had to create a HTTP Web Server. This was possible using a C++ script that uses a WiFi library, connects to the local WiFi and generates a local server.



HTTP Server start-up


Using GET calls from Postman or any web browser to the local host ( – http://<router_IP>:<port> ) we are able to set the output power of the LEDs.



HTTP GET Calls for each LED


SAP Build is not able to do any sort of call to unsecured servers, so it meant we had to use SAP Cloud Connector to expose it to the internet in a secure communication and SAP Cloud Integration in order to be able to access the on-premise location.


In the SAP Cloud Connector we exposed the local host as a Non-SAP system, and then we added the resources that we needed – the paths for turning on or off the LEDs.



SAP Cloud Connector Setup


After this step, we can go into SAP Cloud Integration and create a small iFlow that uses a HTTP Sender adapter in order to be called from SAP Build and a HTTP Receiver adapter for the communication with the Arduino board.



SAP Cloud Integration Setup

The first Groovyscript extracts the query parameters sent by SAP Build :


Groovyscript for parameter extraction


I will later go back to this step because I will explain how the parameter value work, because as you can see, we have a value map in this script.


In order to succesfully call SAP Cloud Integration endpoints from SAP Build, we had to dive into SAP API Management and handle the CORS policies.


As a reference for this part we have used this and this blogs by Priyanka Chakraborti and Mariajose Martinez and we have binded the HTTP endpoint of the above iFlow with an API created by us that is handling the ‘OPTIONS’ header, thus enabling communication with SAP Build.


SAP Build home page

Going to the SAP Build part, we had to create logic behind a button in order to do proper GET calls to the LEDs for the SAP Cloud Connector to interpret them.



SAP Build Data page for connections


Adding the ApiKey provided by the binded application in API Management is mandatory, otherwise SAP Build won’t be able to do any sort of call because of the CORS policies not being satisfied.



SAP Build Buttons page


The logic behind each button handles two calls that are triggered by pressing them. The first call turns on the ON led and the second call turns off the OFF led.

Note : The above statement may sound weird, but I had to use a led for each state – one for ON and one for OFF, and that is because I did not find RGB LEDs.


As you saw in the above picture, for each call, we are sending a parameter that has values like 11,12, 21, 22, … , 81, 82.


SAP Build buttons page

The first digit of the parameter is binded with a specific LED connected to the Arduino board, and the second digit means the desired state of the LED, 1 is ON and 2 is OFF.


The groovyscript I showed will pull this value from the SAP Cloud Integration property CamelHttpQuery and use the below value map :



SAP Cloud Integration Value Map


The groovyscript also sets the value map output as a property, which is in the end used dinamically in the HTTP Receiver adapter, sent to the Cloud Connector and in the end used to change the state of the LEDs.

The whole set up can be seen in the below picture. I have set up a proof of concept of a house that has a solar panel, and i had a total of 4 fictional points ( each with 2 LEDs for each state ) in the chain of distribution from the production of electricity by the electrons movement in the solar panel up to the light bulb inside our house. You can see the ESP32 board, and also some of the cables used to connect the LEDs to the Breadboard.



Real life proof of concept




By setting up the proper communication channels we are able to turn a low-code/no-code application generated by SAP Build into something powerful that can manipulated physical objects and change their states. The hardest part was the API Management step, because it takes a lot of time to pass all the steps and you have to be really careful with everything because the errors are not that easy to spot. It was also the first time I have set up the Cloud Connector and this blog by Yury Hotsman helped me a lot.


I hope you liked my article and feel free to reply with any suggestions here or on in the SAP Build Question section.


Thank you !

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Mustafa Bensan
      Mustafa Bensan

      Hi Marian-Cornel,

      I commend you on this impressive and novel end-to-end SAP BTP IoT architecture example.  In particular:

      1)  Very clever solution to expose the Arduino board to the internet with a C++ script that uses a WiFi library.

      2)  Great example showing that Cloud Connector can also be used to connect BTP to a non-SAP on-premise system.  I think there can be a perception that Cloud Connector is only for connecting to on-premise SAP ECC or S/4HANA, so this example demonstrates the versatility of Cloud Connector.