Projects / Wired Ethernet sensor node

Wired Ethernet sensor node

Intermediate2 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. ESP32W5500

    Wire the W5500

    SPI, reset and power.

  2. ESP32

    Get an address

    DHCP on your router.

  3. ESP32BME28024.0°C

    Read the BME280

    Print values.

  4. ESP32

    Serve the page

    Open it in a browser.

  5. ESP32

    Publish to MQTT

    Watch with a subscriber.

  6. ESP32

    Pull the cable

    See it reconnect.

  7. ESP32

    Compare with Wi-Fi

    Count dropouts over a day.

In short

How do you build a wired Ethernet sensor node?

A W5500 Ethernet module gives a sensor a reliable wired link for places where Wi-Fi is poor. You need ESP32 DevKit V1, W5500 Ethernet module, BME280 Environmental Sensor, Ethernet cable Cat6 (3 m) and 5 V 2 A USB adapter. It takes 7 steps and about 120 minutes.

Level
Intermediate
Time
About 120 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
W5500 SCS (CS)ESP32 GPIO5Chip select
W5500 SCLK, MISO, MOSIESP32 GPIO18, GPIO19, GPIO23SPI
W5500 RSTESP32 GPIO4Reset
W5500 VCC and GNDAs marked on your module (3.3 V or 5 V) and GNDPower
BME280 SDA and SCLESP32 GPIO21 and GPIO22Sensor
BME280 VIN and GNDESP32 3V3 and GNDPower
Ethernet cableRouter or switch portWired link
ESP32 VIN5 V adapterPower

Code

Wired Ethernet does not drop out when a microwave runs or a wall is thick, and it can power nothing but needs no password, which is why it suits a workshop, a pump house or a sensor in a long metal cabinet. The W5500 handles the network protocols in hardware, so the ESP32 just talks to it over SPI. First check what voltage your module wants on VCC, because many boards have an on-board regulator and expect 5 V while bare chips expect 3.3 V. The sketch gets an address by DHCP, serves a tiny status page you can open from any computer, and publishes to an MQTT broker on your own network every 30 seconds; put your broker's address in BROKER. The page and the broker traffic are not encrypted, so keep the node on your own network and never forward its port to the internet. Pull the cable and plug it back to see it recover. Arduino IDE with the ESP32 boards package 2.0.x, board "ESP32 Dev Module".

Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Wired sensor node: DHCP, a small status page and an MQTT publish. Libraries: Ethernet, Adafruit BME280, PubSubClient.
// Board: ESP32 Dev Module.
#include <SPI.h>
#include <Ethernet.h>
#include <Adafruit_BME280.h>
#include <PubSubClient.h>
byte mac[] = {0x02, 0xAB, 0xCD, 0x00, 0x00, 0x01};  // locally administered address: change it if you build several
const IPAddress BROKER(192, 168, 1, 10);            // your MQTT broker on the local network
EthernetServer web(80);
EthernetClient net;
PubSubClient mqtt(net);
Adafruit_BME280 bme;
unsigned long lastPub = 0;
void setup() {
  Serial.begin(115200);
  pinMode(4, OUTPUT); digitalWrite(4, LOW); delay(50); digitalWrite(4, HIGH); delay(200);   // reset the W5500
  Ethernet.init(5);
  if (Ethernet.begin(mac) == 0) { Serial.println("No DHCP address"); while (true) delay(1000); }
  Serial.print("IP "); Serial.println(Ethernet.localIP());
  bme.begin(0x76);
  web.begin();
  mqtt.setServer(BROKER, 1883);
}
void loop() {
  Ethernet.maintain();                              // renew the DHCP lease
  EthernetClient c = web.available();
  if (c) {
    while (c.connected() && c.available()) c.read();       // read and ignore the request
    c.println("HTTP/1.1 200 OK"); c.println("Content-Type: text/html"); c.println("Connection: close"); c.println();
    c.print("<html><body><h3>Sensor node</h3>Temperature ");
    c.print(bme.readTemperature(), 1); c.print(" C<br>Humidity "); c.print(bme.readHumidity(), 0);
    c.print(" %<br>Pressure "); c.print(bme.readPressure() / 100.0, 0); c.println(" hPa</body></html>");
    delay(1); c.stop();
  }
  if (millis() - lastPub > 30000UL) {
    lastPub = millis();
    if (!mqtt.connected()) mqtt.connect("wired-node-1");
    if (mqtt.connected()) {
      mqtt.publish("home/wired/temperature", String(bme.readTemperature(), 1).c_str());
      mqtt.publish("home/wired/humidity", String(bme.readHumidity(), 0).c_str());
    }
  }
  mqtt.loop();
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
BootPrints an IP address
BrowserShows live readings
MQTTMessages every 30 seconds
Cable unplugged and repluggedNode recovers

If it does not work

No DHCP

Check the cable and the module power.

Page does not open

Check the IP address and the firewall.

Reboots

Give the module a stable supply.

MQTT fails

Check the broker address and port.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the wired Ethernet sensor node?

ESP32 DevKit V1, W5500 Ethernet module, BME280 Environmental Sensor, Ethernet cable Cat6 (3 m) and 5 V 2 A USB adapter.

How long does the wired Ethernet sensor node take to build?

About 120 minutes for a intermediate maker, in 7 steps.

How do I know the wired Ethernet sensor node works?

Boot: Prints an IP address. Browser: Shows live readings. MQTT: Messages every 30 seconds.

No DHCP: what should I check?

Check the cable and the module power.

Page does not open: what should I check?

Check the IP address and the firewall.

Reboots: what should I check?

Give the module a stable supply.

MQTT fails: what should I check?

Check the broker address and port.