Esp32 Ethernet ping?

Hello with the help of Deva_Rishi we manage to get the ESP32 working with the Wiznet 5500 module to pull up a webpage. However i got a new problem I'm trying to do pinging a couple of local ip addresses.

This is the sketch we got working.

#include <SPI.h>
#include <Ethernet.h>

#define LED_YELLOW 2
#define VSPI_SCK 18
#define VSPI_MISO 19
#define VSPI_MOSI 23
#define W5500_CS 5 
#define SPI_FRQ 32000000

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);

//SPIClass * vspi = NULL;

void setup() {
  Serial.begin(115200);
  pinMode(LED_YELLOW, OUTPUT);
  digitalWrite(LED_YELLOW, LOW);  // active LOW
  //vspi = new SPIClass(VSPI);

  //vspi->begin(VSPI_SCK, VSPI_MISO, VSPI_MOSI, W5500_CS);
  //vspi->setFrequency(SPI_FRQ);
  SPI.setFrequency(SPI_FRQ);
  
  Serial.println("Starting ethernet");
  Ethernet.init(W5500_CS);  // set the CS pin
  Ethernet.begin(mac,ip);
  delay(1000);
  Serial.println(Ethernet.localIP());
}

void loop() {
}

I'm able to see in serial monitor the ip address.

I have added #include <ESP32Ping.h> to the sketch and

if (digitalRead(BUTTON_PIN) == HIGH) {
     bool success = Ping.ping("8.8.8.8", 3);
 
  if(!success){
    Serial.println("Ping remote failed");
    return;
  }
  Serial.println("Ping remote host succesful.");

To the Setup for the ping. After compiling and uploading I get this from serial monitor.

Starting ethernet
192.168.1.177

assert failed: tcpip_send_msg_wait_sem IDF/components/lwip/lwip/src/api/tcpip.c:455 (Invalid mbox)

Backtrace: 0x400834a9:0x3ffb1ed0 0x400882a5:0x3ffb1ef0 0x4008d545:0x3ffb1f10 0x400df6b2:0x3ffb2040 0x400eb479:0x3ffb2070 0x400eb4d8:0x3ffb2090 0x400df529:0x3ffb20e0 0x400d286f:0x3ffb2100 0x400d2bfd:0x3ffb21f0 0x400d27ee:0x3ffb2220 0x400d2825:0x3ffb2240 0x400d1eab:0x3ffb2270 0x400d4325:0x3ffb2290

ELF file SHA256: 39405d7cb7f80d33

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_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:1
load:0x3fff0030,len:1184
load:0x40078000,len:13260
load:0x40080400,len:3028
entry 0x400805e4

My only guess it keeps rebooting the processor somehow. The code was made for the esp32 on wifi and it does work fine onthat. but not on ethernet. Does anyone know a ping that I can get to work for a esp32 on the wiznet W5500 please?

Joseph

What i'm trying to do is on ethernet be able to ping other ip addresses or domain. And on the wifi part of it. I want to server up a webpage with the status of the pings that is all.

You are aware that the IP address you assigned may not work on your router ? With ethernet shields assigning a static IP (as with WiFi) still requires a matching IP address, that is why i tend to go for the DHCP assignment first, and get an example.

can you show me a link to the library (on github or in reference)

My ip address is 192.168.1.XXX address. that is part of my network.

Ok just checking

I think this library may actually work for you.
Issue with ESP32 specific libs is that they use WiFi not ethernet.

I tried that library.

#include <SPI.h>         
#include <Ethernet.h>
#include <EthernetICMP.h>
#define VSPI_SCK 18
#define VSPI_MISO 19
#define VSPI_MOSI 23
#define W5500_CS 5 
#define SPI_FRQ 32000000

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; // max address for ethernet shield
byte ip[] = {192,168,1,177}; // ip address for ethernet shield
IPAddress pingAddr(1,1,1,1); // ip address to ping

SOCKET pingSocket = 0;

char buffer [256];
EthernetICMPPing ping(pingSocket, (uint16_t)random(0, 255));

void setup() 
{
  // start Ethernet
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
}

void loop()
{
  EthernetICMPEchoReply echoReply = ping(pingAddr, 4);
  if (echoReply.status == SUCCESS)
  {
    sprintf(buffer,
            "Reply[%d] from: %d.%d.%d.%d: bytes=%d time=%ldms TTL=%d",
            echoReply.data.seq,
            echoReply.addr[0],
            echoReply.addr[1],
            echoReply.addr[2],
            echoReply.addr[3],
            REQ_DATASIZE,
            millis() - echoReply.data.time,
            echoReply.ttl);
  }
  else
  {
    sprintf(buffer, "Echo request failed; %d", echoReply.status);
  }
  Serial.println(buffer);
  delay(500);
}




result

Echo request failed; 1
⸮⸮B,⸮e&⸮!⸮

Well it compiles and it runs, i don't ever ping anything so i can't help you much with that.

⸮⸮B,⸮e&⸮!⸮

maybe HEX output would be clearer

Serial.println(buffer, HEX);

C:\Users\josep\AppData\Local\Temp\arduino_modified_sketch_116352\Ping.ino: In function 'void loop()':
Ping:61:29: error: no matching function for call to 'println(char [256], int)'
Serial.println(buffer, HEX);

After I reboot and open serial monitor again this is what comes up. It does compile but that is all.

Echo request failed; 2
Echo request failed; 2
Echo request failed; 2
Echo request failed; 1
Echo request failed; 2

and what are you pinging ? Try your computer

Either 8,8,8,8 or 129,168,1,1. Just different ip addresses.

Yes but you should ping an IP that actually has a device connected, or the result will be false.

I pings google public address 172,217,12,110 and it is pingable. I get the same result.

Well then maybe it's not working, as i said i don't do this ever, so i don't really know how to help your specific issue.

You should go back to the other thread, i know for sure that that example works with the libraries installed and the patch implemented. I know it works cause i use it.

Goung back there and Trying the patch.

Was looking at this yesterday but git kept crashing..
I only see 1 call to Wifi in the lib..

    if (WiFi.hostByName(host, remote_addr))

checking to make sure a valid host or ip is entered..
could try commenting it out and make sure you pass a valid address..

espressif docs on the matter..

Searching around, didn't find a ping lib that doesn't use wifi..
but again git was throwing allot of 500 errors yesterday..

might have to roll your own..

good luck.. ~q