查看“Microduino W5500 Network (2)”的源代码
←
Microduino W5500 Network (2)
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{| style="width: 800px;" |- | ==Purpose== This course will show you how to use DHCP server to configure network parameter automatically, enabling your Microduino to acquire IP address accordingly. ==Equipment== *'''[[Microduino-Core]]''' *'''[[Microduino-USBTTL]]''' *'''[[Microduino-W5500]]''' *'''[[Microduino-RJ45]]''' *Other hardware equipment **USB cable One ==DHCP== Generally, you can find a DHCP (Dynamic Host Configuration Protocol) server in local network. DHCP distributes network parameters (IP address, mask, gateway and DNS) to internal network device automatically. Here is a simple introduction of how it works: You need a device (Client) with IP address, send a '''DISCOVERY''' broadcasting data package—which will reach the whole network of the device, and “discover” a functional DHCP server; If there are more than one DHCP servers functional, they will respond to a '''OFFER''' package and “suggest” Client set available IP address; Client selects the IP address and send a '''REQUEST''' data package to the corresponding server, asking the permission of using the address; We suggest set server of the IP address and return an '''ACK''' to confirm associated IP address. [[File:DHCPShow.jpg|600px|center|thumb]] Luckily, the acquisition of IP address mentioned above has been achieved in library file of dhcp.cpp. Next, we’ll compile a simple example to present the use of DHCP server. ==Schematic== *Microduino-W5500 *Microduino-RJ45 *Microduino-Core *Microduino-USBTTL Stack them and then plug in network cable. As follows: [[File:MicroduinoW5500Show.png|600px|center|thumb]] ==Program== [[https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Advanced_Tutorial/W5500Code/MicroduinoW5500Two MicroduinoW5500Two]] ==Debugging== Step 1: First, make sure there is _02_Microduino_Ethernet_WIZ library in the IDE. If no, please download one and put it into libraries folder of your IDE and restart IDE. Step 2: If there still exists Ethernet library in the libraries folder of your IDE, it needs to be deleted since the previous Ethernet is compiled according to W5100. Then you need to change _02_Microduino_Ethernet_WIZ so that the library function can be corresponding with the pin of Microduino-W5500: Find w5100.h in utility folder of _02_Microduino_Ethernet_WIZ library. Change #define wiz_cs_pin 8 //CS_PIN of the code to #define wiz_cs_pin 10 //CS_PIN. Step 3: Interpret the code: // start the Ethernet connection: Serial.println("Trying to get an IP address using DHCP"); if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // initialize the ethernet device not using DHCP: #if defined(WIZ550io_WITH_MACADDRESS) Ethernet.begin(ip, gateway, subnet); #else Ethernet.begin(mac, ip, gateway, subnet); #endif } The code above uses DHCP to assign IP address firstly. So, if the assignment failed, you need to assign the IP address defined previously. Step 4: Download the code and pass compile. Step 5: If everything works fine, you can open the serial port and acquire IP address assigned by DHCP. [[File:MicroduinoW5500DHCP1.png|600px|center|thumb]] With the IP, you can have a ping connection with your Microduino. [[File:MicroduinoW5500DHCP2.png|600px|center|thumb]] ==Result== If you can check your DHCP server (Usually, you can find it in the DHCP client of our router), you will see a newly connected device. ==Video== |}
返回至
Microduino W5500 Network (2)
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
Welcome
首页
创客大赛
大赛详情
3D打印
安装月球车
图形化编程
操控月球车
升级月球车
编程工具下载
软件下载
Arduino
Processing
Mixly
Scratch
模块套件
Microduino 102
mCookie 102
mCookie 202
mCookie 302
IBC
其他
应用套件
四轴飞行器
平衡车
小车CUBE
音乐播放器
刷卡音乐播放器
wifi气象站
彩虹音乐触摸灯
分贝检测仪
迎门汇报
LED点阵时钟
LED点阵屏幕
硬件
mCookie
Sensor
Microduino
MicroWrt
MicroNux
MicroRobot-Core
MicroRobot-CoreESP
ideaBoard
ideaBox
MicroMV
MicroAI
帮助
常见问题
帮助
工具
链入页面
相关更改
特殊页面
页面信息