Pages: [1]   Go Down
Author Topic: How do I set up the ethernet on Arduino NOT using DHCP ?  (Read 555 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 49
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have scoured the internet but cannot find an answer.

I have a project running that sends data via the Ethernet port shield on my Arduino. This is working faultlessly but I have run out of program space in the Arduino to add more functions that I need to add.

I have read that using DHCP uses a lot of code.

What do i need to add to my program to get it to communicate with HTTP port 80 without using DHCP ?

Regards

Gary

Pseudo code below

Code:

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

 byte server[]         = {192,168,1,64};                                                       
 byte ip[]               = {192,168,1,1};                                                       // *** All must be unique ***
 byte mac[]            = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };                  // *** All must be unique ***
 byte gateway []    = { 192,168,1,254};   

void setup()
{

  EthernetClient ethClient(80);                                                               // IS THIS CORRECT
  Ethernet.begin(mac, ip, gateway);
}




Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 148
Posts: 6103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is how this should be set up.
Code:
  Ethernet.begin(mac, ip, gateway, gateway);
I know it looks redundant, but the first "gateway" ip is for the dns, and the second is the gateway. Otherwise, it assigns 192.168.1.1 as the gateway, and that is your ethernet shield ip, not the router gateway.
Logged

Pages: [1]   Go Up
Jump to: