Box IO

Self-hosted IoT for Arduino and ESP32.

Grid

A table of cells on one virtual pin. The sketch sends a comma-separated list, row by row. Color rules paint cells from those numbers.

Sample pin: V5

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 Grid.
  4. Set Virtual pin to 5.
  5. Set Rows and Columns. Both must be from 1 to 16. A 2 by 2 grid has 4 cells.
  6. Choose Read only, or Read and write if the dashboard should send edits back to the sketch.
  7. Set the default cell color, then add color rules. Each rule has a low, a high, a color, and either all cells or certain cell numbers.
  8. Save the layout, then open Live.
  9. 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
rowsDashboard or sketchWhole number 1 to 162Row count. A sketch setProperty replaces the dashboard size.
colsDashboard or sketchWhole number 1 to 162Column count.
modeDashboardreadonly or readwritereadonlyRead and write lets a cell edit send the full grid back. The dashboard mode stays in charge when the widget already has one.
colorOffDashboard or sketch#RRGGBB#1a2333Color for a cell whose value is blank or matches no rule.
colorRulesDashboard or sketchlow-high:#hex:cells joined by semicolons0-25:#2ee0c5:all;35-100:#ff5d73:0,1First matching rule wins. cells is the word all, or zero-based indexes separated by commas.
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 "localhost"
#define BOXIO_PORT 5923

#include <BoxIOEsp32.h>

void setup() {
  BoxIO.begin(BOXIO_AUTH, WIFI_SSID, WIFI_PASS, BOXIO_HOST, BOXIO_PORT);
BoxIO.setProperty(V5, "label", "Grid Lab");
  BoxIO.setProperty(V5, "rows", "2");
  BoxIO.setProperty(V5, "cols", "2");
  BoxIO.setProperty(V5, "colorOff", "#1a2333");
  BoxIO.setProperty(V5, "colorRules", "0-25:#2ee0c5:all;35-100:#ff5d73:all");
  int cells[] = {21, 22, 40, 18};
  BoxIO.virtualWrite(V5, cells, 4);
}

void loop() {
  BoxIO.run();
static uint32_t last = 0;
  if (millis() - last < 1000) return;
  last = millis();
  static int n = 0;
  n = (n + 3) % 180;
  int cells[] = {n % 50, 22, 40, 18};
  BoxIO.virtualWrite(V5, cells, 4);
}

BOX_WRITE(V5) {
  // Full CSV when the widget is Read and write.
  Serial.println(param.asStr());
}

What you should see

Four cells appear. Numbers from 0 through 25 are teal. Numbers from 35 through 100 are red. Other numbers keep the default cell color. Switch the widget to Read and write before expecting BOX_WRITE to run.