Quickstart -> Datapoints

Now that we have the devices setup, let's get them to send datapoints. We have two schemas for datapoints, one for environmental metrics, and the other is the telemetry drones should send.

Imagine that we have the hardware for each of these built, and they collect the telemetry fields that we have added to our packet schemas.

Sending Datapoints

Sending datapoints is quite straightforward and similar to sending heartbeats. The only difference is that you just need to provide a JSON object body, and the correct Content-Type header.

As in the previous section, we'll use HTTP to demonstrate that you can easily send a datapoint reading to Fostrom, but you can also use persistent MQTT connections from your device code. Note that Fostrom requires TLS for both HTTP and MQTT.

curl https://device.fostrom.dev/v1/datapoint/environment-metrics \
  -XPOST \
  -d '{"temperature": 22.53, "humidity": 70, "aqi_ok": true}' \
  -H 'Content-Type: application/json' \
  -H 'X-Fleet-ID: <your-fleet-id>' \
  -H 'X-Device-ID: <your-device-id>' \
  -H 'X-Device-Secret: <your-device-secret>'

You should get the following response:

{"ok": true}

You can head over to the Packets tab in your fleet, and you should see this new packet arrive shortly.

A few things to note above are:

  • The packet schema name is provided in the URL: /v1/datapoint/:packet_schema_name
  • Whenever you're sending a body with your HTTP request, you need to send Content-Type: application/json. The body should be a valid JSON object.

Sending the Drone Telemetry datapoint is similar. Go ahead and try it yourself.

Now that we can send datapoints from devices to Fostrom, the next step is sending messages, which is also very similar to sending datapoints. Before we do that though, let's take a short detour and setup an Action to open and close the gates based on incoming messages from the drones.