Skip to content
Brenda Nyokabi Bucha edited this page Dec 11, 2020 · 36 revisions

Next page: Pinouts NodeMCU v2, v3

API Air Data.info (aka dusti.api)

The API accepts the sensor data and serves as the basis for the graphical display on v2.map.aq.sensors.africa. In addition, the data of the "public" sensors are exported once a day (around 8:00 am) as CSV and made available at archive.sensors.africa.

API Madavi.de

The API also accepts the sensor data and stores it in a CSV file (one file per sensor per day). Furthermore, the data is stored in a RoundRobin database and graphically processed via RRDTools. The file archive can be found at https://www.madavi.de/sensor/csvfiles.php, the graphical representation at https://www.madavi.de/sensor/graph.php.

OpenSenseMap

Opensensemap is a free platform for open sensor data. Website and API are open source. In addition to numerous projects that provide data to this platform, the fine dust sensor can also be used Transfer data to it. Users can display their values ​​there and have them processed as a graph. A "box" generated there has its own ID, which must be entered in the configuration page of the particulate matter sensor. Then the API point in the configuration is to be activated.

Send to your own API

The data can be stored on a local web server such as a Raspberry Pi in the local network. The menu item "Send to own API" on the configuration page of the particulate matter sensor must be activated accordingly and the destination address with the server, path, port, and optional user and password must be entered. A simple PHP script is available for saving and later evaluating the data:

https://github.com/opendata-stuttgart/madavi-api/blob/master/data_simple.php

This saves the supplied data in a daily .csv file. The data is delivered in .json format and not in $ _post format! This script can also be used to store in a separate database (self-program).

Issue # 69 gives more hints and code examples for PHP:
https://github.com/opendata-stuttgart/meta/issues/69#issuecomment-314222830

Another example: a Python script as Systemd Service receives the data and sends it to Domoticz:
https://github.com/joba-1/airrohr2domoticz

InfluxDB

InfluxDB is a special database for time-based measurements or events. If there is a separate InfluxDB server, the sensor data can also be sent directly to it. The pre-settings must be adjusted accordingly for your own application. (Server, port, path, user) In this case, the server only the address without additions such as HTTP or HTTPS must be entered, the latter is anyway not supported.
More information about InfluxDB
https://www.influxdata.com/   

More detailed description

For the NodeMCU, the chipID is used as the ID. For other systems, X-Sensor is composed of a name for the system (e.g., raspi for Raspberry) and a unique ID (Raspberry: Serial in / proc / cpuinfo).

Example POST for SDS011:

Header

Content-Type: application / json  
X-Pin: 1  
X-sensor: esp8266-12345678  

Data

  {
    "software_version": "your_version",
    "sensordatavalues": [
      {
       "value_type": "P1", 
       "value": "66.04"
      }, 
      {
      "value_type": "P2", 
      "value": "53.32"
      }
    ]
  }  

Example POST for DHT22:

Header

Content-Type: application / json    
X-Pin: 7  
X-sensor: esp8266-12345678  

Data

  { 
    "software_version": "your_version", 
    "sensordatavalues": [
      {
       "value_type": "temperature",
       "value": "22.30" 
      }, 
     {
     "value_type": "humidity", 
     "value": "34.70" 
    }
   ] 
 }

Other sensors:

  • BMP180: value_types: temperature, pressure; X-Pin: 3
  • BME280: value_types: temperature, humidity, pressure; X-pin: 11
  • PMS1003 - PMS 7003: value_types: P1 (PM10), P2 (PM2.5); X-Pin: 1

The address of the API endpoint to deliver the data is http://api.sensors.africa/v1/push-sensor-data/   

Accessing API Data

Interactive documentation:

Endpoints


  NOTE: *[WIP]* Is not in production but may be working in staging.

We have some 'API' endpoints to access the sensor data. The data is saved once a minute due to performance reasons:

V1

http://api.sensors.africa/v1/now/ - all measurements of the last 5 minutes for all publicly accessible sensors

[WIP] http://api.sensors.africa/v1/data/ - all measurements for all publicly accessible sensors in our database

http://api.sensors.africa/v1/sensor/{sensor_id}/ - all measurements of the last 5 minutes for one sensor

http://api.sensors.africa/v1/filter?city=&country=&type= - 5 minutes filtered by query:

  • city = {sensor type}: comma separated list of cities, i.e. Nairobi, Lagos
  • country = {country code}: i.e. KE, TZ, NG, ZA, ...,
  • type = {sensor type}: comma separated list of sensor types, i.e. SDS011, BME280

V2

https://api.sensors.africa/v2/cities - get all supported cities

https://api.sensors.africa/v2/data/air - get average, min and max for air data for all cities

  • city = {city slug}: filter city using slug e.g. dar-es-salaam. Example
  • from = {YYYY-mm-dd}: filter results from date. Example
  • to = {YYYY-mm-dd} : filter results to date which must be provided with from. Example
  • value_type = {sensor value type}:comma separated list of value types P1, P2, temperature, humidity. Example

https://api.sensors.africa/static/v2/data.json - average of all measurements per sensor of the last 5 minutes for all sensors

https://api.sensors.africa/static/v2/data.1h.json - average of all measurements per sensor of the last hour

https://api.sensors.africa/static/v2/data.24h.json - average of all measurements per sensor of the 24 hours

https://api.sensors.africa/static/v2/data.dust.min.json - same as data.json but dust sensors only

https://api.sensors.africa/static/v2/data.temp.min.json - same as data.json but temp./humidity/air pressure sensors only