操作步骤
注:服务器端网址为http://www.ivt.edu.cn/english/sub/pub.html
1.将网络扩展板与UNO插接在一起,确保引脚连接正常。
pic1:uno+w5100 shield
2.如图所示连接UNO和PC机(PWR红灯长亮,AREF左侧绿灯长亮)
pic2:connect uno and pc
3.打开arduino示例程序WebClient
pic3-1:WebClient
修改代码如下图(红色划线部分为你要访问的服务器的信息),并上传到uno板
pic3-2:WebClient-code
上图中蓝色划线部分(Client端w5100的IP地址一定要和路由器在同一个网段),下图是在当前路由器下的另外电脑信息,可以确认路由器网段
pic3-3:router
4.将网络扩展板使用网线(网线用交叉线)与路由器连接
pic4:crossover cable
5.打开arduino菜单:工具-》串口监视器
pic5:arduino serial
6.代码解释
设置w5100为客户端,http://www.ivt.edu.cn/english/sub/pub.html为服务器端,会读取服务器信息(client.read())显示在端口监视器中。
网上参考资料
Getting Data From The Web – Arduino + Ethernet
Arduino Ethernet Shield and external webserver
Tutorials > Examples from Libraries > Ethernet > WebClient
Tutorials > Examples from Libraries > Ethernet > WebClientRepeating