Box IO

Self-hosted IoT for Arduino and ESP32.

Graph

A line graph of one or more virtual pins. The server stores the readings, and the graph can show live data or a past day, week, or month.

Sample pin: V4 and 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 Graph.
  4. Assign the project device key, or set Device on this widget.
  5. Use Add pin for each virtual pin you want on the chart. Each row is a pin number, a name, and a color. Remove drops one pin. The graph holds up to 16 pins.
  6. Set Store a reading to one per second, one per minute, or one per hour. One per second is kept 31 days. One per minute is kept 400 days. One per hour is kept 5 years. A new reading in the same period replaces the earlier one.
  7. Set Live view to the window shown while Live is selected: 1 minute, 15 minutes, 1 hour, 6 hours, 1 day, 1 week, or 1 month.
  8. Save the layout. Until you save, the server does not store these pins.
  9. Open Live. Live follows the window you chose and draws stored readings through the current time. The line starts on the left at the value already in effect, and it ends on the value the pin holds now, the same value a meter on that pin shows. If the first stored reading is later than the start of that window, the chart starts at the first reading so the line fills the graph. On 1 minute the window keeps sliding once the line reaches the left side, instead of clearing and drawing again from the right. Day shows 24 hours from the date and time you pick. Week shows the Monday-to-Monday week of that date. Month shows that calendar month. Prev and Next move the date.
  10. Turn on Time scale to label the bottom with the clock or the date. Turn on Horizontal data scale to draw horizontal lines and the values they mark. Both stay off until you turn them on. The line fills the widget when you resize it.
  11. Set Font size to change the caption, the buttons, the pin names, and both scales together. Leave it blank to keep the usual small type.
  12. In Live, click or tap the plot to zoom in around that spot. Each click shows half the time and half the value range, centered where you clicked, until the window is about two seconds wide. Reset zoom returns to the full Live, Day, Week, or Month window. Changing those controls also clears the zoom.
  13. 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
sampleEveryDashboardsecond, minute, or hourminuteHow often a reading is stored for every pin on this graph.
liveSpanDashboardminute, 15m, hour, 6h, day, week, or monthhourHow far back the Live button looks.
showTimeScaleDashboardOn or offoffLabels along the bottom for the time window.
showDataScaleDashboardOn or offoffHorizontal lines labeled with the data values.
graphSeriesDashboardPin, name, and color rowsV4 Temp, V5 HumThe virtual pins drawn on the chart. Each pin is stored on the device key for this widget.
labelDashboard or sketchPlain textPumpCaption above the widget, taken from the label saved on that widget. Live shows that caption only. Edit also shows the pin and the device name. A sketch setProperty for label does not rename it. 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. On a graph this sizes the caption, the buttons, the pin names, and the time and value scales.
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.setTimer(1000, sendTemp);
  BoxIO.setTimer(1000, sendHum);
}

void loop() {
  BoxIO.run();

}

void sendTemp() {
  BoxIO.virtualWrite(V4, analogRead(34));
}

void sendHum() {
  BoxIO.virtualWrite(V5, analogRead(35));
}

What you should see

After you save the layout, each virtualWrite on those pins leaves one reading at the rate you set. Live shows those stored readings through the current time. The line begins at the value already in effect and ends on the value the pin holds now. A shorter history fills the chart from the first stored reading. Day, Week, and Month show the stored readings for the date you pick.