I have just received the ethernet shield today, but I can't figure out how to give it a MAC address.
There was also no sticker with the MAC address on it either.
Since I have never worked with MAC addresses before, I just need a hand.
I have tried to follow this tutorial right here:
And I got stuck on step 3.
(when I try to put in a MAC address, it gives me the yellow error code line at the mac address) ( Please find picture attached)
Client code with an assigned mac address. You chose the address and put it in the appropriate format.
//zoomkat 9-22-12
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
//remove SD card if inserted
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
char serverName[] = "web.comporium.net"; // zoomkat's test web page server
EthernetClient client;
//////////////////////
void setup(){
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
while(true);
}
Serial.begin(9600);
Serial.println("Better client test 9/22/12"); // so I can keep track of what is loaded
Serial.println("Send an e in serial monitor to test"); // what to do to test
}
void loop(){
// check for serial input
if (Serial.available() > 0) //if something in serial buffer
{
byte inChar; // sets inChar as a byte
inChar = Serial.read(); //gets byte from buffer
if(inChar == 'e') // checks to see byte is an e
{
sendGET(); // call sendGET function below when byte is an e
}
}
}
//////////////////////////
void sendGET() //client function to send/receive GET request data.
{
if (client.connect(serverName, 80)) { //starts client connection, checks for connection
Serial.println("connected");
client.println("GET /~shb/arduino.txt HTTP/1.1"); //download text
client.println("Host: web.comporium.net");
client.println("Connection: close"); //close 1.1 persistent connection
client.println(); //end of get request
}
else {
Serial.println("connection failed"); //error message if no client connect
Serial.println();
}
while(client.connected() && !client.available()) delay(1); //waits for data
while (client.connected() || client.available()) { //connected or data available
char c = client.read(); //gets byte from ethernet buffer
Serial.print(c); //prints byte to serial monitor
}
Serial.println();
Serial.println("disconnecting.");
Serial.println("==================");
Serial.println();
client.stop(); //stop client
}
Hello!
Thanks for your reply!
but, I don't know how to make a MAC address, I have no experience in it what so ever.
I have tried different MAC address generators, to see if I could get a unique one, and one that actually works.
In a tutorial I read a couple of days ago, it said that you could put in a random MAC address in the right format, and it should work. Could anyone give me a random (of the top of your head) MAC address that I can use?
Thanks lots !
Goldfile:
Could anyone give me a random (of the top of your head) MAC address that I can use?
Use the mac address in zoomkat's code above. It only has to be unique to your localnet. Or increment it by one if you feel you must have it absolutely unique. Your choices are hexadecimal (0-9 and A-F).