Box IO

Self-hosted IoT for Arduino and ESP32.

Round button

A round on/off button. The caption is the label. The word on the face is textOn or textOff. A click sends the on or off value to the sketch.

Sample pin: V6

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 Round button.
  4. Set Virtual pin to 6.
  5. Label is the caption above the button. On text and Off text are the words on the face.
  6. Set Value sent when on and Value sent when off. The sample uses go and 0.
  7. Set the two background colors and the two text colors.
  8. Save the layout, then open Live and click the button.
  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
labelDashboard or sketchPlain textRoundCaption above the button. This is not the word drawn on the face.
textOnDashboard or sketchPlain textGoWord on the face while the pin equals the on value.
textOffDashboard or sketchPlain textIdleWord on the face while the pin equals the off value.
onValueDashboard or sketchExact text the pin must matchgoClicking the button while it is off sends this string to the device.
offValueDashboard or sketchExact text the pin must match0Clicking the button while it is on sends this string. Default is 0.
sendValueDashboard or sketchSame text as onValuegoOlder name for the on value. If onValue is empty, sendValue is used.
colorOnDashboard or sketch#RRGGBB#2ee0c5Face background when on.
colorOffDashboard or sketch#RRGGBB#314057Face background when off.
textColorOnDashboard or sketch#RRGGBB#071018Face text color when on.
textColorOffDashboard or sketch#RRGGBB#e8eef8Face text color when off.
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(V6, "label", "Round");
  BoxIO.setProperty(V6, "textOn", "Go");
  BoxIO.setProperty(V6, "textOff", "Idle");
  BoxIO.setProperty(V6, "onValue", "go");
  BoxIO.setProperty(V6, "offValue", "0");
  BoxIO.setProperty(V6, "sendValue", "go");
  BoxIO.setProperty(V6, "colorOn", "#2ee0c5");
  BoxIO.setProperty(V6, "colorOff", "#314057");
  BoxIO.setProperty(V6, "textColorOn", "#071018");
  BoxIO.setProperty(V6, "textColorOff", "#e8eef8");
}

void loop() {
  BoxIO.run();

}

BOX_WRITE(V6) {
  if (String(param.asStr()) == "go") {
    digitalWrite(2, HIGH);
  } else {
    digitalWrite(2, LOW);
  }
}

What you should see

The caption reads Round. The face reads Go while the pin is go, and Idle while the pin is 0. Clicking sends go or 0 to BOX_WRITE(V6). If the face always says Go, the sketch is still sending textOn on boot.