Bar meter
A vertical bar from min to max. Same color rules as the circle meter. The sketch publishes the number.
Set it up on the server
- Sign in to the Box IO dashboard and open the project that uses this device key.
- Turn on Edit.
- In Edit, add Bar meter.
- Set Virtual pin to
3. - Set Min and Max. The sample below is 10 to 90.
- Choose Color by and set the color stops.
- Save the layout, then open Live. Drag the corner handle if you want a taller bar. The gauge scales with the box.
- Flash the sketch below with the same device key, host, and port
5923. KeepBoxIO.run()inloop().
Properties
Sketch values are always strings, including numbers: BoxIO.setProperty(V2, "max", "200").
| Property | Where to set it | Format | Example | Effect |
|---|---|---|---|---|
min | Dashboard or sketch | Number | 0 | Low end of the gauge. |
max | Dashboard or sketch | Number | 200 | High end of the gauge. The arc or bar is the span from min to max. |
color | Dashboard or sketch | #RRGGBB | #2ee0c5 | Color used when no color stop matches. |
colorMode | Dashboard or sketch | percentage or values | percentage | percentage compares stops to 0–100 percent of the min/max span. values compares stops to the raw number. |
colorStops | Dashboard or sketch | at:#hex joined by semicolons | 0:#2ee0c5;60:#f5b942;85:#ff5d73 | The highest stop that is still at or below the reading wins. In percentage mode, 60 means 60 percent. In values mode, 60 means the number 60. |
label | Dashboard or sketch | Plain text | Pump | Caption above the widget. On a round or oval button this is the caption, not the word on the button face. |
hideLabel | Dashboard | On or off | checked | Hides the caption. Button face text, meter numbers, and label text stay visible. |
fontSize | Dashboard | Whole number 8 to 160, or blank for automatic size | 28 | Text size in pixels inside the widget. |
opacity | Dashboard | 10% to 100% | 70% | Lets an overlapping widget show through. 100% is solid. |
Formatting
- Color stops use the same string as the circle meter:
0:#2ee0c5;60:#f5b942;85:#ff5d73. colorModeispercentageorvalues. Percentage means the stop numbers are 0–100 percent of the distance from min to max.- A reading below min shows an empty bar. A reading above max fills the bar.
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);
BoxIO.setProperty(V3, "label", "Bar Lab");
BoxIO.setProperty(V3, "min", "10");
BoxIO.setProperty(V3, "max", "90");
BoxIO.setProperty(V3, "color", "#7aa2ff");
BoxIO.setProperty(V3, "colorMode", "percentage");
BoxIO.setProperty(V3, "colorStops", "0:#2ee0c5;60:#f5b942;85:#ff5d73");
BoxIO.virtualWrite(V3, 40);
}
void loop() {
BoxIO.run();
static uint32_t last = 0;
if (millis() - last < 1000) return;
last = millis();
static int n = 0;
n = (n + 3) % 80;
BoxIO.virtualWrite(V3, 10 + n);
}
What you should see
The bar grows from the bottom. At about 85 percent of the 10–90 range the color is the last stop.