Importing example in Espressif framework in Arduino framework

Max…

the following example

https://github.com/arduino-libraries/Ethernet/blob/master/examples/WebServer/WebServer.ino

doesn’t work for me

In the example they use this ip address

IPAddress ip(192, 168, 1, 177);

Can I use the same Ip address ?
Do I have to change or set something…
It is still understanding if the cable is connected or not…
What do you think ?

Thanks as always you are my hero

Can you please test the example GitHub - maxgerhardt/pio-esp32-enc28j60: A test using a modified Ethernet library for arbitrary SPI pins. on the board?

1 Like

Well since you’ve modified the libraries/SPI files on the framework, I suggest you save your modified SPI folder to somewhere else and then detelte the framework-arduinoespressif32 folder so that PlatformIO gives you a new clean copy on the next build. Only that way you can test the above sketch properly with a unmodified SPI library.

I did the test… the only change that I made is in the SPI constructor init …
This is the result of your test firmware

lib\EthernetENC\src/Ethernet.h:80:8: note:   candidate expects 1 argument, 5 provided
lib\EthernetENC\src/Ethernet.h:113:15: note: candidate: static void UIPEthernetClass::init(const uint8_t*)
   static void init(const uint8_t* mac);
               ^
lib\EthernetENC\src/Ethernet.h:113:15: note:   candidate expects 1 argument, 5 provided
*** [.pio\build\esp32dev\lib235\ethernet\ethernet_module.cpp.o] Error 1

image

No, don’t have a local copy of the library in lib/, this is not how I uploaded the project GitHub - maxgerhardt/pio-esp32-enc28j60: A test using a modified Ethernet library for arbitrary SPI pins.. Please download this project and test that, not in your own code. It uses lib_deps = https://github.com/maxgerhardt/EthernetENC.git to get the modified version of the library.

Ok…

I have tried …
It is running but not working…
The debug console is showing this

— EOL: CRLF
— filters: default
␌�␂0��1!␑ 9␌��9$!�1Ethernet WebServer Example
␌�B0��1!␑ 9␌��9$!�1Ethernet WebServer Example
��␐ ~L�1�))��N)�~ 19у�Ethernet WebServer Example

Okay, there seems to be a crash, I need to investigate.

I don’t understand why this in your example

#define ETH_SPI_BUS VSPI

We said it is HSPI right?

Oh yeah that’s right, you wanted HSPI. But it doesn’t really matter – both VSPI and HSPI can use arbitrary GPIO pins through the GPIO matrix.

Yes but take in account before I changed the SPI.cpp file with HSPI never worked.
Once I changed it started to work,
The MAC can be different ?
I saw it is different from the one I set.

This completely works for me, first try. I’ve also made some improvements to the library in case it detects that no hardware is connected. Also, HSPI vs VSPI didn’t matter in my case, but I’ve changed it to HSPI anyways.

grafik

--- Miniterm on COM10  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8
Ethernet WebServer Example
Trying to recognize hardware and join via DHCP...
Got out of Ethernet.begin with ret = 1
server is at 192.168.1.167
new client
GET / HTTP/1.1
Host: 192.168.1.167
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: de,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0

client disconnected

Only connections are SPI (MISO, MOSI, SCLK, CS) and power (3.3V and GND), all other control pins (RST, INT, WO) are unused.

I’ve activated the exception decoder and changed the baudrate. Can you remove the project again and download it anew from GitHub - maxgerhardt/pio-esp32-enc28j60: A test using a modified Ethernet library for arbitrary SPI pins. and retry?

Ok I am going to try…
Cn you tell me your setup … ?

The ethernet cable from the board is connected directly to the router?
What about the pc/laptop ?
Can you explain me ?
Thanks a lot

Both PC and the ENC28J60 ethernet module are plugged into the same router via a ethernet cable each. The router is setup for standard DHCP.

There’s really nothing magical about it.

SPI pin mapping is the same as yours and as declared in the example.

Also, my Ethernet module is Mini ENC28J60 Ethernet LAN Netzwerk Modul für Arduino, RJ45 mit SPI K, schematic per https://www.arduino-tech.com/2pcs-enc28j60-ethernet-lan-network-module-schematic-for-arduino/

Max nothing to do…

it is blocked here

Ethernet WebServer Example
Trying to recognize hardware and join via DHCP…
Got out of Ethernet.begin with ret = 0
Ethernet cable got connected, retrying.

And the ethernet cable is connected to a router that has a DHCP server running? Or are you wanting to a use static IPs?

It is connected with the router i guess using dhcp…
Can you modify the code for understanding is SPI communication with the ENC is working?
It is not clear if it is working

If the SPI wasn’t working it would output

        if (Ethernet.hardwareStatus() == EthernetNoHardware)
        {
            Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
            while (true)
            {
                delay(1); // do nothing, no point running without Ethernet hardware
            }
        }

(the function interally calls Enc28J60Network::getrev() to read the EREVID register of the chip, which should non-zero and not 0xFF).

So pretty sure the DHCP process is not working for whatever reason. The ethernet jack should have a green LINK Led and an orange ACTIVITY LED. Is the LINK LED on when the cable is plugged in and the ACTIVITY LED lights up when the microcontroller is reset?

Ethernet WebServer Example
Trying to recognize hardware and join via DHCP…
Got out of Ethernet.begin with ret = 0
Ethernet cable is not connected.
Ethernet cable got connected, retrying.
Ethernet.begin() failed.
server is at 0.0.0.0

when I plug the cable the link led is on … green led is most of the time off…