Go Down

Topic: How do I set up the ethernet on Arduino NOT using DHCP ? (Read 609 times) previous topic - next topic

Quest UK

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: [Select]


#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);
}






SurferTim

This is how this should be set up.
Code: [Select]

  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.

Go Up