Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based RJ45 Cable Tester with LED Indicators and Buzzer

View and Edit Project In Cirkit DesignerImage of ESP32-Based RJ45 Cable Tester with LED Indicators and Buzzer

Circuit Documentation

Summary

This circuit involves an ESP32 microcontroller interfacing with various components including LEDs, resistors, a buzzer, an LCD display, an RJ45 connector, and a pushbutton. The circuit is designed to test the continuity and measure the length of cables connected to the RJ45 connector. The ESP32 controls the LEDs and buzzer to indicate the status of the test, and the results are displayed on the LCD.

Component List

  1. LED: Two Pin (green)

    • Pins: cathode, anode
    • Description: Green LED used for visual indication.
  2. LED: Two Pin (red)

    • Pins: cathode, anode
    • Description: Red LED used for visual indication.
  3. Resistor

    • Pins: pin1, pin2
    • Description: 220 Ohms resistor used for current limiting.
    • Properties:
      • Resistance: 220 Ohms
  4. buzzer

    • Pins: PIN, GND
    • Description: Buzzer used for audible indication.
  5. ESP32 Devkit V1

    • Pins: 3V3, GND, D15, D2, D4, RX2, TX2, D5, D18, D19, D21, RX0, TX0, D22, D23, EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, VIN
    • Description: Microcontroller used to control the circuit.
  6. RJ45

    • Pins: R1+, R1-, R2+, R2-, R3+, R3-, 5V, GND
    • Description: RJ45 connector used for cable testing.
  7. MKE-M07 LCD1602 I2C

    • Pins: GND, 5V, SDA, SCL
    • Description: LCD display used to show test results.
  8. Pushbutton

    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
    • Description: Pushbutton used to initiate the test.

Wiring Details

LED: Two Pin (green)

LED: Two Pin (red)

Resistor (220 Ohms)

Resistor (220 Ohms)

buzzer

ESP32 Devkit V1

RJ45

MKE-M07 LCD1602 I2C

Pushbutton

Code Documentation

Code for ESP32 Devkit V1 (Instance 1)

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Define the GPIO pins connected to the Female RJ45
const int female_rj45_pins[8] = {25, 26, 27, 32, 33, 34, 35, 14};

// Define the GPIO pins for the LEDs
const int greenLED = 2;
const int redLED = 4;

// Define the GPIO pin for the buzzer
const int buzzerPin = 5;

// Create an LCD object connected to I2C (address 0x27)
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Speed of signal in wire (in meters per microsecond)
const float signalSpeed = 0.0343;

// Wire colors
const char* wireColors[8] = {
  "Orange/White",
  "Orange",
  "Green/White",
  "Blue",
  "Blue/White",
  "Green",
  "Brown/White",
  "Brown"
};

void setup() {
  Serial.begin(115200);

  // Initialize the LCD
  lcd.init();
  lcd.backlight();
  lcd.clear();

  // Initialize the GPIO pins for Female RJ45
  for (int i = 0; i < 8; i++) {
    pinMode(female_rj45_pins[i], INPUT_PULLUP);
  }

  // Initialize the GPIO pins for LEDs
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  digitalWrite(greenLED, LOW);
  digitalWrite(redLED, LOW);

  // Initialize the GPIO pin for the buzzer
  pinMode(buzzerPin, OUTPUT);
  digitalWrite(buzzerPin, LOW);
}

void loop() {
  // Start the test
  runTest();
  delay(1000); // Delay for readability
}

void runTest() {
  bool allConnected = true;
  lcd.clear();

  // Continuity Testing for Female RJ45
  for (int i = 0; i < 8; i++) {
    int state = digitalRead(female_rj45_pins[i]);
    if (state == HIGH) {
      Serial.print("Female Wire ");
      Serial.print(i + 1);
      Serial.print(" (");
      Serial.print(wireColors[i]);
      Serial.println(") is connected.");
    } else {
      Serial.print("Female Wire ");
      Serial.print(i + 1);
      Serial.print(" (");
      Serial.print(wireColors[i]);
      Serial.println(") is not connected.");
      lcd.setCursor(0, i % 2);
      lcd.print(wireColors[i]);
      lcd.print(" not conn");
      allConnected = false;
    }
  }

  // Distance Measurement
  if (allConnected) {
    lcd.setCursor(0, 0);
    lcd.print("All wires conn");
    lcd.setCursor(0, 1);
    lcd.print("Length: ");
    lcd.print(measureLength());
    lcd.print(" m");

    // Indicate success
    digitalWrite(greenLED, HIGH);
    digitalWrite(buzzerPin, HIGH);
    delay(100);
    digitalWrite(buzzerPin, LOW);
    delay(100);
    digitalWrite(buzzerPin, HIGH);
    delay(100);
    digitalWrite(buzzerPin, LOW);
    digitalWrite(greenLED, LOW