Box IO

Self-hosted IoT for Arduino and ESP32.

Webhook

When the sketch virtualWrites this pin, the Box IO server calls a URL. Dashboard edits do not fire it. Comma-separated fields fill the data template.

Sample pin: V11

Set it up on the server

  1. Sign in to the Box IO dashboard and open the project that uses this device key.
  2. Turn on Edit.
  3. In Edit, add Webhook.
  4. Set Virtual pin to 11. The device on the widget, or the project device, must be the device key in the sketch.
  5. Set URL to an http or https address. The server must be able to reach it.
  6. Set Method to GET, POST, or PUT.
  7. Set Content type to one of application/json, text/plain, or application/x-www-form-urlencoded.
  8. Set Data using {1}, {2}, and {value}.
  9. Save the layout. The call happens only after a device virtualWrite. The widget shows the pin value and a status such as 204 POST.
  10. Flash the sketch below with the same device key, host, and port 5923. Keep BoxIO.run() in loop().

Properties

Sketch values are always strings, including numbers: BoxIO.setProperty(V2, "max", "200").

PropertyWhere to set itFormatExampleEffect
urlDashboardhttp or https URL, 2000 characters maxhttps://example.com/hookPlaceholders in the URL are URL-encoded. <code>{1}</code> in the URL is the first field.
methodDashboardGET, POST, or PUTPOSTGET puts Data on the URL and sends no body. POST and PUT send Data as the body.
contentTypeDashboardOne of the three types belowapplication/jsonChooses how inserted values are escaped and which Content-Type header is sent.
dataDashboardTemplate, 8000 characters max{"temp":"{1}","room":"{2}"}<code>{1}</code> is the first comma field, <code>{2}</code> the second, and <code>{value}</code> is the whole virtualWrite string. Fields are trimmed.
labelDashboard or sketchPlain textPumpCaption above the widget. On a round or oval button this is the caption, not the word on the button face.
hideLabelDashboardOn or offcheckedHides the caption. Button face text, meter numbers, and label text stay visible.
fontSizeDashboardWhole number 8 to 160, or blank for automatic size28Text size in pixels inside the widget.
opacityDashboard10% to 100%70%Lets an overlapping widget show through. 100% is solid.

Formatting

Sketch

Paste the device key over bx_paste_your_device_key_here. Wi-Fi boards include BoxIOEsp32.h. Ethernet boards use the same calls with an EthernetClient.

#define BOXIO_AUTH "bx_paste_your_device_key_here"
#define WIFI_SSID  "your-ssid"
#define WIFI_PASS  "your-password"
#define BOXIO_HOST "boxio.krmsproducts.net"
#define BOXIO_PORT 5923

#include <BoxIOEsp32.h>

void setup() {
  BoxIO.begin(BOXIO_AUTH, WIFI_SSID, WIFI_PASS, BOXIO_HOST, BOXIO_PORT);
// Dashboard data for JSON:
  // {"temp":"{1}","room":"{2}"}
  // Form data instead:
  // temp={1}&room={2}
}

void loop() {
  BoxIO.run();
static uint32_t last = 0;
  if (millis() - last < 5000) return;
  last = millis();
  BoxIO.virtualWrite(V11, "72,north room");
}

What you should see

After the virtualWrite, the widget leaves “Waiting for virtualWrite” and shows 72,north room plus the HTTP status. A button click on a different widget does not call this URL. The call is only from virtualWrite on V11.