Circle meter
A gauge arc from a start degree to an end degree. 0 is straight up and degrees go clockwise. The default runs from the lower left to the lower right.
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 Circle meter.
- Set Virtual pin to
2. - Set Min and Max to the same range the sketch will send. The sample below is 0 to 200.
- Set Start and End in degrees, from 0 to 360. 0 is straight up. 90 is the right, 180 is the bottom, and 270 is the left. The colored arc travels clockwise from Start to End.
- Leave Start at
225and End at135for a normal gauge: it begins at the lower left and ends at the lower right. Set both to the same number, or use 0 and 360, for a full circle. - Choose Color by. Percentage of max uses 0–100. Raw data values uses the number itself.
- Use Add division and Remove under Color by. One division is a single color for the whole gauge. Fifteen is the most. With two or more, the number beside each color is the point where that color starts.
- Save the layout, then open Live.
- 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 |
|---|---|---|---|---|
startDeg | Dashboard or sketch | Degrees, 0 to 360 | 225 | Where the minimum sits. 0 is straight up and degrees go clockwise. 225 is the lower left. |
endDeg | Dashboard or sketch | Degrees, 0 to 360 | 135 | Where the maximum sits. 135 is the lower right. The fill travels clockwise from startDeg to endDeg. |
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
- Start 225 and end 135 sweep clockwise across the top, from the lower left to the lower right. That is about 270 degrees of arc, with the gap at the bottom.
- The same start and end, or start 0 and end 360, draw a full circle. The fill still begins at Start.
- The dashboard holds 1 to 15 color divisions. One division paints the gauge in that color. Extra divisions change the color when the reading reaches each number.
- Sketch color stops are one string:
at:#hexpieces joined by;. No spaces are required. Example:0:#2ee0c5;50:#f5b942;100:#ff5d73. - With colorMode
percentageand min 0 max 200, a reading of 100 is 50 percent, so the 50 stop is the one that applies. - With colorMode
values, a stop of 50 matches the raw reading 50, not 50 percent. - The number in the middle is the raw reading. Whole numbers print as integers. Other numbers print with one decimal.
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(V2, "label", "Circle Lab");
BoxIO.setProperty(V2, "min", "0");
BoxIO.setProperty(V2, "max", "200");
BoxIO.setProperty(V2, "startDeg", "225");
BoxIO.setProperty(V2, "endDeg", "135");
BoxIO.setProperty(V2, "color", "#2ee0c5");
BoxIO.setProperty(V2, "colorMode", "values");
BoxIO.setProperty(V2, "colorStops", "0:#2ee0c5;50:#f5b942;100:#ff5d73");
BoxIO.virtualWrite(V2, 72);
}
void loop() {
BoxIO.run();
static uint32_t last = 0;
if (millis() - last < 1000) return;
last = millis();
static int n = 0;
n = (n + 3) % 180;
BoxIO.virtualWrite(V2, n);
}
What you should see
The arc starts at the lower left and fills clockwise toward the lower right as the number climbs. The color changes when the reading passes a stop. A sketch setProperty for startDeg, endDeg, min, max, or colorStops replaces the dashboard value until you edit that field again.