Go Down

Topic: Eternet shield help (Read 269 times) previous topic - next topic

Helter_Skelter

Feb 19, 2016, 02:45 am Last Edit: Feb 22, 2016, 04:33 pm by Helter_Skelter
Hello guys,

I have been trying to solve this problem but i hit a wall, so i hope u can help me.

I have been trying to send an e mail using this tutorial (the secound code, one with SMPT2GO): http://playground.arduino.cc/Code/Email.

There are 4 things to change so you get the resault: IPAddress, IPAddress gateway, IPAddress subnet, and Arduinos IP

Now because i am new at networking and stuff, i dont know wich one i missed, i used gateway and subnet from my computer. I dont know wich one i should use for IPAddress ip, and Arduinos IP.

Here are some pictures
http://i.imgur.com/L3WBro8.png
http://i.imgur.com/KpLZWpn.png

Thanks


Helter_Skelter

Bump, i really need help with this

ieee488

I would imagine you would need the IP address of the mail server.


ffur

First - Are you connected to your ethernet. Can you ping your Arduino ethernet shield on address 192.168.1.5 ?
If you are connected then please supply us with the output from your Serial monitor.
Where does your sketch stop?
It's much easier to help if we get as much info as possible.

/ffur

zoomkat

Simple client code you can try unmodified to see if you can get a response from the external server.

Code: [Select]

//zoomkat 11-04-13
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test client GET
//for use with W5100 based ethernet shields
//remove SD card if inserted
//data from myIP server captured in readString

#include <SPI.h>
#include <Ethernet.h>
String readString;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "checkip.dyndns.com"; // myIP server 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("client readString test 11/04/13"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
  Serial.println();
}

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 / HTTP/1.1"); //download text
    client.println("Host: checkip.dyndns.com");
    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
    readString += c; //places captured byte in readString
  }

  //Serial.println();
  client.stop(); //stop client
  Serial.println("client disconnected.");
  Serial.println("Data from server captured in readString:");
  Serial.println();
  Serial.print(readString); //prints readString to serial monitor
  Serial.println(); 
  Serial.println();
  Serial.println("End of readString");
  Serial.println("==================");
  Serial.println();
  readString=""; //clear readString variable

}


Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

VitorAlves

I need to create a web client with Arduino and Ethernet Shield and several possible combinations never got a valid IP for the Arduino .
Ethernet.begin ( mac ) the system stops on this line. To begin ( mac, ip) the system assigns the IP 0.25.25.25 . Already blocked the SD card system with the pin 4 to LOW and HIGH , already used the begin ( mac, ip , dns , gateway mask ) and the result was the same attachment the last code. The idea is to run a php page that inserts a record in mysql table.

#include <Ethernet.h>
#include <SPI.h>

EthernetClient client;

byte mac[] = { 144, 162, 218, 16, 66, 237 };
byte ip[] = { 192, 168, 1, 151 };
byte mydns[] = { 192, 168, 1, 1 };
byte gateway[] = { 192, 168, 1, 1 };
byte mask[] = { 255, 255, 255, 0 };
byte server[] = { 192, 168, 1, 150 };

void setup()
{
  Ethernet.begin(mac,ip); //, mydns, gateway, mask);
  delay(1000);
  pinMode(4, OUTPUT);
  //pinMode(10, OUTPUT);
  //digitalWrite(10, LOW);
  digitalWrite(4, HIGH);

  Serial.begin(9600);
  delay(1000);
   
  Serial.println("connecting...");
  Serial.print(Ethernet.localIP());
   
    if (client.connect(server, 80)) {
    Serial.println("connected");
    client.println("/arduino/index.php");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
}

pert

never got a valid IP for the Arduino
Which Ethernet Shield do you have? The Ethernet library only supports the W5100 Ethernet controller based shields but there are some other shields with different chips that require a different library. If you aren't sure you could check the chip on the shield or post a link to where you bought your shield.

VitorAlves

The board is Ethernet shield 2 (Shield ETH11 V2)

pert

#8
Feb 23, 2016, 04:10 pm Last Edit: Feb 23, 2016, 04:40 pm by pert
The board is Ethernet shield 2 (Shield ETH11 V2)
The Ethernet Shield 2 uses the W5500 Ethernet controller chip instead of the W5100 chip on the Ethernet Shield. The Ethernet library is not compatible with the W5500. If you're using the arduino.org IDE then you can just change the line in your sketch from:
Code: [Select]
#include <Ethernet.h>
to:
Code: [Select]
#include <Ethernet2.h>
If you're using the arduino.cc(this website) IDE, which I would highly recommend then you only need to install an Ethernet library that supports the W5500. There are a few choices:

Ethernet2 library - this is the same library included with the arduino.org IDE

EthernetMod W5x00 branch - This supports W5100, W5200, and W5500 without needing any modifications
https://github.com/per1234/EthernetMod/tree/W5x00 follow the installation instructions on that page, you don't need to make any changes to your current sketch.

Wiznet Ethernet Library - https://github.com/Wiznet/WIZ_Ethernet_Library this is already set up to support the W5500 but the installation is slightly complicated so let me know if you want to install that one and need help with installation.

VitorAlves

Thank you, it's work :), I lose 2 days with this problem, try all possibility and reading all text about Shield Ethernet

ffur

Hi Helter_Skelter
I think VitorAlves did clobber your question up. He should have started another sequence.
Please try zoomkat's sketch - he knows what he's talking about.
Else try some of the simpler examples in the IDE - ex. WebServer.

/ffur

Helter_Skelter

Hey zoomkat,

First of all thank you, and secound

I tried to use your program, but i get nothing on my serial monitor, i tried to use another sketch that uses serial monitor, and it is working ok, i also tried to use 2 different arduinos :/

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy