Base de données environnementales
Structuration des données environnementales
Voilà les données renseignées dans la base de données opensensemap https://docs.opensensemap.org/#api-Measurements
A priori la variable physico-chimique mesurée est renseignée dans le champ "phenomenon"
https://docs.opensensemap.org/#api-Measurements-getDataMulti
Et chaque "sensor" mesure un "phenomenon" renseigné dans le champ "title"
https://docs.opensensemap.org/#api-Measurements-getLatestMeasurementOfSensor
Bref toute la réflexion qu'on pensait devoir avoir sur la structuration des données environnementales mesurées dans une base est dispo dans cette doc'. Y'a qu'à rejoindre le projet SenseBox / OpenSensemap je dirais. Et exploiter les résultats pour valider les modèles de Roland. On peut éventuellement créer notre propre "SenseBox" si les leur ne répondent pas à notre cahier des charges (type et qualité des données valeurs mesurées).
Publier les données d'un ESP32 vers OpenSenseMap via MQTT
https://edu.books.sensebox.de/en/
- On peut envoyer des données vers les serveurs openSenseMap en publiant des messages MQTT au format
.json
(array ou object) ou.csv
sur un broker (serveur MQTT) public - La documentation de l'API MQTT se trouve là : https://docs.opensensemap.org/#api-Boxes-postNewBox
Publication en MQTT
- Le paramètre
messageFormat
spécifie à l'API sous quel format les mesures sont envoyées. - Un maximum de 2500 valeurs peuvent être envoyées à la fois (Maximum count of values)
- Les formats acceptés sont listés dans Measurements/Post mutliple new Measurements
Pour le csv
- Envoyer d'abord un header
content-type: text/csv
- Puis envoyer une valeur par ligne au format
sensorId,value,[createdAt]
(pas de header,[createdAt]
est un timestamp optionnel au format RFC 3339)
sensorID,value
anotherSensorId,value,RFC 3339-timestamp
sensorIDtheThird,value
anotherSensorId,value,RFC 3339-timestamp,longitude,latitude
anotherSensorId,value,RFC 3339-timestamp,longitude,latitude,height
...
Pour le JSON
- JSON Array
- objects with the keys sensor, value and optionally createdAt and location
- Specify the header
content-type: application/json
- If Location Values are posted, the Timestamp becomes obligatory
[
{"sensor":"sensorID", "value":"value"},
{"sensor":"anotherSensorId", "value":"value", "createdAt": "RFC 3339-timestamp", "location": [lng,lat,height]}
...
]
- JSON Object :
- the keys of the object are the sensorIds
- the values of the object are either
- just the
value
of your measurement - or an array of the form
[value, createdAt, location]
.createdAt
andlocation
values are optional.
- just the
{
"sensorID": "value",
"anotherSensorID": ["value"]
"sensorID3": ["value", "createdAt as RFC 3339-timestamp"],
"sensorID4": ["value", "createdAt as RFC 3339-timestamp", "location latlng-object or array"],
}
Header
Champ | Type | Description |
---|---|---|
Authorization | String |
Box' unique access_token. Will be used as authorization token if box has auth enabled (e.g. useAuth: true) |
Paramètres pour la communication des mesures
Champ | Type | Description |
---|---|---|
luftdatenoptionnel | String |
Specify whatever you want (like |
hackairoptionnel | String |
Specify whatever you want (like |
senseBoxId | String |
the ID of the senseBox you are referring to. |
- Standard de format
jsonJSON (Object) par luftdaten.info
The API now tries to convert the JSON objects
in the sensordatavalues
key to the openSenseMap JSON Array format. Sensors are matched by the key value_type
against the title
of the sensors of this box. SDS_P1
matches sensors with title PM10
, SDS_P2
matches sensors with title PM2.5
. You can find all matchings in the source code of the openSenseMap-API (lib/decoding/luftdatenHandler.js
)
{
"sensordatavalues": [
{
"value_type": "SDS_P1",
"value": "5.38"
},
{
"value_type": "SDS_P2",
"value": "4.98"
}
]
}
- Standard de format
jsonJSON (Values) parhackairhackAIR
The API now tries to convert the JSON values
in the reading
key to the openSenseMap JSON Array format. Sensors are matched by the key sensor_description
against the title
of the sensors of this box. PM2.5_AirPollutantValue
matches sensors with title PM2.5
, PM10_AirPollutantValue
matches sensors with title PM10
. You can find all matchings in the source code of the openSenseMap-API (lib/decoding/hackAirHandler.js
)
{
"reading": {
"PM2.5_AirPollutantValue": "7.93",
"PM10_AirPollutantValue": "32.63"
},
"battery": "5.99",
"tamper": "0",
"error": "4"
}
Formats acceptés pour la localisation
Champ | Type | Description |
---|---|---|
lat | Number |
Latitude between -90 and 90 |
lng | Number |
Longitude between -180 and 180 |
heightoptionnel | Number |
Height above ground in meters. |
- Location Object
{ "lng": 7.684, "lat": 51.972, "height": 66.6 }
- Location Array
[7.684, 51.972, 66.6]
Paramètres pour une senseBox connectée via MQTT
Champ | Type | Description |
---|---|---|
enabled | Boolean |
enable or disable mqtt Valeur par défaut : |
url | String |
the url to the mqtt server. |
topic | String |
the topic to subscribe to. |
messageFormat | String |
the format the mqtt messages are in. Valeurs autorisées : |
decodeOptions | String |
a json encoded string with options for decoding the message. 'jsonPath' for 'json' messageFormat. |
connectionOptions | String |
a json encoded string with options to supply to the mqtt client (https://github.com/mqttjs/MQTT.js#client) |
Ressources
https://www.urbanheatislands.com/uhi-web-maps
Projet Capt'air : https://wp.unil.ch/captographies/