I have a problem using ethernet shield on arduino!!


hi, bought ethernet shield runs w5100 , have trouble using this.

i have built php , mysql ,

when type

localhost/arduino/test.php?sensor1=50

in address bar on internet, works fine , store "50" database , displays on localhost website.

-----------------------------------------------------------------------------------------
#include <spi.h>
#include <ethernet.h>

byte mac[] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed };
byte ip[] = { 169,254,15,174 };
byte server[] = { 127, 0, 0, 1 };

float sensor1 = 5;

ethernetclient client;

void setup()
{
  serial.begin(9600);
  ethernet.begin(mac, ip);
}

void loop()
{
  if(client.connect(server, 80))
  {
    serial.println("connected");
    client.print("get /arduino/test.php?");
    client.print("sensor1=");
    client.print(sensor1);
  }
  else
  {
    serial.println("connection failed");
  }
}
-----------------------------------------------------------------------------------------

the ip address assigned above found on system preferences - network on macbook.

i plugged ethernet cable right macbook , new network came up. ip address of shown in picture attached.

the server address assigned above think localhost address.

i thought correct, when upload, prints "connection failed"

please help!

the ip 127.0.0.1 localhost. accessible computer server software running on. must use ip of computer, 169.254.x.x ip.


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > I have a problem using ethernet shield on arduino!!


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'