使用 Ethernet Shield 在多个 Arduino 板之间发送和接收数据的最佳方式是什么?

What is the best way to send and receive data between multiple Arduino boards using Ethernet Shield?

我是 Arduino 新手。 我有 4 个 Arduino 开发板,相隔很远。我想在所有这些之间建立连接,例如,如果一个传感器连接到 Arduino 板号 1(例如)被触发,它将向所有其他 3 个板发送某种通知以在其他板上执行操作。我打算使用 Ethernet shield,但想知道在使用 Arduino 配置 Ethernet Shields 时最好使用什么模式,以及如何配置它们来这样做。我希望你明白。提前谢谢你。

在带有网络屏蔽的 Arduino 上,您可以启动 EthernetServer 或 WiFiServer。请参阅以太网库的 ChatServer 示例。

在其他带有网络屏蔽的 Arduino 上,您创建一个 EthernetClient(或 WiFiClient)并将其连接到服务器的 IP 地址。然后,您打印到客户端客户端的所有内容都将发送到由 server.available() 返回的服务器客户端。

您可以使用 Telnet 客户端测试服务器。