Overview

The Farm21 import function (<importType>Farm21</importType>) imports data from the Farm21 API. (since 2021.01).

See also: https://www.farm21.tech/field-sensor


Example JSON file

2020102313_FORECAST_CONTROL-C1E_ctrl_Stations_control.json
[
  {
    "name": "Test sensor 1",
    "id": 1450,
    "readings": [
      {
        "soil_moisture_10": 11.6,
        "soil_moisture_20": 16.8,
        "soil_moisture_30": 18.9,
        "soil_temperature": 11,
        "humidity": 67.2,
        "air_temperature": 10,
        "crop_type": null,
        "race_type": null,
        "cultivation_type": null,
        "latitude": 0,
        "longitude": 0,
        "measured_at": "2020-10-29T15:46:28.000000Z",
        "id": 1804953
      }
    ]
  }
]


Location ids

Each sensor has a unique id. It can be retrieved from the GUI (https://www.farm21.tech/field-sensor) in the groups and sensors when clicking on the sensor id. This is the id the FEWS location id should be mapped to with id mapping.


Group ids

Sensor are grouped. The id of a group can be found when clicking on the group edit functionality.

Mapped json fields

From the json fields, the following parts will be mapped to FEWS:

  • id: locationId
  • readings: events

  • reading.soil_moisture_10: value of the soil moisture 10 parameter.
  • reading.soil_moisture_20: value of the soil moisture 20 parameter.
  • reading.soil_moisture_30: value of the soil moisture 30 parameter.
  • reading.soil_temperature: value of the soil temperature parameter.
  • reading.humidity: value of the humidity parameter.
  • reading.air_temperature: value of the air temperature parameter.

Configuring the Import

De import type and have to be configured in the Import Configuration. A basic example where one location and parameter are imported can be seen in the following XML configuration. 

For the password a key has to be generated using the portal of Farm21. 

To get all sensor data for an organization, specify the server url as follows:

 <serverUrl>https://app.farm21.tech/api/public/beta</serverUrl>

It is also possible to specify a specific group id to import only sensors that are part of that group. The group id is available in the portal. The groupid is part of the configured URL and should be changed to the group id to be used. See the serverUrl in the following example where the group id is 668.

<serverUrl>https://app.farm21.tech/api/public/beta/v2/groups/668/data</serverUrl>

For a complete example of the import configuration, see the following example:

Import Configuration
<?xml version="1.0" encoding="UTF-8"?>
<timeSeriesImportRun xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/timeSeriesImportRun.xsd">
	<import>		
		<general>
	        <importType>Farm21</importType>
    	    <serverUrl>https://app.farm21.tech/api/public/beta/v2/groups/668/data</serverUrl>
	        <user>Bearer</user>
	        <password>$FARM21_API_KEY$</password>
	        <relativeViewPeriod unit="hour" start="-120" end="0" startOverrulable="true"/>
	        <idMapId>IdImportFarm21</idMapId>
	        <dataFeedId>Farm21</dataFeedId>
		</general>
		<timeSeriesSet>
			<moduleInstanceId>Import_Farm21</moduleInstanceId>
            <valueType>scalar</valueType>
            <parameterId>soil_moisture_10</parameterId>
            <locationId>1450</locationId>
            <timeSeriesType>external historical</timeSeriesType>
            <timeStep unit="nonequidistant" />
            <readWriteMode>add originals</readWriteMode>
		</timeSeriesSet>
		</import>
</timeSeriesImportRun>


  • No labels