Setting IP address of Ethernet interface

Hello Friends,

I am trying to do simple exercise.

i need to setup IP for my Ethernet interface.

byte mac = { 0x90, 0xA2, 0xDA, 0x10, 0x38, 0x53 };
byte ip = { 192, 168, 1, 5 };
byte gateway = { 255, 255, 255, 0} ;
Ethernet.begin(mac, ip, gateway);

But always i am getting 0.118.118.188.Why???!!!

Why???!!!

There ?? must !! be $$ something @@ wrong ** with %% your || code.

Did the excess punctuation help? Yours didn't, either.

Mahmoudjaa: But always i am getting 0.118.118.188.Why???!!!

Frustration can be a hell of a thing ???!!!

What Ethernet card is it and did you check to see if your pins are in the correct location? Arduino Ethernet card uses the Ethernet.h library, where the ENC28J60 Card works on the UIPEthernet.h library. Is the cs pin connected on the correct pin as per library instruction?

Post the rest of the program.

byte gateway[] = { 255, 255, 255, 0} ;

Is that really the IP address of your default gateway router?!? Why did you not pass the name server address?!?

Try:

byte mac[] =    { 0x90, 0xA2, 0xDA, 0x10, 0x38, 0x53 };
byte ip[] =     { 192, 168, 1, 5 };
byte DefaultRouter[] =     { 192, 168, 1, 1 };
byte DomainNameServer[] =     { 192, 168, 1, 1 };
byte SubnetMask[] = { 255, 255, 255, 0} ;
Ethernet.begin(mac, ip, DefaultRouter, DomainNameServer, SubnetMask );

PaulS:
There ?? must !! be $$ something @@ wrong ** with %% your || code.

Did the excess punctuation help? Yours didn’t, either.

byte mac = { 0x90, 0xA2, 0xDA, 0x10, 0x38, 0x53 };
IPAddress ip(12, 215, 1, 99)
IPAddress subnet(255, 255, 255, 0)
IPAddress gateway(12, 215, 1, 1)

void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial){;} // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
Ethernet.begin(mac, ip, gateway, subnet); // initialize Ethernet device
Serial.print("My IP address: ");

for (byte thisByte = 0; thisByte < 4; thisByte++) {
Serial.print(Ethernet.localIP()[thisByte]);
Serial.print(".");
}

}

void loop() {
//Serial.println(Ethernet.localIP());}
}

This my Code.but when i click to serial monitor i found that my ip daress is 0.118.118.118

johnwasser: byte gateway[] = { 255, 255, 255, 0} ;

Is that really the IP address of your default gateway router?!? Why did you not pass the name server address?!?

Try:

byte mac[] =    { 0x90, 0xA2, 0xDA, 0x10, 0x38, 0x53 };
byte ip[] =     { 192, 168, 1, 5 };
byte DefaultRouter[] =     { 192, 168, 1, 1 };
byte DomainNameServer[] =     { 192, 168, 1, 1 };
byte SubnetMask[] = { 255, 255, 255, 0} ;
Ethernet.begin(mac, ip, DefaultRouter, DomainNameServer, SubnetMask );

johnwasser: byte gateway[] = { 255, 255, 255, 0} ;

Is that really the IP address of your default gateway router?!? Why did you not pass the name server address?!?

Try:

byte mac[] =    { 0x90, 0xA2, 0xDA, 0x10, 0x38, 0x53 };
byte ip[] =     { 192, 168, 1, 5 };
byte DefaultRouter[] =     { 192, 168, 1, 1 };
byte DomainNameServer[] =     { 192, 168, 1, 1 };
byte SubnetMask[] = { 255, 255, 255, 0} ;
Ethernet.begin(mac, ip, DefaultRouter, DomainNameServer, SubnetMask );

johnwasser: byte gateway[] = { 255, 255, 255, 0} ;

Is that really the IP address of your default gateway router?!? Why did you not pass the name server address?!?

Try:

byte mac[] =    { 0x90, 0xA2, 0xDA, 0x10, 0x38, 0x53 };
byte ip[] =     { 192, 168, 1, 5 };
byte DefaultRouter[] =     { 192, 168, 1, 1 };
byte DomainNameServer[] =     { 192, 168, 1, 1 };
byte SubnetMask[] = { 255, 255, 255, 0} ;
Ethernet.begin(mac, ip, DefaultRouter, DomainNameServer, SubnetMask );

Thank you for your reply.

i impelemnt your code but still the same problem.

I print the IP before the command etherent.begin and after

Before it show 255.255.255.255 and after command it show 0.118.118.118

Try printing your IP address like this.

  // print your local IP address:
  Serial.println(Ethernet.localIP());