Examples / Messaging

Messaging

Send named key/value messages between the browser and the sketch — no pins involved — and inspect every frame on the wire with the live traffic monitor.

IntermediateMulti-userTool
Messaging — the example running

Messaging

Named key/value messages between the browser and the Arduino sketch — no pin, no hardware device. Send a value under a key, watch keys for changes, and inspect all WebSocket traffic with the frame monitor.

What it shows

The sketch (messaging.ino) drives the built-in LED from a led message, logs every message to Serial, and sends a retained uptime counter once a second — retained means a browser that connects later immediately gets the current value.

Run it

  1. In Arduino IDE: File → Examples → Pardalote → messaging, select your board, upload.
  2. Open index.html in a browser.
  3. Type the board's IP into the Board IP field and press Connect — this is a tool, so no code editing is needed and the browser remembers the IP for next time.

Try sending led = true / false to toggle the LED. Open the page in two browser tabs and send with broadcast ticked — the other tab sees it too (the board relays it). Tick retain, reload, and the value is still there.

API used

JS
arduino.send('mode', 'idle', { retain: true, broadcast: true });
arduino.send('count', 42);            // int    (auto-typed)
arduino.send('temp', 22.5);           // float
arduino.send('on', true);             // bool

arduino.watch('uptime', (v, key, type) => …);
arduino.on('message', ({ key, value, type }) => …);
arduino.messages['mode'];             // last received value

arduino.on('frame', ({ dir, cmdName, target, params }) => …);   // inspect all traffic
Arduino
Pardalote.send("uptime", secs, MSG_FLAG_RETAIN);
Pardalote.watch("led", onLed);        // void onLed(const Message& m)
Pardalote.onMessage(onAny);
Pardalote.onFrame(onFrame);           // void onFrame(const FrameEvent& ev)