Ethernet (LAN RJ45) cable tester with Arduino

In this article you can find instruction on how to make a simple ethernet cable tester driven by an Arduino.

I was inspired by this page that simply and clearly describes how to make a tester for ethernet cables (straight or cross) with a master and a slave unit, so to be able to test also cable already in place.

I did nothing more than following the instructions and writing few lines of code for Arduino.

Hardware

What you need:

  • eight LED
  • eight resistor (I’ve used 33 ohm resistors)
  • two ethernet plug (female)
  • a switch (to be able to test straight and cross cables)
  • and, obviously, wires and two small pieces of board

We need to build to separate small boards:

  • a master board, that will be inserted into the Arduino and that will be plugged into one side of the ethernet cable that we need to test
  • a slave board, that will be plugged into the other side of the ethernet cable that we need to test

This is the circuit:

Software

The process implemented with the software is very simple:

  • Arduino set an HIGH value (5 V) on each wire of the cable for one second (and then reset a LOW value) one wire after the other
  • If everything is ok, you should see LEDs on the slave unit turning on one after the other for one second each
  • If there is some broken wire, the corresponding LED will not turn on
  • If there is some inverted wire in the cable, you will see the LEDs turning on not in a sequential order
  • The switch tells Arduino the type of cable under test (straight or cross)

This is the software:

//#define VERBOSE

char straight[8] = {2, 3, 4, 5, 6, 7, 8, 9};
char cross[8] = {4, 7, 2, 5, 6, 3, 8, 9};

void setup() {
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(12, INPUT); // Straight (normal) cable or cross cable
  pinMode(13, OUTPUT); // Control LED
#ifdef VERBOSE
  Serial.begin(9600);
#endif
}

void loop() {
  if (digitalRead(12) == LOW) { // Cross cable
#ifdef VERBOSE
    Serial.println("Cross cable");
#endif
    for (char n = 0;n < 8;n++) {
#ifdef VERBOSE
      Serial.print(n+1, DEC);
      Serial.print(": line ");
      Serial.print(cross[n]-1, DEC);
      Serial.print(" (pin ");
      Serial.print(cross[n], DEC);
      Serial.println(")");
#endif
      PulseOut(cross[n], 1000);
      PulseOut(13, 50);
    }
  } else { // Straight (normal) cable
#ifdef VERBOSE
    Serial.println("Straight cable");
#endif
    for (char n = 0;n < 8;n++) {
 #ifdef VERBOSE
      Serial.print(n+1, DEC);
      Serial.print(": line ");
      Serial.print(straight[n]-1, DEC);
      Serial.print(" (pin ");
      Serial.print(straight[n], DEC);
      Serial.println(")");
#endif
      PulseOut(straight[n], 1000);
      PulseOut(13, 50);
    }
  }
}

void PulseOut(char pin, int ms)
{
  digitalWrite(pin, HIGH);
  delay(ms);
  digitalWrite(pin, LOW);
}

The final result

These are the two separate boards of the tester (the master is the one connected to the Arduino):

And these are videos showing the cable tester at work. While testing a straight cable:

While testing a cross cable (when I change the switch):