D1 mini and ESP32-C3 channel messaging
Pressing the button sends a signal on the #homeButton channel, and receiving a signal on that channel toggles the LED. It is the shortest example of boards on one router exchanging signals with each other and with the web or the CLI. The example is esp_channel_txrx; its page on test.iosignal.net has a wiring picture and a panel to try it.
What you need
| Board | LED | Button | Change |
|---|---|---|---|
| ESP8266 D1 mini (default) | Built-in LED (GPIO2) | Between D5 (GPIO14) and GND | Nothing |
| ESP32-C3 Super Mini | Built-in LED (GPIO8) | Built-in BOOT button (GPIO9) | Set LED_PIN to 8 and the ESP32 BUTTON_PIN to 9 in the sketch |
- A D1 mini needs only a button. Without one, briefly touch D5 to GND with a jumper wire.
- An ESP32-C3 Super Mini works with no parts after changing two lines. Its built-in LED lights on LOW.
- You need a 2.4 GHz Wi-Fi router.
Upload
- Install IOSignal and Bounce2 as in library installation.
- Open File → Examples → IOSignal → esp_channel_txrx. For an ESP32-C3, change the pins as in the table above.
- Select the board (D1 mini: LOLIN(WEMOS) D1 R2 & mini, ESP32-C3: ESP32C3 Dev Module) and upload. To see serial output on an ESP32-C3, set USB CDC On Boot to Enabled.
- With the board on USB, open board settings in desktop Chrome or Edge and enter the Wi-Fi name and password. The board keeps them across uploads. You can also write them in
WIFI_SSIDandWIFI_PASSin the sketch.
The default server is io.iosignal.net:55488 (TCP). The same board settings page can set another IOSignal server (host:port) and a device key.
How it works
- Once connected and
ready, the board subscribes to#homeButton. The serial monitor (115200 baud) showsonReady cid: …. - A button press sends the board kind (
esp8266oresp32) as text on#homeButton. The text tells which board sent it; it is not an on/off command. - Receiving
#homeButtontoggles the LED. A board also receives its own signal, so even one board changes its LED when you press the button.
#homeButton is a home channel tag with no channel name. It reaches only boards, web pages and CLIs connected from the same router (the same public IP).
Check from the web or the CLI
- On the example page at test.iosignal.net, use the try-it panel to send
#homeButtonand watch the board's signals. Open it on a PC or phone on the same router as the board. - With the CLI, connect from a PC on the same router with
io-client -c wss://io.iosignal.net/ws -j '#homeButton'and sendsig #homeButton hello(CLI client). The LED changes, and pressing the board's button shows a signal in the CLI.
Seeing your own message in the CLI or on the web does not mean the board received it. Check the board's LED and serial log.
Troubleshooting
- With no connection log on serial, check the Wi-Fi name, password and that the network is 2.4 GHz. The board settings page shows the networks the board finds.
- If the board is
readybut the LED does not react, check the server, the tag spelling (#homeButton) and that everything is on the same router. - With a local server, use the PC's LAN IP and TCP port, not
localhost. See connections.
To build a device that the web app finds and controls next, see Build a Remocon device and the D1 mini and ESP32 examples in Arduino getting started.