Skip to main content

Sensor servers for Telecom Box

Project description

Sensor API for the Raspberry Pi

The Sensor API for the Raspberry Pi is a web service that give access to environmental information of a Raspberry Pi. It uses the sensors of the Sense Hat as well as the internal CPU thermometer.

It returns the information as a JSON structure:

  "C": 50.464, 
  "H": 39.45915603637695, 
  "P": 941.78369140625, 
  "T": 34.720176696777344
  • C is the CPU Temperature (in °C)
  • H is the Humidity (in %rH)
  • P is the Barometric Pressure (in Millibars)
  • T is the Ambient Temperature (in °C)


Install the required software:

sudo apt update
sudo apt install sense-hat libatlas-base-dev libopenjp2-7-dev gunicorn3

Install the app:

sudo pip install heiafr-hydrocontest-sensor_api


If you want to test the service you can just start it localy using gunicorn:

gunicorn3 heiafr.hydrocontest.sensor_api:app

You can now go to and check the result.

In a production environment, you would rather start the service using systemd and use a reverse proxy (e.g. Nginx) in front of it.

You can use this systemd service file (you can name it heiafr-hydrocontest-sensor_api.service):

Description=HEIAFR Hydrocontest Sensor API

ExecStart=/usr/bin/gunicorn3 --bind= heiafr.hydrocontest.sensor_api:app


This is a possible Nginx configuration:

location /sensors {
    proxy_set_header    Host $host;
    proxy_set_header    X-Real-IP $remote_addr;
    proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Proto $scheme;
    proxy_pass          http://localhost:8081/;
    proxy_read_timeout  90;

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for heiafr-hydrocontest-sensor_api, version 1.1.1
Filename, size File type Python version Upload date Hashes
Filename, size heiafr-hydrocontest-sensor_api-1.1.1.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page