Docs
Step
The Step widget has a plus and a minus button. Each press changes the value by a fixed amount and sends the result.
Use it when the exact number matters: a thermostat setpoint, a servo angle, a timer length. Dragging a slider to 21.5 is hard, pressing plus twice is not.
| Setting | What it does |
|---|---|
| Pin | the virtual pin your code reads |
| Min, Max | the limits the value stops at |
| Step | how much one press adds or subtracts |
| Loop | wrap around from max back to min |
| Send on release | send once when you lift your finger |
Open these from the canvas: tap Edit, then long press the widget and choose Configure.
Example
A thermostat setpoint on V13, stepping half a degree at a time.
#include <PlynxSimpleEsp32.h>
#define HEATER_PIN 25
float setpoint = 20.0;
PLYNX_WRITE(V13)
{
setpoint = param.asFloat();
}
void setup()
{
Serial.begin(115200);
pinMode(HEATER_PIN, OUTPUT);
// 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();
}
void loop()
{
Plynx.run();
float room = analogRead(34) * (3.3 / 4095.0) * 100.0;
digitalWrite(HEATER_PIN, room < setpoint ? HIGH : LOW);
} Use param.asFloat() when the step is fractional. asInt() truncates 20.5
to 20 and the half degrees disappear.
The widget sends the resulting value, not the amount of the step. Pressing plus
on 20.0 with a step of 0.5 sends 20.5.
Restore the setpoint after a reboot
The board comes back with whatever setpoint starts as in your code, while the
widget still shows the old number. Ask for it on connect:
PLYNX_CONNECTED()
{
Plynx.syncVirtual(V13);
} Troubleshooting
| Problem | Check |
|---|---|
| Value jumps by the wrong amount | Step in the widget settings, not the sketch |
| Decimals disappear | use param.asFloat() instead of asInt() |
| Value stops before the limit you want | Min and Max in the widget settings |