Skip to content

Raspberry Sense HAT as an SAP Leonardo Iot Device showcase

Notifications You must be signed in to change notification settings

jenska/python-rest-sensehat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-rest-sensehat

Make a Raspberry Pi with Sense HAT a simple SAP Leonardo IoT Device

This python script was created as a showcase for the SAP Leonardo IoT capabilities. It reads some sensor data (enviroment data and gyrsocope data) from Sense HAT and sends the data to the SAP Cloud Platform's IoT service.

The script is prepared to run the Raspberry in headless mode, once an internet connection is confgured. Errors will be displayed on the Sense HAT's 8x8 LED matrix. If the script runs ok, a plasma effect will be shown on the LED matrix.

SAP Leonardo Cockpit

Annotations

  • The script uses the IoT REST gateway service because I had problems with the paho-mqtt library to establish a secure connection. Vice versa I wasn't able to access Sense HAT's sensor data when using NodeJS while mqtt works fine with NodeJS.
  • The downloaded device pem certificate contains an encrypted private key and will therefore be decrypted. The decrypted key is stored locally in 'certificate.key'.

Precondition

  • a Raspberry Pi with a Sense HAT and Raspbian installed
  • SAP Leonardo IoT subscription for Cloud Foundry subaccounot. The showcase should also work with a free trial account.

Setup

Leonardo

Follow the instructions in https://developers.sap.com/tutorials/iot-express-2-create-device-model.html to create a simple IoT device model. Create your device with 2 sensors and capabilities as shown below. Use the REST gateway for your device!

raspberry1

env

gyro

Python

Type this command into the terminal to install the Sense HAT package:

sudo apt install sense-hat

Download your certificate as a pem file and place it into the script's folder.

pem

Copy the secret. Rename 'configuration.json.bak ' to 'configuration.json' and enter your tenant, the secret, your alternate ID's of your device and sensors. Also replace the pem file name.

Run

python3 leonardo.py

About

Raspberry Sense HAT as an SAP Leonardo Iot Device showcase

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages