Docs

Bridge

Bridge lets one board write pins on another board. The two talk through the server, with no phone involved.

Use it for: a sensor outside that switches a relay inside, a button in the hall that opens the garage, a master board driving several others.

SettingWhat it does
Pina spare virtual pin on the sending board

Open these from the canvas: tap Edit, then long press the widget and choose Configure.

Bridge lives in the library rather than on the dashboard. You give it the auth token of the board you want to write to.

Example

A sensor board that turns on a relay wired to a second board.

bridge.ino
#include <PlynxSimpleEsp32.h>

WidgetBridge bridge(V28);             // any free virtual pin on THIS board
PlynxTimer timer;

PLYNX_CONNECTED()
{
  bridge.setAuthToken("TokenOfTheOtherBoard");
}

void checkTemperature()
{
  float celsius = analogRead(34) * (3.3 / 4095.0) * 100.0;

  bridge.virtualWrite(V1, celsius > 28 ? 1 : 0);
}

void setup()
{
  Serial.begin(115200);

  // 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();

  timer.setInterval(30000L, checkTemperature);
}

void loop()
{
  Plynx.run();
  timer.run();
}

setAuthToken() belongs in PLYNX_CONNECTED(). The token identifies the board you are writing to, and you find it in its board settings.

bridge.virtualWrite(V1, value) writes V1 on the other board, which runs its own PLYNX_WRITE(V1) handler. bridge.digitalWrite() and bridge.analogWrite() reach its physical pins.

Both boards need to be online. Bridge sends through the server, so nothing queues up for a board that is asleep.

Troubleshooting

ProblemCheck
Nothing reaches the other boardthe token belongs to a different board
Works sometimesthe receiving board drops offline; check its serial output
The sending board resetssetAuthToken() in setup() instead of PLYNX_CONNECTED()
The handler never runsthe receiving sketch has no PLYNX_WRITE() for that pin

Next