Unleashing the BCRHammer: Ethernet Networking

Welcome to BCRHammer Networking

The BCRHammer board brings robust wired networking to your projects with its integrated W5500 Ethernet module. Whether you’re building IoT hubs, web servers, or networked controllers, this guide will walk you through programming your BCRHammer to connect online with an Arduino sketch. With built-in Power over Ethernet (PoE) support, it’s a powerhouse right out of the box—no extra shields needed. Just plug in an Ethernet cable, code it up, and join the networked world!

What You’ll Need

The BCRHammer is a complete package—here’s your starter kit:

  • BCRHammer Board: Grab it from our shop—includes the ESP32 and W5500 with PoE.
  • Ethernet Cable: Standard RJ45 (CAT5/6)—use a PoE switch or injector for cable power.
  • USB Cable: For programming and initial power (optional with PoE).
  • Arduino IDE: Download from arduino.cc.

No assembly required—the BCRHammer has it all built in!

Understanding the Pins

The W5500 Ethernet module on the BCRHammer leverages the ESP32’s HSPI bus and a reset pin, all pre-wired:

W5500 PinESP32 PinRole
SCK35SPI Clock—syncs data transfer.
MISO34SPI Master In Slave Out—data from W5500.
MOSI25SPI Master Out Slave In—data to W5500.
CS (SS)16Chip Select—activates the W5500.
RESET9Reset—reboots the W5500 if needed.

Plug and Play: These pins are hardwired on the BCRHammer—no jumper wires or soldering!

Power Over Ethernet (PoE) Hookup

With PoE, your BCRHammer can draw power directly from the Ethernet cable—perfect for remote setups. Here’s how it’s rigged:

  • PoE Module: An onboard PoE splitter (e.g., AG9900-compatible) extracts 3.3V from the cable, powering the ESP32 and W5500.
  • RJ45 Jack: Supports PoE (IEEE 802.3af)—plug into a PoE switch or injector.
  • Wiring Inside:
    • Pins 4, 5 (Blue Pair): Positive DC (48V from PoE source).
    • Pins 7, 8 (Brown Pair): Ground return.
    • Pins 1, 2, 3, 6: Data lines to W5500 for networking.
  • Power Output: The splitter converts 48V to 3.3V via a regulator, feeding the board seamlessly.
ComponentConnectionNotes
RJ45 JackPoE SplitterInputs 48V PoE.
PoE SplitterW5500 VCC/GNDSupplies 3.3V to W5500.
PoE SplitterESP32 3.3V/GNDPowers the ESP32.

PoE Power: Use a PoE switch or injector (48V 802.3af). USB is only for programming—unplug it after setup if using PoE!

Required Libraries

The BCRHammer’s W5500 relies on two standard Arduino libraries, included with the IDE:

  • SPI Library (SPI.h): Manages the HSPI bus for communication—pre-installed with Arduino IDE.
  • Ethernet Library (Ethernet.h): Drives the W5500 Ethernet module—also built-in (version 2.0.0+ recommended).

Setup Steps:

  1. Install the Arduino IDE from arduino.cc.
  2. Add ESP32 support:
    • File > Preferences: Add https://raw.githubusercontent.com/espressif/arduino-esp32/master/package_esp32_index.json to “Additional Boards Manager URLs”.
    • Tools > Board > Boards Manager: Search “ESP32”, install “esp32” by Espressif.
  3. Select your board: Tools > Board > ESP32 Arduino > ESP32 Dev Module.

No extra downloads—just the IDE’s defaults get you going!

The BCRHammer Ethernet Sketch

This sketch turns your BCRHammer into a web server, serving a hello page. Paste it into the Arduino IDE:

// BCRHammer Ethernet Web Server Sketch
#include        // SPI library for HSPI
#include   // Ethernet library for W5500

// BCRHammer’s W5500 pinout
#define ETH_SCK    35  // SPI Clock—data sync pulse
#define ETH_MISO   34  // Master In Slave Out—W5500 replies
#define ETH_MOSI   25  // Master Out Slave In—ESP32 sends
#define ETH_CS     16  // Chip Select—W5500’s “on” switch
#define ETH_RESET  9   // Reset—reboots W5500

// MAC address—unique to your BCRHammer
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// Static IP—match your network
IPAddress ip(192, 168, 1, 177);

// Web server on port 80
EthernetServer server(80);

