No IP address when set static IP address


I am a pretty inexperienced arduino/electronics guy.

I am currently trying to set up a turnstile monitoring system. Fairly easy setup. as the turnstile already had a relay that I can connect to. Everything seemed fine during development and dry testing ( on my desk ). But when I installed it on the turnstile, I encountered a problem that the arduino even though configured with a static IP address would boot up without IP address. Was wondering if someone could help me with this and explain what I have done wrong.

So I am using a Uno with an ethernet shield.

Wiring is simple. I put a cable from the 5v pin to the relay and then from the relay back to pin 13. Then I added a 10k resistor from pin 13 to GND. Note: I have tried other pins and have the same problem.

I narrowed the problem down, that the relay is an always open relay. so as soon as I wire up the arduino, the 5v is connected to pin 13. If I disconnect the 5v from the relay, boot up the arduino and then connect the 5v again to the relay it works perfectly fine.

The reason why I say that the arduino doesn't have an IP is because I output the IP on the serial console.

Here is the code that I am using.

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

const int TURNSTILE = 5;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 };

IPAddress dnServer(8, 8, 8, 8);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress ip(192,168,1,105);

//IPAddress gateway(10, 0, 0, 1);
//IPAddress subnet(255, 255, 255, 255);
//IPAddress ip(10,0,0,108);

const int buttonPin = 13;    

String PATH_NAME   = "/somescript.php?t=";
int    HTTP_PORT   = 80;
String HTTP_METHOD = "GET"; // or POST
char   HOST_NAME[] = "";

EthernetClient client;

int buttonState;             
int lastButtonState = LOW;   

unsigned long lastDebounceTime = millis();  
unsigned long debounceDelay = 40;    

unsigned long lastTime = millis();

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  // initialize the Ethernet shield using DHCP:

void loop() {
  int reading = digitalRead(buttonPin);
  if (reading != lastButtonState) {
    lastDebounceTime = millis();
  if ((millis() - lastDebounceTime) > debounceDelay) {
    if (reading != buttonState) {
      buttonState = reading;
      if (buttonState == LOW) {
  lastButtonState = reading;


void recordEntry( int turn) {
   if(client.connect(HOST_NAME, HTTP_PORT)) {
    Serial.println(HTTP_METHOD + " " + PATH_NAME + turn + " HTTP/1.1)");
    client.println(HTTP_METHOD + " " + PATH_NAME + turn + " HTTP/1.1");
    client.println("Host: " + String(HOST_NAME));
    client.println("Connection: close");


Can anyone point out what I am doing wrong? Why does the arduino not boot up if there is 5V to the pin I am using?


How much power does your relay draw? Power is the most likely problem given what you describe. Do you have a link to the specsheet for the relay?

I would put a client.stop() at the end of your recordEntry routine otherwise you are just losing connections or better create the client connection in setup - see Arduino - ClientConnect

I don't power the relay with the arduino. I just read the state. So it really doesn't draw any power.

And also as I mentioned. If I disconnect the 5v first, and power the arduino and then reconnect the 5v it all works perfectly.

I just read somewhere that PIN13 on the ethernet shield is used for timing or something like that. So I stopped using pins13 to pin10 as they all have a line under their pin name on the board. Moved to digital pin2 instead and it all seems to be working now.

Strange one.

Thanks to anyone that took time to look through this issue.

On an Uno, pins 10, 11, 12 and 13 are the SPI pins. Depending on your needs you can use pin 10 for other purposes. If the Uno is a SPI master, pin 10 must be used as an output; if the Uno is used as a SPI slave, it must be used as an input.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.