Рет қаралды 1,172
I have had a number of ENC28J60 and W5100/W5500ethernet modules on my Arduino Nano clones fail over the years. The Nano has a 5V microprocessor, and the ethernet modules are listed as 3.3V IO but are 5V tolerant. I think they are only tolerant for a few years before they die.
With my latest component failure, I wanted to mix it up a bit more. Moving over to a 3.3v microcontroller might help, as the 5v-tolerant components are running at the limit of their tolerance with a Nano. A 3.3V microprocessor might give the components more longevity.
I chose the ESP32 module as it is cheap, plentiful, has many examples and tutorials online, and meets my requirement for a 3.3V microcontroller. I picked a wiz w5500 ethernet module, which I am familiar with from using Nanos. The LAN8720 module seems more commonly supported for the esp32 through the ETH library that comes with the board manager, but it also requires significantly more wires to function. I chose a standard 3.3v version of the BME280 sensor for an environmental sensor, which does temperature, humidity and pressure.
The W5500 requires some modification to work with the ESP32; otherwise, you will get a compile error, specifically: Compilation error: cannot declare variable ‘server’ to be of abstract type EthernetServer. Use your favourite text editor to modify the Ethernet.h file, as shown in the video and change the EthernetServer class from public Server to public Print. You will also need an extra step to set the chip select (CS) pin in your server code.
As a bonus, the W5500’s Serial Peripheral Interface (SPI) requires fewer wires/connections to work than the LAN8720 module. While I review the wiring in the video, here is the TLDR:
W5500 - ESP32
5V - No Connection (NC)
GND - GND PSU (not the ESP32)
RST - NC
INT - NC
GND - NC
3.3V - 3.3V PSU (not the ESP32)
MISO - GPIO 19
MOSI - GPIO 23
SCS - GPIO 5
SCLK - GPIO 19
Why am I using a 3.3V PSU? Well, the ESP32 provides 300ma of current at 3.3V. It will need some of that for itself and some for the BME280. The W5500 needs a minimum of 200ma at 3.3V; I’m assuming there is some sort of spike on start-up or that 200ma is the idle rating, hence why the supplier indicated it was a minimum. Either way, it is safe to assume that it will consume more, which puts the entire setup close to or over the 300ma available from the ESP32, which is why I opted to provide a 3.3v buck converter to supply the W5500 ethernet module.
You can find the code I used in this project here:
pastebin.com/F...
If you find my video useful or entertaining, feel free to buy me a coffee!
www.buymeacoff...