Two-way widget
Messenger
A Messenger is a chat with your device. Type a command like fan on and the board answers in its own bubble. The device can also send you alerts and status messages on its own.
Dashboard ↔ deviceText, up to 256 characters6 quick themes1 Telemetry Point
Try it
Type fan on, fan off or status in the chat and press send. The NuttyFi board reads the text and answers in its own bubble. The buttons under the board send a message from the device, like an alert.
SimulationLIVE
Dashboard
This is the Messenger widget from the dashboard.
TP0
Your device
The board reads and answers on the same Telemetry Point.
Widget Color
Quick themes
Show
Messages are textA Messenger always uses a string Telemetry Point. The app sets the DATA TYPE to string for you when you link the point.
How to add and set up
- Open the dashboard in edit modeOpen the device and turn on editing.
- Add a MessengerPress + on the right edge of the canvas and pick Messenger. Drag it into place and make it tall enough to read a few messages.
- Open its settingsClick the gear icon on the widget.
- Link a Telemetry PointUnder Linked Telemetry Points, pick a free point, for example
TP0. Its DATA TYPE is set to string. Use a point that no other widget uses. - Pick a lookChoose one of the Quick themes, or set your own bubble colours under Customize. Save, then press DONE.
Settings
| Setting | What it does |
|---|---|
| Widget Name | The name in the chat header, like the name of a contact. |
| Label Color | Colour of the name. |
| Linked Telemetry Points | The Telemetry Point the chat uses in both directions. Your device code uses the same point. |
| Quick themes | One tap sets both bubbles: Classic, Ocean, Mint, Sunset, Mono or Neon. Without a theme, your bubbles use the Widget Color and the device bubbles follow light or dark mode. |
| Customize | Pick the device bubble or your bubble, then set its Background or Text colour. If the text becomes hard to read, the app says Text is hard to read on this bubble. and Fix picks a readable text colour. |
| Widget Color | Colour of the outline and the avatar, and of your bubbles and the send button when no theme is set. |
| Hide widget Name / Telemetry Point / Widget Border | Hide the name, the TP badge or the outline around the widget. |
Messages and limits
| What | How it works |
|---|---|
| Your messages | Shown on the right. Each one is sent to the device on the linked point, as text. |
| Device messages | Shown on the left. Whatever the device sends on the same point appears as a new bubble right away. |
| Length | Up to 256 characters per message. A counter appears when you get close to the limit. |
| History | The chat opens with the latest 50 messages. Messages are kept for 30 days, then removed automatically. |
| Sending rate | Up to 30 messages a minute per device. Over that, wait a moment before sending again. |
| Delete history | The bin icon in the header clears every message on this point for this device. It does not touch other points or devices, and cannot be undone. |
| Edit mode | While you edit the dashboard, the chat shows a sample. Sending works in live mode. |
Receive and reply on your device
Your board receives each message with SME_LISTEN on the linked point and answers with SME.publish() on the same point. Read the text with data.toString(). The examples use TP0.
C++ · Arduino
#define FAN_PIN 5
SME_LISTEN(TP0)
{
String msg = data.toString(); // the text you typed
msg.trim();
msg.toLowerCase();
if (msg == "fan on") {
digitalWrite(FAN_PIN, HIGH);
SME.publish(TP0, "Fan ON");
} else if (msg == "fan off") {
digitalWrite(FAN_PIN, LOW);
SME.publish(TP0, "Fan OFF");
} else {
SME.publish(TP0, "Try: fan on, fan off");
}
}bool alertSent = false;
void loop()
{
SME.run();
int level = readTank(); // your sensor, 0 to 100 %
if (level < 20 && !alertSent) {
SME.publish(TP0, "Tank level low: " + String(level) + " %");
alertSent = true; // send it once
}
if (level > 30) alertSent = false;
}SME_LISTEN(TP0)
{
String msg = data.toString();
msg.trim();
msg.toLowerCase();
if (msg == "status") {
float t = readTemperature(); // your sensor
SME.publish(TP0, "Temperature " + String(t, 1) + " C");
}
}#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
// Messenger on TP0: read the text, answer on the same point
SME_LISTEN(TP0)
{
String msg = data.toString();
msg.trim();
msg.toLowerCase();
if (msg == "fan on") {
digitalWrite(FAN_PIN, HIGH);
SME.publish(TP0, "Fan ON");
} else if (msg == "fan off") {
digitalWrite(FAN_PIN, LOW);
SME.publish(TP0, "Fan OFF");
} else {
SME.publish(TP0, "Try: fan on, fan off");
}
}
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
}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.
Related widgets
Was this page helpful?
Docs