查看“Microduino ENC Network (6)”的源代码
←
Microduino ENC Network (6)
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{Language | Microduino ENC网络(六)}} {| style="width: 800px;" |- | ==Objective== This tutorial will show you how to write a sketch to update a DNS record hosted by one of the most famous Dynamic DNS service providers, no-ip. ==Equipment== *'''[[Microduino-Core]]''' *'''[[Microduino-FT232R]]''' *'''[[Microduino-ENC28J60]]''' *'''[[Microduino-RJ45]]''' *Other equipment **USB cable ==Dynamic IP addresses== If you connect to Internet using a home or mobile connection, you’ll probably have a dynamic public IP address, that is it changes everytime you connect. If you need to talk to a device on Internet, you need to write – in the message you send on the net – its public IP address: if this IP is dynamic, you may not know it. ==Dynamic DNS== In Internet you can find free Dynamic DNS (DDNS) services: they allow you to associate a name you choose with an IP address and they allow you to keep that association updated. The update could be done in different ways: *using a client running on your PC; *with a feature present in your router: *asking Arduino to do it for us. ==NO-IP== One of the most used site offering dynamic DNS service is No-IP. If you register for free to No-IP Free service, you can configure up to 5 hosts for Hosts/Redirects feature: [[File:noipPhoto.jpg|600px|center|thumb]] For this tutorial, I registered the following host: enctutorial.no-ip.info. ==DDNS Client== Every DDNS client performs the following steps: *gets the actual public IP (asking the router, an external website…); *compares that IP with the one resolved from DNS alias; *if they are different, it updates the DNS record via service provider’s API. ==Schematic== *Microduino-ENC28J60 *Microduino-RJ45 *Microduino-Core *Microduino-FT232R Stack all modules and then connect the ethernet cable, as follows: [[File:MicroduinoENCShow.jpg|600px|center|thumb]] ==Program== Refer to ENCnetworksix ==Debug== Step 1:Download the EtherCard library and copy to your libraries fold of IDE, then restart IDE. https://github.com/jcw/ethercard Step 2:Explain the program: Public IP: To find the actual public IP, I wrote a simple PHP page on my website: [[File:getPublicIP.jpg|600px|center|thumb]] Microduino sketch gets that page and parse the IP address. DNS record and comparison: //Sketch calls dnsLookup() method to resolve actual IP for DNS record; it then converts the result in a String object to use its compareTo() method to compare the two IP addresses: if(!ether.dnsLookup(noIP_host)) { [...] } else { for(int i = 0; i < 4; i++) { dnsIp = dnsIp + String(ether.hisip[i]); if(i < 3) dnsIp = dnsIp + "."; } if(actualIp.compareTo(dnsIp) == 0) { Serial.println("No update needed :)"); [...] } else { Serial.println("Update needed :("); actual_status = STATUS_NOIP_NEEDS_UPDATE; } Authentication: You have to authenticate to No-IP before being allowed to update any records. [[File:NoIPAuth.jpg|600px|center|thumb]] You have to assign to that constant the base64 encoded value of the string username:password. You can use an online encoder: http://tuxgraphics.org/~guido/javascript/base64-javascript.html [[File:onlineEncode.jpg|600px|center|thumb]] Step 3:Compile the code and download it. Step 4:Check if can access the Microduino. ==Result== Arduino correclty found a difference between public IP and DNS record so it updated No-IP record. After a while, it performed another check and this time the two IP addresses were equals so no update was required. ==Video== |}
该页面使用的模板:
模板:Language
(
查看源代码
)
模板:Nmbox
(
查看源代码
)
返回至
Microduino ENC Network (6)
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
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
帮助
常见问题
帮助
工具
链入页面
相关更改
特殊页面
页面信息