Difference between revisions of "Microduino ENC Network (1)"
m (A misspelled word - represents was spelled rappresents) |
(Misspelled word(s) - already was spelled as alredy) |
||
Line 47: | Line 47: | ||
==Debug== | ==Debug== | ||
− | Step | + | Step 1: Download the EtherCard library and copy to your libraries fold of IDE, then restart IDE. |
https://github.com/jcw/ethercard | https://github.com/jcw/ethercard | ||
− | Step | + | Step 2: Before connect to network, you need learn some network parameter. |
'''Network parameter:''' | '''Network parameter:''' | ||
Line 60: | Line 60: | ||
*(usually) gateway is the IP address assigned to a device (router…) that allows to reach devices in different networks. | *(usually) gateway is the IP address assigned to a device (router…) that allows to reach devices in different networks. | ||
− | You need to choose a MAC address not | + | You need to choose a MAC address not already used in your network… in the examples we usually choose MAC addresses with a not already assigned organization code (es. DD-DD-DD). |
IP parameters (address, subnet, gateway) have to be consistent with the ones configured to other devices in your local network: an unique IP address and the same subnet mask and gateway. | IP parameters (address, subnet, gateway) have to be consistent with the ones configured to other devices in your local network: an unique IP address and the same subnet mask and gateway. | ||
Line 66: | Line 66: | ||
Sometimes a DHCP server is available, that automatically configures new devices in the network: in a next example I’m going to show how to use this with Arduino. | Sometimes a DHCP server is available, that automatically configures new devices in the network: in a next example I’m going to show how to use this with Arduino. | ||
− | Step | + | Step 3: Explain the program. |
//First you need to include the EtherCard library and define some variables: MAC address, IP address and a buffer the library will use to store incoming and outgoing data; | //First you need to include the EtherCard library and define some variables: MAC address, IP address and a buffer the library will use to store incoming and outgoing data; | ||
Line 90: | Line 90: | ||
− | Step | + | Step 4: Download the program and compile it. |
− | Step | + | Step 5: ping! |
Check a device if has online, the "ping" command is a simple method. Ping the destination device's IP. | Check a device if has online, the "ping" command is a simple method. Ping the destination device's IP. |
Latest revision as of 06:24, 6 July 2014
Language: | English • 中文 |
---|
ObjectiveThis tutorial will show you how to ping the Microduino. Equipment
Schematic
Stack all modules and then connect the ethernet cable, as follows:
ProgramDownload the program: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_ENC/ENCnetworkone DebugStep 1: Download the EtherCard library and copy to your libraries fold of IDE, then restart IDE. https://github.com/jcw/ethercard Step 2: Before connect to network, you need learn some network parameter. Network parameter: Before connecting Ethernet shield to the net, you need some parameters:
You need to choose a MAC address not already used in your network… in the examples we usually choose MAC addresses with a not already assigned organization code (es. DD-DD-DD). IP parameters (address, subnet, gateway) have to be consistent with the ones configured to other devices in your local network: an unique IP address and the same subnet mask and gateway. Sometimes a DHCP server is available, that automatically configures new devices in the network: in a next example I’m going to show how to use this with Arduino. Step 3: Explain the program. //First you need to include the EtherCard library and define some variables: MAC address, IP address and a buffer the library will use to store incoming and outgoing data; include <EtherCard.h> static byte mymac[] = {0x74,0x69,0x69,0x2D,0x30,0x31}; static byte myip[] = {192,168,1,10}; byte Ethernet::buffer[700]; ether.staticSetup(myip); //complete configuration with a static configuration for the IP address. Use the function staticSetup() method to configure the static IP, it has three parameters, that are ip address, gateway and DNS. IP is mandatory, others are optional. The following is the defination. static bool staticSetup (const uint8_t* my_ip =0, const uint8_t* gw_ip =0, const uint8_t* dns_ip =0); //in the loop, you need only 2 instructions: //packetReceive()method receives a new incoming packet from the network; //packetLoop() method answers to specific incoming messages, including the “ping” ones (ICMP echo request) ether.packetLoop(ether.packetReceive());
Step 5: ping! Check a device if has online, the "ping" command is a simple method. Ping the destination device's IP. ResultThe upper picture indicates that the device has obeen online. Video |