# W5500 and UWB not Working Together

**URL:** <https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577>\
**Category:** Networking, Protocols, and Devices\
**Created:** [September 14, 2024, 1:21pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577 "2024-09-14T13:21:02Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![hamzamalik69](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@hamzamalik69](https://forum.arduino.cc/u/hamzamalik69)\
**Post date:** [September 14, 2024, 1:21pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/1 "2024-09-14T13:21:03Z")

</div>

Hi everyone How are you.I am working on a Project right now in which I am using Esp32 with UWB to get distance. Now We can also send reading received by MQTT but I need to get the readings by Ethernet via W5500 Module. No when write code only for uwb i can get the distance readings from another similar PCB.But when I add code for W5500 both devices are initialized but UWB is not getting reading from Tag and When i add delay to initializw W5500 the I can recieve distance readings but W5500 failed to initliazed.Please Note W5500 and UWB are on Seprate SPI busses W5500 is on HSPI with different Cs and UWB is on VSPI.Can any body has any idea why this is happening.As i am using seprate SPI busses why its not working properly I can share more If any one has idea about this Thanks

---

<div class="post-metadata">

**Author:** ![hamzamalik69](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@hamzamalik69](https://forum.arduino.cc/u/hamzamalik69)\
**Post date:** [September 14, 2024, 1:22pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/2 "2024-09-14T13:22:35Z")

</div>

I amusing Ethernet lib for W5500.Also below you can take a look at my code

```arduino
#include <SPI.h>
#include <Ethernet.h>
#include "DW1000Ranging.h"
 
// SPI pins for W5500
#define HSPI_SCK 14
#define HSPI_MISO 12
#define HSPI_MOSI 13
 
// Chip Select pin for W5500  
#define W5500_CS 15
 
// SPI pins for UWB
#define SPI_SCK 18
#define SPI_MISO 19
#define SPI_MOSI 23
#define DW_CS 5
 
// Control Pins for UWB
const uint8_t PIN_RST = 27; // reset pin
const uint8_t PIN_IRQ = 34; // irq pin
const uint8_t PIN_SS = 5; // spi select pin
 
// Ethernet configuration
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // MAC address for W5500
IPAddress ip(192, 168, 1, 178); // Static IP address for W5500
IPAddress myDns(8, 8, 8, 8); // DNS server
IPAddress gateway(192, 168, 1, 1); // Gateway
IPAddress subnet(255, 255, 255, 0); // Subnet mask
 
EthernetServer server(23); // Create a server that listens on port 23
 
// Calibration Range for UWB
float calibrationRange = 0.78;
 
void setup() {
  Serial.begin(115200);
  delay(1000);
 
  // Initialize the SPI bus for W5500
  SPI.begin(HSPI_SCK, HSPI_MISO, HSPI_MOSI);
 
  // Initialize W5500 Ethernet module with static IP
  Serial.println("Initializing W5500...");
  Ethernet.init(W5500_CS);
  Ethernet.begin(mac, ip, myDns, gateway, subnet);
 
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("W5500 not found. Check wiring.");
  } else if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  } else {
    Serial.println("Ethernet initialized successfully.");
    Serial.print("IP Address: ");
    Serial.println(Ethernet.localIP());
  }
 
  server.begin(); // Start the TCP server
 
  // Initialize SPI for UWB
  SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
  DW1000Ranging.initCommunication(PIN_RST, PIN_SS, PIN_IRQ);
 
  // Define the sketch as anchor
  DW1000Ranging.attachNewRange(newRange);
  DW1000Ranging.attachBlinkDevice(newBlink);
  DW1000Ranging.attachInactiveDevice(inactiveDevice);
 
  DW1000.enableDebounceClock();
  DW1000.enableLedBlinking();
  DW1000.setGPIOMode(MSGP0, LED_MODE);
 
  // Start the module as an anchor
  DW1000Ranging.startAsAnchor("82:17:5B:D5:A9:9A:E2:9C", DW1000.MODE_LONGDATA_RANGE_LOWPOWER);
}
 
void loop() {
  DW1000Ranging.loop();
 
  // Check if a client has connected
  EthernetClient client = server.available();
  if (client) {
    Serial.println("New client connected");
    while (client.connected()) {
      // Get the range data
      String message = getRangeData();
     
      // Show message on serial monitor
      Serial.println("Sending to client: " + message);
     
      // Send the message to the client
      client.println(message);  
     
      delay(1000); // Send the message every second
    }
    // Close the connection
    client.stop();
    Serial.println("Client disconnected");
  }
}
 
// Function to get the range data
String getRangeData() {
  String data = "";
  if (DW1000Ranging.getDistantDevice()) {
    data += "from: ";
    data += DW1000Ranging.getDistantDevice()->getShortAddress(), HEX;
    data += "\t Range: ";
    data += DW1000Ranging.getDistantDevice()->getRange() * calibrationRange;
    data += " m\t RX power: ";
    data += DW1000Ranging.getDistantDevice()->getRXPower();
    data += " dBm";
  }
  return data;
}
 
void newRange() {
  Serial.print("from: "); Serial.print(DW1000Ranging.getDistantDevice()->getShortAddress(), HEX);
  Serial.print("\t Range: "); Serial.print(DW1000Ranging.getDistantDevice()->getRange() * calibrationRange); Serial.print(" m");
  Serial.print("\t RX power: "); Serial.print(DW1000Ranging.getDistantDevice()->getRXPower()); Serial.println(" dBm");
}
 
void newBlink(DW1000Device* device) {
  Serial.print("blink; 1 device added ! -> ");
  Serial.print(" short:");
  Serial.println(device->getShortAddress(), HEX);
}
 
void inactiveDevice(DW1000Device* device) {
  Serial.print("delete inactive device: ");
  Serial.println(device->getShortAddress(), HEX);
}

```

---

<div class="post-metadata">

**Author:** ![gilshultz](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gilshultz](https://forum.arduino.cc/u/gilshultz)\
**Post date:** [September 14, 2024, 2:53pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/3 "2024-09-14T14:53:36Z")

</div>

> [@hamzamalik69](#):
>
> I am using Esp32 with UWB to get distance

Please do the following:

1. **Annotated Schematic:**

- Show how your circuit is wired, including all connections, power sources, ground lines, and any other relevant components.
- Clearly label each part in the schematic, especially critical components like displays, relays, contactors, sensors, and controllers.

1. **Technical Information Links:**

- Provide links to the datasheets or technical documentation for each component. This information helps us understand the specifications, pin configurations, and electrical characteristics of the parts involved. Spell out any acronyms, as many readers may not be familiar with them.
- Avoid links to sales pages like Amazon unless they include complete technical details; instead, look for manufacturer or supplier datasheets.

### **Why This is Important:**

- **Accurate Diagnosis:** An annotated schematic helps identify issues such as incorrect wiring, missing components, or potential sources of interference.
- **Proper Recommendations:** Understanding the exact parts used allows us to suggest the right mitigation techniques, such as specific filters, grounding methods, or alternative components.
- **Time-Saving:** Providing this information upfront saves time and helps avoid multiple back-and-forth exchanges, leading to faster and more effective troubleshooting.

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [September 14, 2024, 3:39pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/4 "2024-09-14T15:39:36Z")

</div>

I moved your topic to an appropriate forum category @hamzamalik69 .

In the future, please take some time to pick the [forum category](https://forum.arduino.cc/categories) that best suits the subject of your topic. There is an " **About the \_\_\_\_\_ category**" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in [the " **How to get the best out of this forum**" guide](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966). The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

---

<div class="post-metadata">

**Author:** ![hamzamalik69](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@hamzamalik69](https://forum.arduino.cc/u/hamzamalik69)\
**Post date:** [September 14, 2024, 3:58pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/5 "2024-09-14T15:58:16Z")

</div>

Hi Below you can find schematic and PCb layout of my circuit,and also you can find link for datasheet of relevant components.

 ![ESP32](https://europe1.discourse-cdn.com/arduino/original/4X/5/9/5/5958c32d7ca131d63318ce25299e55c3a87ded07.png)  
 ![Schematic Whole](https://europe1.discourse-cdn.com/arduino/original/4X/a/4/4/a44774a936639a36a33967f1cb8c3342dd29338b.png)  
 ![UWB](https://europe1.discourse-cdn.com/arduino/original/4X/7/9/4/794659a3a0585fe4b9d7bd7055e8be2fcf45d227.png)

[W5500 Ethernet Sheet Datasheet Link:](https://www.enmindustry.de/WebRoot/Store31/Shops/88169453/5FFE/A9C7/E740/BF9E/CE7C/0A0C/6D0C/C7CA/W5500-SPI-Ethernet-Datasheet_1.pdf)

W5500 Chip Datasheet: [https://cdn.sparkfun.com/datasheets/Dev/Arduino/Shields/W5500\_datasheet\_v1.0.2\_1.pdf](https://cdn.sparkfun.com/datasheets/Dev/Arduino/Shields/W5500_datasheet_v1.0.2_1.pdf)

ESP32-WROOM-32 Datasheet ://www.espressif.com/sites/default/files/documentation/esp32-wroom-32d\_esp32-wroom-32u\_datasheet\_en.pdf

UWB-DWM1000 Datasheet: [https://www.mouser.de/pdfDocs/dwm1000-datasheet-1.pdf](https://www.mouser.de/pdfDocs/dwm1000-datasheet-1.pdf)

---

<div class="post-metadata">

**Author:** ![hamzamalik69](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@hamzamalik69](https://forum.arduino.cc/u/hamzamalik69)\
**Post date:** [September 14, 2024, 3:58pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/6 "2024-09-14T15:58:55Z")

</div>

Here are remaining Pictures

 ![PCB layout](https://europe1.discourse-cdn.com/arduino/original/4X/1/a/e/1ae26f66faff9b8b966c6f2b9e7a28610a02de98.png)  
 ![POWER Circuit](https://europe1.discourse-cdn.com/arduino/original/4X/a/6/0/a607ed2ef1b9430253f4fcc456a83c47ae57cd16.png)  
 ![W5500](https://europe1.discourse-cdn.com/arduino/original/4X/3/f/3/3f39b54dde78897d66a229a86b30a6c8f9aabc84.png)

---

<div class="post-metadata">

**Author:** ![hamzamalik69](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@hamzamalik69](https://forum.arduino.cc/u/hamzamalik69)\
**Post date:** [September 14, 2024, 3:59pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/7 "2024-09-14T15:59:41Z")

</div>

![3d View 2](https://europe1.discourse-cdn.com/arduino/original/4X/5/6/2/56251cddec9829ff848d90a0064f5b9ab7aaa660.png)  
 ![PCB 3D](https://europe1.discourse-cdn.com/arduino/original/4X/f/5/7/f57e858e4b07a7a64ddba79b46b3b1a6bd3625f1.png)

---

<div class="post-metadata">

**Author:** ![hamzamalik69](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@hamzamalik69](https://forum.arduino.cc/u/hamzamalik69)\
**Post date:** [September 14, 2024, 4:03pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/8 "2024-09-14T16:03:08Z")

</div>

Hi I am sending you links of datasheet of all components and uploading schematics.You can take a look.I think there is issue in Ethernet Library i am only using ethernet lib and not ethernet2 and ethernet3.Can you please take a look at circuit and my code if there is any issue thanks

(Attachment Anchor POE DATA Final.rar is missing)

---

<div class="post-metadata">

**Author:** ![gilshultz](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gilshultz](https://forum.arduino.cc/u/gilshultz)\
**Post date:** [September 15, 2024, 12:44am UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/9 "2024-09-15T00:44:07Z")

</div>

The W5500 is missing some bypass capacitors, the others look OK, I am assuming the values etc are correct. Why are you using two SPI busses? The middle schematic is not readable on my system. I am not familiar with the libraries but do they define the SPI pins and if so are they the correct ones. I have seen different declarations of the SPI pins in the past. It has been a while and I do not remember which library(s) had the problem.

---

<div class="post-metadata">

**Author:** ![hamzamalik69](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@hamzamalik69](https://forum.arduino.cc/u/hamzamalik69)\
**Post date:** [September 15, 2024, 8:53am UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/10 "2024-09-15T08:53:40Z")

</div>

I am using Two Separate SPI to avoid Data Collisions As i need both devices active at the same time so there might be a data collision. Both devices gets initialized that is UWB and W5500 but the UWB is not getting distance, If add delay for W5500 the UWB immediately Gets readings but after delay When W5500 tries to initialize it fails. The capacitors where I need to add the W5500 is proper ethernet shield all the required components are there thanks I will share the SPI Busses from ESP32 website

 ![SPI](https://europe1.discourse-cdn.com/arduino/original/4X/5/5/5/555946fbb537a49fad02b33c30b80b2c226c29a6.png)

---

<div class="post-metadata">

**Author:** ![hamzamalik69](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@hamzamalik69](https://forum.arduino.cc/u/hamzamalik69)\
**Post date:** [September 15, 2024, 10:48am UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/11 "2024-09-15T10:48:35Z")

</div>

Also can you please check the code combination of W5500 and UWB may be there is issue in code combination thanks

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [September 15, 2024, 2:21pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/12 "2024-09-15T14:21:59Z")

</div>

does the Ethernet module work by itself in a separate program with no other devices connected?  
have you tried [EthernetESP32 library](https://github.com/Networking-for-Arduino/EthernetESP32) - note it requires ESP32 platform version 3 or higher - I have used it with both VSPI and HSPI

```arduino
// ESP32/W5500 ethernet using HSPI interface

// W5500 SCK to HSPI_SCK GPIO14
// W5500 MOSI to HSPI_MOSI GPIO13
// W5500 MISO to HSPI_MISO GPIO12
// W5500 SCS to HSPI_CS GPIO15
// W5500 3.3V to ESP32 3.3V
// W5500 GND to ESP32 GND

```

---

<div class="post-metadata">

**Author:** ![hamzamalik69](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@hamzamalik69](https://forum.arduino.cc/u/hamzamalik69)\
**Post date:** [September 15, 2024, 2:35pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/13 "2024-09-15T14:35:29Z")

</div>

Yes the module is working fine alone as it is initialized and I can get data from it can view it from wire shark. Can you please take look at the combination of code for uwb ans w5500 may be it’s blocking in one way or other  
No i did not try with EthernetESP lib  
If you have code using ethernetESP lib please can you share it  
Thanks

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [September 15, 2024, 2:44pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/14 "2024-09-15T14:44:44Z")

</div>

W5500 using ESP32 HSPI helloServer example

```cpp
// ESP32/W5500 ethernet using HSPI interface

// W5500 SCK to HSPI_SCK GPIO14
// W5500 MOSI to HSPI_MOSI GPIO13
// W5500 MISO to HSPI_MISO GPIO12
// W5500 SCS to HSPI_CS GPIO15
// W5500 3.3V to ESP32 3.3V
// W5500 GND to ESP32 GND

/*
 * HelloServer example from the ESP32 WebServer library modified for Ethernet.
 */

#include <EthernetESP32.h>
#include <WebServer.h>
#include <ESPmDNS.h>

W5500Driver driver(15); // HSPI SS is GPIO15
//ENC28J60Driver driver;
//EMACDriver driver(ETH_PHY_LAN8720);

SPIClass hspi(HSPI); // HSPI object used by W5500

WebServer server(80);

const int led = 13;

void handleRoot() {
  digitalWrite(led, 1);
  server.send(200, "text/plain", "hello from esp32!");
  digitalWrite(led, 0);
}

void handleNotFound() {
  digitalWrite(led, 1);
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i = 0; i < server.args(); i++) {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
  digitalWrite(led, 0);
}

void setup(void) {
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  Serial.begin(115200);
  delay(2000);
  while (!Serial)
    ;
  driver.setSPI(hspi); // specify driver SPI interface
  Ethernet.init(driver); // initialise driver
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin()) {
    Serial.print(" DHCP assigned IP ");
    Serial.println(Ethernet.localIP());
  } else {
    Serial.println("Failed to configure Ethernet using DHCP");
    while (true) {
      delay(1);
    }
  }
  if (MDNS.begin("esp32")) {
    Serial.println("MDNS responder started");
  }
  server.on("/", handleRoot);
  server.on("/inline", []() {
    server.send(200, "text/plain", "this works as well");
  });
  server.onNotFound(handleNotFound);
  server.begin();
  Serial.println("HTTP server started");
}

void loop(void) {
  server.handleClient();
  delay(2); //allow the cpu to switch to other tasks
}

```

serial monitor output

```arduino
Initialize Ethernet with DHCP:
  DHCP assigned IP 192.168.1.65
MDNS responder started
HTTP server started

```

PC we client  
 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/7/6/b/76b99b35300df6b74edfc1d5e30df1d45f330582.png)

---

<div class="post-metadata">

**Author:** ![gilshultz](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gilshultz](https://forum.arduino.cc/u/gilshultz)\
**Post date:** [September 15, 2024, 7:01pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/15 "2024-09-15T19:01:02Z")

</div>

**SPI (Serial Peripheral Interface)** is a master-slave communication bus. As long as there is only one master and the chip selects are properly configured, collisions will not occur.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 14, 2025, 7:01pm UTC](https://forum.arduino.cc/t/w5500-and-uwb-not-working-together/1301577/16 "2025-03-14T19:01:58Z")

</div>

Closed on March 14, 2025, 7:01pm UTC

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