{"id":16229830,"url":"https://github.com/indaco/saphcpiot-greenhouse","last_synced_at":"2026-05-05T03:37:49.114Z","repository":{"id":136250681,"uuid":"42066892","full_name":"indaco/saphcpiot-greenhouse","owner":"indaco","description":"IoT Greenhouse Demo Scenario on SAP HCP using RaspberryPI, Python, Java, SAPUI5 and SAP HCP IoT Services","archived":false,"fork":false,"pushed_at":"2015-10-13T07:34:03.000Z","size":2176,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-14T03:49:21.994Z","etag":null,"topics":["demo-app","iot-platform","python","raspberry-pi","sap-hcp","sapui5"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/indaco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-07T17:48:08.000Z","updated_at":"2017-05-09T17:03:27.000Z","dependencies_parsed_at":"2023-03-13T12:31:53.355Z","dependency_job_id":null,"html_url":"https://github.com/indaco/saphcpiot-greenhouse","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indaco%2Fsaphcpiot-greenhouse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indaco%2Fsaphcpiot-greenhouse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indaco%2Fsaphcpiot-greenhouse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indaco%2Fsaphcpiot-greenhouse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/indaco","download_url":"https://codeload.github.com/indaco/saphcpiot-greenhouse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247785920,"owners_count":20995642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["demo-app","iot-platform","python","raspberry-pi","sap-hcp","sapui5"],"created_at":"2024-10-10T12:59:20.148Z","updated_at":"2026-05-05T03:37:44.094Z","avatar_url":"https://github.com/indaco.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Greenhouse Demo Scenario\n\n\u003e**NOTE**: This document is in DRAFT version, something can be missing or wrong. If you intend to re-create this scenario, you are smart enough to go through without a real step-by-step guide. Anyway, if you find errors, missing steps or typos  as well as if you need some help to implement the scenario, feel free to contact me. I really appreciate your help and your feedbacks.\n\n\u003eDISCLAIMER: This repository doesn't want to represent the best way to develop on SAP HCP or on RaspberryPi, but it's an attempt to make things work and, it works. Code can be improved in readability, efficiency and design.\n\nThis is the repository for a real and complete end-to-end scenario (**Greenhouse**) built using the SAP Hana Cloud Platform IoT Services ([SAP HCP IoT](http://hcp.sap.com/)) and a [RaspberryPi](https://www.raspberrypi.org/) as a gateway.\n\nThe document and the code snippets  will provide information on how to quick re-use it, replicate what I built, improve it and extend it.\n\n![Greenhouse](/images/greenhouse.png)\n\nThe entire _Greenhouse_ scenario is based on two separate applications:\n\n- **greenshouse**: Sensor data readings, data transmission via RaspberryPi to SAP HCP and an HTML5 UI/Dashboard developed with [SAPUI5](https://sapui5.netweaver.ondemand.com/) on SAP HCP.\n\n![GreenhouseTiles](/images/greenhouse_tiles.png)\n![GreenhouseUI1](/images/greenhouse_ui_1.png)\n![GreenhouseUI2](/images/greenhouse_ui_2.png)\n\n- **remotecontroller**: Receiving the messages sent to the device. It acts as a controller to switch on/off a lamp, open/close the roof consuming messages sent to the devices.\n\n![RemoteController](/images/remote_controller.png)\n\n## Shopping list\nHere a list of components used to build the scenario:\n\n- 1 Raspberry Pi B+ or Raspberry Pi 2\n- 1 AM2302 sensor\n- 1 Breadboard   \n- 3 leds (Red, Green and Yellow)\n- 3 resistors 330Ω\n- 1 T-Cobbler cable\n- 1 DC 5V Relay module\n- 1 Lamp\n- 1 [Continuous Rotation Servo](http://www.adafruit.com/products/154)\n- 1 Additional 5V (2000mA) power supply\n- Some jumpers\n- Plexiglass box (W: 50cm H: 25cm)\n\n## Prerequisites\nIn this section you can find a quick list of prerequisites, software and hardware.\n\nDiscussing how to connect leds, lamp, servo motor and so on to the RaspberryPi as well as the SAP HCP IoT architecture, features etc. are outside the scope of this document; There are lots of resources available on line.\n\n### RaspberryPi\n\nThe RaspberryPi acts as a gateway. All the code is written in Python 3  (v. 3.2) and uses some python libs. Take a look to the following links to install all the requirements:\n\n- [RPi.GPIO](https://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberry-pi/install-python-module-rpi-dot-gpio)\n- [Requests](http://docs.python-requests.org/en/latest/)\n\n### SAP HCP\n\nGetting started with SAP HCP IoT following the step-by-step guides:\n\n1. [Get HANA Cloud Platform Developer Account](https://github.com/SAP/iot-starterkit/blob/master/src/prerequisites/account)\n2. [Enable Internet of Things Services](https://github.com/SAP/iot-starterkit/blob/master/src/prerequisites/service)\n\n## How to use it.\n\nIn this section you can find steps to replicate the entire scenario. Make sure all the above prerequisites are in place.\n\n### 1. RaspberryPi\n\nTo handle the AM2302 sensor protocol (as well as for of DHT11 and DHT22) will use an utility developed by [Adafruit](http://adafruit.com) that, among other things, develops and sells many interesting accessories for RaspberryPi.\n\nThe sources of Adafruit also contains a library to allow Python code to access the sensor data. Unfortunately, at the moment, the library has not been updated to support Python 3. We will use a class in Python 3, [DHTUtils](apps/greenhouse/raspberrypi/utils/dhtutils.py), as a wrapper that implements methods to make the call to the library Adafruit.\n\nFirst of all, we clone the [Adafruit_Python_DHT](https://github.com/adafruit/Adafruit_Python_DHT) Github repository and save the code in a `Adafruit ` folder within the `home` directory of `pi` user:\n\n```shell\ncd ~/\nmkdir Adafruit \u0026\u0026 cd $_\ngit clone https://github.com/adafruit/Adafruit_Python_DHT.git\n```\n\nThe, we clone this repository:\n\n```shell\ncd ~/\ngit clone https://github.com/indaco/saphcpiot-greenhouse.git\n```\n\nCreate a folder to save the code inside it:\n\n```shell\ncd ~/\nmkdir code\n```\n\n#### Greenhouse App\n\nMove code for the _greenhouse_ app to the right folder:\n\n```shell\ncd ~/\nmv ~/saphcpiot-greenhouse-master/apps/greenhouse/raspberrypi ~/code/greenhouse\n```\n\nand adapt the [configs.py](apps/greenhouse/raspberrypi/configs.py) with your information.\n\n#### Remote Controller App\n\nCopy and paste code for the _remotecontroller_ app to the right folder\n```shell\ncd ~/\nmv ~/saphcpiot-greenhouse-master/apps/remotecontroller/raspberrypi ~/code/remotecontroller\n```\nand adapt the [configs.py](apps/remotecontroller/raspberrypi/configs.py) with your information.\n\n#### Logging\n\nBoth _greenhouse_ and _remotecontroller_ save logs in their respective \"logs\" folders. You should not see output on the shell.\n\n### 2. SAP HCP\n\n#### Getting started with SAP HCP IoT\n\nUse the following documentations as step-by-step guide to:\n\n1. [Create Device Information in Internet of Things Services Cockpit](https://github.com/SAP/iot-starterkit/blob/master/src/prerequisites/cockpit)\n   - after device and device type creations, it's time to create message types **to** and **from** RaspberryPi. Create them as shown in the figures\n\n   ![MessageFromGreenhouse](/images/msg_fromGreenhouse.png)\n\n   ![MessageToGreenhouse](/images/msg_toGreenhouse.png)\n\n2. [Deploy the Message Management Service (MMS)](Deploy the Message Management Service (MMS)\n3. [Consume the messages with HANA XS using XSJS and OData](https://github.com/SAP/iot-starterkit/tree/master/src/apps/xs/consumption)\n\n#### Greenhouse App\n\n1. Create a [new XS App](https://github.com/SAP/iot-starterkit/tree/master/src/apps/xs/consumption#hana-xs-development) for the _Greenhouse_\n2. Copy all the code in `~/saphcpiot-greenhouse/apps/greenhouse/hcp/xs/iotmmsxs` to the HANA XS app previously created\n3. Adapt the following files to reflect information from your account and your HANA Schema:\n   - [.xsaccess](apps/greenhouse/hcp/xs/iotmmsxs/.xsaccess)\n   - [.xsprivileges](apps/greenhouse/hcp/xs/iotmmsxs/.xsprivileges)\n   - [roles/user.hdbrole](apps/greenhouse/hcp/xs/iotmmsxs/roles/user.hdbrole)\n   - [services/iotservices.xsodata](apps/greenhouse/hcp/xs/iotmmsxs/services/iotservices.xsodata)\n   - [services/lastValues.xsjs](apps/greenhouse/hcp/xs/iotmmsxs/services/lastValues.xsjs)\n   - [services/measurements.xsjs](apps/greenhouse/hcp/xs/iotmmsxs/services/measurements.xsjs)\n4. Execute the following SQL Script to grant accesses (refer to  [Grant Access](https://github.com/SAP/iot-starterkit/tree/master/src/apps/xs/consumption#grant-roles)) documentation\n```SQL\ncall \"HCP\".\"HCP_GRANT_ROLE_TO_USER\"('\u003cuser_id\u003etrial.iotmmsxs::iotaccess', '\u003cuser_id\u003e');\n```\n\n#### Remote Controller App\n\n1. Open the Java project `~/saphcpiot-greenhouse/apps/remotecontroller/hcp/java/it.sapiotlab.greenhouse.remotecontroller` with Eclipse\n2. Adapt the [index.html](apps/remotecontroller/hcp/java/it.sapiotlab.greenhouse.remotecontroller/src/main/webapp/index.html) file at the bottom of the page (`createModel` method) to reflect information from your SAP HCP IoT Cookpit\n3. [Compile with Maven and Deploy](https://github.com/SAP/iot-starterkit/tree/master/src/apps/java/consumption#compilation-and-deployment)\n\n### Start \u0026 Stop\n\nTwo different scripts are provided to start and stop the applications.\n\nSTART:\n- [start_greenhouse.sh](apps/greenhouse/raspberrypi/start_greenhouse.sh)\n- [start_remotecontroller.sh](apps/remotecontroller/raspberrypi/start_remotecontroller.sh)\n\nSTOP:\n- [stop_greenhouse.sh](apps/greenhouse/raspberrypi/stop_greenhouse.sh)\n- [stop_remotecontroller.sh](apps/remotecontroller/raspberrypi/stop_remotecontroller.sh)\n\nExecute them as `sudo`, e.g.:\n\n```shell\ncd /home/pi/code/greenhouse/\nsudo ./start_greenhouse.sh\n```\n\n### Miscellaneous\n\n#### RaspberryPi Email IP On Boot\n\nTo access the RaspberryPi via SSH or other network protocols without a monitor and moving from network to network, we need to know the IP address. The [startup_mailer.py](app/greenhouse/raspberrypi/scripts/startup_mailer.py) utility do exactly this task. It's based on [RPi Email IP On Boot Debian](http://elinux.org/RPi_Email_IP_On_Boot_Debian) documentation by Cody Giles.\n\n#### Auto-Start\u0026Stop\n\nCrontab tasks are used to automatically start and stop the scenario.\n\n| Application      | Wake-Up | Sleep   | Days            |\n| ---------------- | --------| ------- | --------------- |\n| Greenhouse       | 8:00 AM | 8:00 PM | Monday - Friday |\n| RemoteController | 8:05 AM | 7:55 PM | Monday - Friday |\n\nRun `crontab -e` and paste the following entries:\n\n```shell\n# Greenhouse\n0 8 * * 1-5 /home/pi/code/greenhouse/start_greenhouse.sh \u003e /tmp/start_greenhouse.log\n0 22 * * 1-5 /home/pi/code/greenhouse/stop_greenhouse.sh \u003e /tmp/stop_greenhouse.log\n# Remote Controller\n5  8  * * 1-5 /home/pi/code/remotecontroller/start_remotecontroller.sh \u003e /tmp/start_remotecontroller.log\n55 19 * * 1-5  /home/pi/code/remotecontroller/stop_remotecontroller.sh \u003e /tmp/stop_remotecontroller.log\n```\n\nYou can find the `cron-file.txt` for both the applications.\n\n### Further Resources\n\n- [SAP Hana Cloud Platform](http://hcp.sap.com/)\n- [SAP HANA Cloud Platform Developer Center](http://scn.sap.com/community/developer-center/cloud-platform)\n- [SAP HANA Cloud Platform Internet of Things (IoT) Services](https://help.hana.ondemand.com/iot/frameset.htm)\n- [SAP HANA Cloud Platform IoT Starter Kit](https://github.com/SAP/iot-starterkit)\n- [Turning on an led with your RaspberryPi's GPIO pins](http://thepihut.com/blogs/raspberry-pi-tutorials/27968772-turning-on-an-led-with-your-raspberry-pis-gpio-pins)\n- [Controlling Relay Boards using RaspberryPi](https://elementztechblog.wordpress.com/2014/09/09/controlling-relay-boards-using-raspberrypi/)\n- [Controlling Servo Motors](http://razzpisampler.oreilly.com/ch05.html)\n\n### License\nAll the code is released under [Creative Commons CC0 1.0 Universal (CC0 1.0)](https://creativecommons.org/publicdomain/zero/1.0/) license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findaco%2Fsaphcpiot-greenhouse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Findaco%2Fsaphcpiot-greenhouse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findaco%2Fsaphcpiot-greenhouse/lists"}