Sensor data#
If you need to collect sensor data, go to DATA
section in the Admin panel and complete the fields Devices and Sensors (in particular the steps in bold), before Applications .
These two are the instruments that transmit and acquire data.
Then, add the application and define at least the name, the start date, the core device, the sensors, and the field.
NOTE:
the abbreviation (shortname) of Value types must be the same used by the payload formatter of your application
the device name and Uid of Devices must be equal to the ID and the DevEUI of your end device
if your application acquires the same data on multiple levels (for example sensors installed at different depths), specify it in the name of Value types
Data providers#
HTTP API#
DigiAgriApp provide a ReST API to insert data using a HTTP POST request, the payload of the request should be a JSON like this
{
"time": "2024-10-01 10:00",
"field": 1,
"value": 10.8,
"sensor": 2,
"valuetype": 2
}
where field
value should be the ID of the field, sensor
value has to be the ID of the sensor and valuetype
the ID of the type of value observed. You can change field
with subfield
, row
and plant
according to the element that the sensor is connected to. The API end point are api/v1/field-data
, api/v1/subfield-data
, api/v1/row-data
and api/v1/plant-data
again according to the chosen element.
MQTT#
Now that the monitoring station has been registered in the app, you need to enable the MQTT data transmission, there are two ways to set up it:
add a record in the
DATA
->Mqtts
section of the admin panelif you have access to the installation you can edit the
settings.py
file and modify the variables listed below.
The information to add in both cases are the public address, the application name, the username and the MQTT API key (the example below uses The Things Network as system provider).
MQTT_BROKER = 'eu1.cloud.thethings.network'
MQTT_TOPICS = ["v3/first-test-mkr@ttn/devices/+/up"]
MQTT_USER = "first-test-mkr@ttn"
MQTT_PASSWD = "NNSXS.2RK******************************7A"
When the device is properly connected to the running server, data can be visualized in Field values and in charts in the DigiAgriApp multiplatform app.
NOTE
A MQTT broker (provided by the MQTT Mosquitto software) is running within the DigiAgriApp server, so it is able to listen different MQTT topics out of the box.