void setup() {
  Serial.begin(115200);  // Serial for debugging
  while (!Serial);

  // Initialize HSPI with BCRHammer pins
  SPI.begin(ETH_SCK, ETH_MISO, ETH_MOSI, ETH_CS);

  // Reset W5500—pulse low then high
  pinMode(ETH_RESET, OUTPUT);
  digitalWrite(ETH_RESET, LOW);
  delay(100);
  digitalWrite(ETH_RESET, HIGH);
  delay(100);

  // Start Ethernet with static IP
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("Server running at: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  // Check for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("New client connected");
    // Wait for client request
    while (!client.available()) {
      delay(1);
    }

    // Read request (simplified)
    String request = client.readStringUntil('\r');
    Serial.println(request);
    client.flush();

    // Send a basic web page
    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println("Connection: close");
    client.println();
    client.println("");
    client.println("");
    client.println("

Hello from BCRHammer!

"
); client.println("

Your Ethernet-powered BCRHammer is online.

"
); client.println(""); // Close connection delay(1); client.stop(); Serial.println("Client disconnected"); } }

Quick Start: Connect your BCRHammer to an Ethernet cable (PoE switch for cable power), plug in USB for programming, upload this sketch, and open the Serial Monitor (115200 baud). Visit the IP (e.g., 192.168.1.177) in your browser to see it live!

Unpacking the Code: A Deep Dive

Let’s break this sketch down to master the BCRHammer’s Ethernet capabilities.

1. Loading the Libraries

// Default libraries for Ethernet
#include        // SPI for HSPI bus
#include   // W5500 networking

SPI.h powers the HSPI bus, and Ethernet.h—included with the Arduino IDE—drives the W5500. These are your built-in tools for networking magic!

2. Defining the BCRHammer Pins

// BCRHammer’s W5500 pinout
#define ETH_SCK    35  // SPI Clock—data sync pulse
#define ETH_MISO   34  // W5500 sends data back
#define ETH_MOSI   25  // ESP32 sends data out
#define ETH_CS     16  // Chip Select—W5500’s “on” switch
#define ETH_RESET  9   // Reset—reboots W5500

These pins are pre-wired on the BCRHammer’s HSPI bus—SCK, MISO, MOSI, and CS handle SPI, while RESET keeps the W5500 fresh.

3. Configuring the Network

// Network identifiers
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  // Unique MAC
IPAddress ip(192, 168, 1, 177);                       // Static IP
EthernetServer server(80);                            // Port 80 server

The MAC is a unique ID—tweak it if running multiple boards. The IP fits typical home networks (adjust to your router’s range). Port 80 is the web standard.

4. Initializing in Setup

void setup() {
  Serial.begin(115200);  // Serial for logs
  while (!Serial);

  SPI.begin(ETH_SCK, ETH_MISO, ETH_MOSI, ETH_CS);  // HSPI start

  pinMode(ETH_RESET, OUTPUT);  // Reset W5500
  digitalWrite(ETH_RESET, LOW);
  delay(100);
  digitalWrite(ETH_RESET, HIGH);
  delay(100);

  Ethernet.begin(mac, ip);  // Connect to network
  server.begin();
  Serial.print("Server running at: ");
  Serial.println(Ethernet.localIP());
}
  • Serial: 115200 baud—check the IP here.
  • SPI.begin: Kicks off HSPI with your pins.
  • Reset: Pulses RESET low then high—clears the W5500.
  • Ethernet.begin: Sets MAC and IP, linking up.
  • server.begin: Starts the web server.

5. Serving Pages in Loop

void loop() {
  EthernetClient client = server.available();
  if (client) {
    Serial.println("New client connected");
    while (!client.available()) {
      delay(1);
    }

    String request = client.readStringUntil('\r');
    Serial.println(request);
    client.flush();

    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println("Connection: close");
    client.println();
    client.println("");
    client.println("");
    client.println("

Hello from BCRHammer!

"
); client.println("

Your Ethernet-powered BCRHammer is online.

"
); client.println(""); delay(1); client.stop(); Serial.println("Client disconnected"); } }
  • Client Check: Waits for browser hits.
  • Request: Reads the HTTP request and logs it.
  • Response: Serves a simple page—“200 OK” means success.
  • Close: Ends the connection.

Level Up Your BCRHammer

Push it further:

  • DHCP: Use Ethernet.begin(mac)—router assigns IP.
  • Pin Control: Add if (request.indexOf("/on") > -1) digitalWrite(2, HIGH);—toggle pin 2 via “/on”.
  • Dashboard: Expand HTML with real-time data!

Get Yours: Snag a BCRHammer from our shop and get networked. Need help? We’re here!