Docs
Number Input
The Number Input widget gives you a field to type a number, and sends it when you confirm.
Use it when the value is exact and far from the last one: a target temperature, a duration in seconds, a pulse count. Reaching 300 with a Step takes a lot of presses.
| Setting | What it does |
|---|---|
| Pin | the virtual pin your code reads |
| Min, Max | the values the field accepts |
| Decimals | whether fractions are allowed |
Open these from the canvas: tap Edit, then long press the widget and choose Configure.
Example
A watering duration on V19, typed in seconds.
#include <PlynxSimpleEsp32.h>
#define VALVE_PIN 26
PlynxTimer timer;
int wateringSeconds = 30;
void stopWatering()
{
digitalWrite(VALVE_PIN, LOW);
}
PLYNX_WRITE(V19)
{
wateringSeconds = param.asInt();
}
PLYNX_WRITE(V20) // a Button that starts the cycle
{
if (param.asInt() == 1) {
digitalWrite(VALVE_PIN, HIGH);
timer.setTimeout(wateringSeconds * 1000L, stopWatering);
}
}
void setup()
{
Serial.begin(115200);
pinMode(VALVE_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();
timer.run();
} The value arrives once, when you confirm the field. Nothing is sent while you type, so a half typed number never reaches the board.
Check the value before you use it. A typo that opens a valve for 30000 seconds is a flooded room, and Min and Max in the widget settings are the first guard.
Troubleshooting
| Problem | Check |
|---|---|
| Value never arrives | the field was not confirmed, or the pins do not match |
| Decimals are lost | allow them in the widget settings and read param.asFloat() |
| Value resets on reboot | add Plynx.syncVirtual(V19) inside PLYNX_CONNECTED() |