Circuit background

Deep Dive: Sending Data

Sending Data

There are two ways to send data to Inventronix Connect:

  • Arduino Library - For ESP32/Arduino devices (recommended)
  • HTTP API - For any device or language that can make HTTP requests

Option 1: Arduino Library

The Inventronix Arduino library handles all the complexity for you - HTTP requests, retries, error handling, and command dispatch.

Installation

Arduino IDE:

  • Open the Library Manager (Sketch → Include Library → Manage Libraries)
  • Search for "Inventronix" and click Install
  • Also install ArduinoJson if you don't have it

PlatformIO:

1

Basic Example

1

Specifying a Schema

If you have multiple schemas, tell the library which one to use:

1

Receiving Commands

Commands are automatically received when you call `sendPayload()`. Register handlers in `setup()`:

1

Pulse Commands

For things that should run for a set duration then stop (pumps, buzzers):

1

Or get the duration from the server:

1

Check if a pulse is active:

1

Complete Example: Heating Controller

1

Configuration Options

1

Error Messages

The library provides clear error messages:

  • 400 Bad Request - Payload doesn't match schema
  • 401 Unauthorized - Invalid PROJECTID or APIKEY
  • 429 Rate Limit - Sending too fast (auto-retries)
  • 5xx Server Error - Temporary issue (auto-retries)

Option 2: HTTP API

For non-Arduino devices, or when you want full control.

Endpoint

1

Headers

  • Content-Type (required) - Must be `application/json`
  • X-API-Key (required) - Your project's API key
  • X-Project-ID (required) - Your project ID
  • X-Schema-ID (optional) - Specific schema to validate against

Request Body

JSON object with your data fields:

1

Response

Success (202 Accepted):

1

With pending commands:

1

Validation error (400):

1

Examples

curl:

1

Python:

1

JavaScript (Node.js):

1

MicroPython (ESP32):

1

Rate Limits

Each account has a rate limit of 30 requests per minute, shared across all projects.

If you exceed the limit, you'll get a `429 Too Many Requests` response. Wait a moment and retry.

The Arduino library handles this automatically with exponential backoff.

Handling Commands

Commands are returned in the response to your payload. Your device should:

  • Parse the `commands` array
  • Execute each command
  • Report the new state in your next payload

The command format:

1

  • `execution_id` - Unique ID for this execution (for logging/debugging)
  • `command` - The command name you defined in your action
  • `arguments` - Any arguments from your action configuration

Best Practices

Report Actual State

Always report what's actually happening, not what you think should happen:

1

Handle Sensor Failures

Don't send garbage data if a sensor read fails:

1

Choose Appropriate Intervals

  • 10 seconds - Good for most monitoring
  • 1 minute - Fine for slowly-changing data (room temperature)
  • 1 second - Only if you really need it (uses rate limit quickly)

Secure Your API Key

Never commit your API key to public repositories. Use:

  • Environment variables
  • Separate config file (gitignored)
  • Build-time injection

Next Steps

  • Dashboards - Visualise your data
  • Rules and Actions - Automate responses
  • Debugging - Troubleshoot issues