Skip to content

Campbell Stations

Station Fields

To create a Campbell station you must include the following fields in your post:

  • name: String that can be from 2 - 100 characters in length.
  • code: String 4 - 20 characters in length which is used as a unique identifier for the station and/or data logger. The 'code' property is the same as the 'sui' in the config packet and these fields can be used interchangeably.
  • reporting: Number which should be set to the number of seconds of the reporting interval. Valid range for reporting interval are 120 seconds to 86400 seconds
  • ref_logger_id: Number to identify the station type. The ref_logger_id for the Campbell station type is 16.

Optionally you can include the following additional fields in your post

  • status: Boolean that should be set to 0 or 1 and controls whether the station is active or inactive. If not set status will default to 1 (active).
  • location: String for the station's location that can be from 2 to 255 characters in length
  • latitude: String for the station's latitude coordinate. If not present latitude will default to "0.000000". Valid range for latitude is -90 to 90.
  • longitude: String for the station's longitude coordinate. If not present longitude will default to "0.000000". Valid range for longitude is -180 to 180.

Creating a Station

POST route:

http://api.stevens-connect.com/project/<projectId>/station

Station POST Example

Your request must include your JWT token which would look like the following using curl:

curl -H 'Authorization: bearer eyJ0eXAiOiJK...'

Next it should include the configuration data:

-d "name=StationName&ref_logger_id=16&code=CRXXX_XXXXXX&reporting=3600"

Lastly it must include the post route where 'xxx' represents your project ID:

-X POST http://api.stevens-connect.com/project/xxx/station

Here is the full curl example:

curl -H 'Authorization: bearer eyJ0eXAiOiJK...' -d "name=StationName&ref_logger_id=16&code=CRXXX_XXXXXX&reporting=3600" -X POST http://api.stevens-connect.com/project/xxx/station

A successful POST will return the following response:

{
    "errors": false,
    "data": {
        "station": {
            "id": 1192,
            "project_id": 216,
            "code": "CRXXX_XXXXXX",
            "name": "api_test",
            "location": "",
            "latitude": "0.000000",
            "longitude": "0.000000",
            "battery_reading": null,
            "is_public": 0,
            "ref_logger_id": 16,
            "firmware_version": null,
            "board_rev": "",
            "support_add_m": 0,
            "reporting": 3600,
            "status": 1,
            "warmup_delay": 0,
            "last_reported": null,
            "last_reported_utc": null,
            "timezone": "+0000",
            "timezone_name": "",
            "is_published": 0,
            "low_power_mode": null,
            "etracker_sdi12_logging": null,
            "sensors": [
                {
                    "id": 0000,
                    "station_id": 0000,
                    "name": "Parameters",
                    "status": 1,
                    "reporting": 3600,
                    "logging": 3600,
                    "type": 6,
                    "current": 0,
                    "analog_low": 0,
                    "analog_high": 0,
                    "analog_voltage_low": 0,
                    "analog_voltage_high": 0,
                    "address": "0",
                    "analog_warmup": 0,
                    "code": "Cellnet Sensor",
                    "latitude": "0.000000",
                    "longitude": "0.000000",
                    "channels": []
                }
            ]
        }
    }
}

Updating a Station

All of the fields listed above for Creating a Station can be updated.

PATCH route:

http://api.stevens-connect.com/project/<projectId>/station/<stationId>

Example for updating a Campbell station's name and reporting interval:

curl -H 'Authorization: bearer eyJ0eXAiOiJK...' -d "name=NewStationName&reporting=7200" -X PATCH http://api.stevens-connect.com/project/xxx/station/xxx

Deleting a Station

DELETE route:

http://api.stevens-connect.com/project/<projectId>/station/<stationId>

Example for deleting a Campbell station:

curl -H 'Authorization: bearer eyJ0eXAiOiJK...' -X DELETE http://api.stevens-connect.com/project/xxx/station/xxx

Creating a Sensor Parameter

When you create your Campbell station a default sensor is created. All parameters will be added to your default sensor. The sensor id can be found in the station POST response or in the Configuration Object. To create a sensor parameter the following fields should be included in your post:

  • name: String that can be from 2 - 100 characters in length
  • scale: Number which should be set to 1 unless the parameter value needs to be scaled for calibration purposes
  • offset: Number which should be set to 0 unless the parameter value needs to be offset for calibration purposes
  • unit_id: Number that corresponds with the desired unit's id which can be found in the Configuration Packet Getting the Configuration Packet
  • code: Number that should be set based on the order that it will be listed in the reporting response object. The first parameter's code should be set to 0 and subsequent code's should increment e.g. 1,2,3...
  • status: Can be set to 0 or 1 and controls whether the parameter is active or inactive

POST route:

http://api.stevens-connect.com/project/xxx/station/xxx/sensor/xxx/channel

Your POST request will follow the same format as the station POST Example. Here's an example for posting a parameter where 'xxx' represents your station/sensor/channel IDs:

curl -H 'Authorization: bearer BLbAqi7AmIrUP0...' -d "name=ParamName&scale=1&offset=0&unit_id=1&code=0" -X POST http://api.stevens-connect.com/project/xxx/station/xxx/sensor/xxx/channel

A successful POST will return the following response:

{
    "errors":false,
    "data": {
        "channel": {
            "scale": "1.000000",
            "offset": "0.000000",
            "unit_id": 1,
            "logging": 0,
            "m_source": 0,
            "status": 1,
            "warehouse_table_id": 0,
            "name": "Param1",
            "code": "0",
            "sensor_id": "4238",
            "id": 13990
        }
    }
}

Updating a Sensor Parameter

All fields are optional for updates. All of the fields listed above for creating a sensor parameter can be updated as well as the following fields:

PATCH route:

http://api.stevens-connect.com/project/<projectId>/station/<stationId>/sensor/<SensorId>/channel/<ChannelId>

Example for patching a Campbell parameter where 'xxx' represents your station/sensor/channel IDs:

curl -H 'Authorization: bearer eyJ0eXAiOiJK.....' -d "name=SensorName" -X PATCH http://api.stevens-connect.com/project/xxx/station/xxx/sensor/xxx/channel/xxx

Deleting a Sensor Parameter

DELETE route:

http://api.stevens-connect.com/project/<projectId>/station/<stationId>/sensor/<sensorId>/channel/<channelId>

Example for deleting a parameter where 'xxx' represents your station/sensor/channel IDs:

curl -H 'Authorization: bearer eyJ0eXAiOiJK.....' -X DELETE http://api.stevens-connect.com/project/xxx/station/xxx/sensor/xxx/channel/xxx