I've been trying to figure this out all afternoon and no luck. I've tried seeing if there were any other posts similar to this question already on this forum, but nothing has seemed to helped so far. So please let me know if I am violating any rules.
First of all, I am using a Macbook Air mid-2013 model with the Arduino Uno and Seeed Studio Ethernet Shield v2. My Macbook Air does not have an ethernet port so I am using an adapter to plug in my ethernet cord. My shield however did not come with a sticker on it that showed the IP address and MAC address. I plugged the Arduino USB in my computer and ethernet cord directly into my computer (with the adapter). I have to use the adapter because I am going to demo my project to my school and will not have access to a router...
When I go to System Preferences > Network I see my ethernet connection (USB 10/100 LAN). It says "Self-Assigned IP" and also says "USB 10/100 LAN has a self-assigned IP address and will not be able to connect to the Internet". I am currently using DHCP. I see my IP address there and when I click 'advanced' I see my MAC address as well. However, whenever I upload the Example > Ethernet > WebServer (I changed the IP and MAC to match what I have in my Network settings) and go to the IP address on my web browser: NOTHING. I even tried doing 'http://' in front of it.
What on earth am I doing wrong?! Is it because I am using the adapter?
What IP and mac are you using in the Arduino? Posting your sketch is highly recommended.
Are you using the ethernet library from Seeed Studios for that shield? It has a w5200 ethernet controller instead of the w5100, so it needs a slightly modified library.
You need to download and import that library into the IDE using "Sketch/Import Library/Add Library".
/*
Web Server
A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)
created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
*/
#include <SPI.h>
#include <EthernetV2_0.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xA0, 0xCE, 0xC8, 0x02, 0x46, 0x5C };
IPAddress ip(169,254,7, 40);
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
#define W5200_CS 10
#define SDCARD_CS 4
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
pinMode(SDCARD_CS,OUTPUT);
digitalWrite(SDCARD_CS,HIGH);//Deselect the SD card
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connnection: close");
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
// add a meta refresh tag, so the browser pulls again every 5 seconds:
client.println("<meta http-equiv=\"refresh\" content=\"5\">");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(sensorReading);
client.println("
");
}
client.println("</html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}
I have tried this and still nothing, is there any setup that must be done on my mac? It seems whenever I try to change IP address in system preferences I get the message that a computer already is using that IP address...no matter what IP address I try to use.