ENC28J60 Gateway - no ping



  • I'm trying to create a simple ethernet gateway with an arduino nano (chinese clone) and a ENC28J60 shield like this.
    I'm not able to get this ethernet shield working: I used the ENC28J60 GW example from MySensors library (changing IP and MAC address), downloading UIPEthernet from here, tried commenting everything except the basic ethernet configuration, but the shield never acquires the IP.

    This is the sketch I'm using (completely unuseful, just for testing the ethernet interface):

    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    //#define MY_DEBUG_VERBOSE_GATEWAY
    
    // Enable and select radio type attached
    //#define MY_RADIO_NRF24
    //#define MY_RF24_PA_LEVEL   RF24_PA_MIN
    //#define MY_RF24_DATARATE   RF24_250KBPS
    //#define MY_RF24_CHANNEL 120
    
    // When ENC28J60 is connected we have to move CE/CSN pins for NRF radio
    //#define MY_RF24_CE_PIN 5
    //#define MY_RF24_CS_PIN 6
    
    // When ENC28J60 is connected, move SCK, MI and MO pins and enable SPI
    //#define MY_SOFTSPI
    //#define MY_SOFT_SPI_SCK_PIN 7
    //#define MY_SOFT_SPI_MISO_PIN 8
    //#define MY_SOFT_SPI_MOSI_PIN 9
    
    // Enable gateway ethernet module type 
    #define MY_GATEWAY_ENC28J60
    
    // Gateway IP address
    #define MY_IP_ADDRESS 192,168,1,22  
    
    // If using static ip you can define Gateway and Subnet address as well
    //#define MY_IP_GATEWAY_ADDRESS 192,168,1,1
    //#define MY_IP_SUBNET_ADDRESS 255,255,255,0
    
    // The port to keep open on node server mode / or port to contact in client mode
    #define MY_PORT 5003
    
    // Controller ip address. Enables client mode (default is "server" mode). 
    // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. 
    //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254   
    
    // The MAC address can be anything you want but should be unique on your network.
    #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEF
    
    
    #include <SPI.h>
    #include <UIPEthernet.h>
    #include <MySensors.h>
    
    
    void setup()
    {
    }
    
    void loop() 
    {
    }
    

    and this is the only output I can get in the serial monitor:

    0 MCO:BGN:INIT GW,CP=R-NGA---,VER=2.3.0
    

    and clearly I cannot ping the address I set up.
    I know that W5100 is much better (I have 2 of them, and they work like a charm), but I need an ethernet gw for testing purpose and right now I have only 2 ENC28J60 in my pocket...

    Do you have any suggestion?
    How can I debug the sketch to understand where it's blocking?



  • @daniele-frigo
    I have just tried your code with the separate module type ENC28J60 and get the following Debug output, and pinging is successful.

    0 MCO:BGN:INIT GW,CP=R-NGA---,VER=2.3.1-alpha
    54 GWT:TIN:IP=192.168.1.22
    1056 MCO:BGN:STP
    1058 MCO:REG:NOT NEEDED
    1060 MCO:BGN:INIT OK,TSP=NA
    

    I only have the following connected
    +5V, GND, SO-12, SCK-13, SI-11, CS-10 (INT-2, RESET-RESET)

    Have you tried unplugging the nano from the ENC28J60 Shield and just using the above jumpers?

    My module also has CLK and WOL that are unconnected, Could it be that your module has these connected somehow?



  • @hard-shovel said in ENC28J60 Gateway - no ping:

    ENC28J60

    I tried conneting +5V, GND, then 10-10, 11-11, 12-12, 13-13, RST-RST, but with the same result.
    The odd thing is that I cannot see any led turning on on the shield (neither using it as a shield, neither with external connections).



  • @daniele-frigo I have just tried my setup again using Mysensor 2.3.0 and I still get the same debug and ping response.

    I also get the same five lines of debug output even if the ENC28J60 is not connected. So i wonder why your output is only one line with the same code above!

    If I power my ENC28J60 with only +5V and GND and no other connections
    I get the Power LED on and then with a network cable connected the Green Link LED solid ON at the network connector and random blinking of the Yellow traffic LED

    So you could have a problem with the Power or Regulator on your board.



  • I really think you're right at this point.
    I don't have another arduino to do a test, I'll try in the next few days.
    Thanks



  • I connected a brand new nano, the ethernet leds are powered when I connect a cable, but the log result is always the same.
    Should I deduct that my shield is defective?



  • @daniele-frigo

    I have tried the stable and development versions of my sensors, the standard UIPEthernet.h and the Mysensors version of UIPEthernet.h, and several versions of Arduino IDE and still cannot replicate your log result of getting only one line of debug data using your program.

    This should generate five lines of debug code regardless if the ENC module is connected.
    With the module connected you should be able to ping the arduino on 192.168.1.22 if your computer is on the same subnet.

    So several questions & things to consider
    1 Are you actually testing using the code you posted above and getting only the one line of debug
    If so, then I think you need to check your software versions,
    1a Are you using Arduino IDE or some other environment like PlatformIO what versions?
    1b Is the correct UIPEthernet.h being used during compiling?
    1c Are there any error messages during compiling, what is the memory usage?
    1d what bootloader are you using? the Old nano Bootloader, New nano type or some other?

    2 Is the network address suitable for your network and you have no other item using that ip address and no arduino device using the same MAC address
    for pinging Is your computer on the same subnet ie 192.168.1.xxx

    3 My ENC modules are power hungry they take about 150mA with only a nano attached. Is you power supply sufficient and smooth?

    4 Are you plugging the board to the nano or using jumpers?
    If using jumpers try and jumper from the Nano pin 10(CS) to pin 8 on the board it is possible the board has the cs connection on pin 8.

    5 You could try loading the UIPEthernet example EchoServer and see if you can then get echo back from your computer if you use telnet on your computer.
    When doing this use a suitable MAC, IP address and port number on the arduino for your computer network.
    This example uses the same connections as the gateway so no wiring changes.
    You should then be able to connect and then get text sent from the computer echoed back from the arduino using telnet.

    6 Failed Parts!
    Original Nano
    If you were powering the original nano from the USB port then i suspect the input diode has partially failed, so will supply very limited power to the board from the USB connector, If you were powering the nano via the RAW pin then the voltage regulator is suspect.

    ENC28J60 Board
    If the Link and Data LEDs are lighting up then the ENC28J60 is working to some extent as these LEDs are controlled by the chip.

    So I suspect the programing and then power / connections.

    Of course even if you get this working this chip is second rate compared to the W5100 or W5500 in both memory consumption and speed.


Log in to reply
 

Suggested Topics

  • 87
  • 5
  • 6
  • 7
  • 7
  • 10

51
Online

11.4k
Users

11.1k
Topics

112.7k
Posts