Docs

Vertical Level

The Vertical Level widget shows a value as a column that fills from the bottom. It is the Level Display turned upright.

Use it when the thing you measure is upright too: a tank, a silo, a rain gauge, a battery in a stack of readings.

SettingWhat it does
Pinthe virtual pin your code writes to
Min, Maxthe values for empty and full
Colourthe fill colour
Show valueprint the number over the column

Open these from the canvas: tap Edit, then long press the widget and choose Configure.

Example

A rainwater tank reported every minute.

vertical-level-display.ino
#include <PlynxSimpleEsp32.h>

#define LEVEL_PIN 34
#define FULL_READING 3200             // ADC value with the tank full

PlynxTimer timer;

void sendLevel()
{
  int raw = analogRead(LEVEL_PIN);
  float percent = raw * 100.0 / FULL_READING;

  Plynx.virtualWrite(V32, constrain(percent, 0, 100));
}

void setup()
{
  Serial.begin(115200);

  // Auto setup: WiFi and the Plynx token are configured from the app.
  //
  // To provide them directly in the sketch instead, use:
  //   Plynx.begin(auth, ssid, pass);
  Plynx.begin();

  timer.setInterval(60000L, sendLevel);
}

void loop()
{
  Plynx.run();
  timer.run();
}

Calibrate FULL_READING with the tank actually full, and print the raw value to the serial monitor while you do it. A number copied from a datasheet rarely matches the sensor on your bench.

Troubleshooting

ProblemCheck
Column never fillsFULL_READING is higher than the sensor ever reads
Column is always fullthe widget Max is lower than the values you send
Readings drift with the weatherADC reference changes with temperature; average over time

Next