Slider
A Slider sends a number in a range: motor speed, LED brightness, a set temperature. Drag it and the device gets the new value.
Try it
Drag the slider. With Get Value Instantly the fan speed follows while you drag. Switch Value Update Mode to Get Value On Drop and the value is sent only when you let go.
How to add and set up
- Open the dashboard in edit modeOpen the device and turn on editing.
- Add a SliderPress + on the right edge of the canvas and pick Slider. Drag it into place.
- Open its settingsClick the gear icon on the widget. The window title shows the widget's name.
- Link a Telemetry PointUnder Linked Telemetry Points, pick the point your code reads and set its MIN and MAX.
- Pick style and update modeChoose a Slider Style, the orientation and Value Update Mode. Save, then press DONE.
Settings
| Setting | What it does |
|---|---|
| Widget Name | The title shown on the widget. |
| Label Color | Colour of the title. |
| Linked Telemetry Points | The Telemetry Point (TP0, TP1…) the widget uses. Your device code uses the same point. |
| Slider Style | Classic, Glow, Bars, Ruler, or a rotary Knob, Dial or Meter. Try them all in the simulation above. Ruler, Knob, Dial and Meter need Starter or above. |
| Slider Orientation | Horizontal (Left to Right) or Vertical (Bottom to Top). Knob, Dial and Meter turn instead, so they have no orientation. |
| Value Update Mode | Get Value Instantly: sends while you drag, at most one value every 250 ms, and always the final value. Get Value On Drop (default): sends once, when you let go. |
| Telemetry Point settings | The linked point carries the DATA TYPE (integer or double), UNITS, MIN, MAX, DECIMALS and DEFAULT the widget uses. |
| Widget Color | Colour of the filled part of the slider and of the value. |
| Hide widget Name / Telemetry Point / Widget Border | Hide the title, the TP badge or the outline around the tile. |
Instantly or On Drop?
| Use | Mode |
|---|---|
| Brightness, fan speed: you want to see it change | Get Value Instantly |
| Set points, motor targets: only the final value matters | Get Value On Drop |
Receive commands on your device
A Slider writes a number between the Telemetry Point's MIN and MAX. The examples use TP0 with MIN 0 and MAX 255, like the fan in the simulation.
SME_LISTEN(TP0)
{
int speed = data.toInt(); // 0 to 255
analogWrite(FAN_PIN, speed); // PWM: fan speed or LED brightness
}float setPoint = 0;
SME_LISTEN(TP0)
{
setPoint = data.toFloat(); // e.g. 22.5 (DATA TYPE double)
}#define DASHBOARD_ID "PROJ-XXXXXXXX"
#define DEVICE_TOKEN "SME-XXXX-XXXX-XXXX"
#define FIRMWARE_VERSION "1.0.0"
#define WIFI_SSID "your_wifi"
#define WIFI_PASS "your_pass"
#include <SMEIoT.h>
#define FAN_PIN 5
// Slider on TP0: MIN 0, MAX 255
SME_LISTEN(TP0)
{
int speed = data.toInt();
analogWrite(FAN_PIN, speed);
}
void setup()
{
Serial.begin(115200);
pinMode(FAN_PIN, OUTPUT);
SME.begin(DASHBOARD_ID, DEVICE_TOKEN, FIRMWARE_VERSION,
WIFI_SSID, WIFI_PASS);
}
void loop()
{
SME.run(); // keeps the link alive
}SME_LISTEN(TP0) runs every time the dashboard writes TP0. data holds the value it sent, as text: use data.toInt() for whole numbers or data.toFloat() for decimals.
analogWrite() takes 0 to 255. On older cores it takes 0 to 1023: add analogWriteRange(255); in setup(), or set the Slider's MAX to 1023.These are snippets. Your sketch also needs #include <SMEIoT.h>, SME.begin(...) in setup() and SME.run() in loop(). The full sketch tab shows a complete example; see the SDK quick start for more.
Docs