使用以太网扩展板在多个 Arduino 板之间发送和接收数据的最佳方式是什么? [英] What is the best way to send and receive data between multiple Arduino boards using Ethernet Shield?

查看:32
本文介绍了使用以太网扩展板在多个 Arduino 板之间发送和接收数据的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm new to Arduino. I have 4 Arduino boards separated by long distance. I wanted to make connections between all of them so, for example if one sensor connected to Arduino board number 1 (for example) was triggered it will send to all other 3 boards some kind of notification to do action on other boards. I intended to use Ethernet shield but wondered what is the best mode to use when configuring Ethernet Shields with Arduino and how to configure them to do so . I hope you understand. Thank you in advance.

推荐答案

在带有网络扩展板的 Arduino 上,您可以启动 EthernetServer 或 WiFiServer.请参阅以太网库的 ChatServer 示例.

On Arduino with a networking shield you can start an EthernetServer or WiFiServer. See ChatServer example of the Ethernet library.

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

On other Arduino with a networking shield you create an EthernetClient (or WiFiClient) and connect it to IP address of the server. Then everything you print to client's Client will be send to server's Client returned by server.available().

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

You can test the server with a Telnet client.

这篇关于使用以太网扩展板在多个 Arduino 板之间发送和接收数据的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