Cannot power up Arduino Uno + Ethernet Shield with other than computer USB

I have successfully wrote a sketch for Ethernet Shield and Arduino. If I plug it into computer's USB, it works.

But if I plug into any other power source, like USB power adapter from iPhone or laboratory power source to power socket -- it doesn't work.

LEDs are doing various strange bursts, very different than if powered from computer.

What can be the reason?

I have updated sketch so that it doesn't refer serial:

    #include <SPI.h>
    #include <Ethernet.h>
    
    // Enter a MAC address and IP address for your controller below.
    // The IP address will be dependent on your local network:
    // B6-62-C5-CC-48-81
    byte mac[] = {
      0xB6, 0x62, 0xC5, 0xCC, 0x48, 0x81
    };
    IPAddress ip(192, 168, 10, 90);
    
    // Initialize the Ethernet server library
    // with the IP address and port you want to use
    // (port 80 is default for HTTP):
    EthernetServer server(80);
    
    long requestCount = 0;
    long upCounts[] = {0, 0, 0, 0, 0, 0};
    long downCounts[] = {0, 0, 0, 0, 0, 0};
    int currVals[] = {0, 0, 0, 0, 0, 0};
    int prevStats[]= {0, 0, 0, 0, 0, 0};
    int upThreshold = 1024-32;
    int downThreshold = 32;
    
    
    
    void setup() {
      // Open serial communications and wait for port to open:
    //  Serial.begin(9600);
    //  while (!Serial) {
    //    ; // wait for serial port to connect. Needed for native USB port only
    //  }
    
    
      // start the Ethernet connection and the server:
      Ethernet.begin(mac, ip);
      server.begin();
    //  Serial.print("server is at ");
    //  Serial.println(Ethernet.localIP());
    }
    
    
    void loop() {
    
      for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
        int sensorReading = analogRead(analogChannel);
        currVals[analogChannel] = sensorReading;
    
        if( prevStats[analogChannel] == 0 ) {
          if( currVals[analogChannel] >= upThreshold ) {
            prevStats[analogChannel] = 1;
            if( requestCount>0 ) {
              upCounts[analogChannel] ++;
            }
          }
        }
        else {
          if( currVals[analogChannel] < downThreshold ) {
            prevStats[analogChannel] = 0;
            if( requestCount>0 ) {
              downCounts[analogChannel] ++;
            }
          }
        }
      }
    
      
      // listen for incoming clients
      EthernetClient client = server.available();
      if (client) {
        //Serial.println("new client");
        // an http request ends with a blank line
        boolean currentLineIsBlank = true;
        while (client.connected()) {
          if (client.available()) {
            char c = client.read();
            //Serial.write(c);
            // if you've gotten to the end of the line (received a newline
            // character) and the line is blank, the http request has ended,
            // so you can send a reply
            if (c == '\n' && currentLineIsBlank) {
              // send a standard http response header
              client.println("HTTP/1.1 200 OK");
              client.println("Content-Type: text/html");
              client.println("Connection: close");  // the connection will be closed after completion of the response
              client.println("Refresh: 2");  // refresh the page automatically every 2 sec
    
              client.print("X-Inthemoon-Request-Count: ");  
              client.println(requestCount);
              for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
                client.print("X-Inthemoon-Analog-To-Digital: ");  
                client.print("Channel=");
                client.print(analogChannel);
                client.print("; ");
                client.print("Min-Value=0; ");
                client.print("Max-Value=1023; ");
                client.print("Value=");
                client.print(currVals[analogChannel]);
                client.print("; ");
                client.print("Up-Change-Count=");
                client.print(upCounts[analogChannel]);
                client.print("; ");
                client.print("Down-Change-Count=");
                client.print(downCounts[analogChannel]);
                client.println(";");
              }
    
              
              client.println();
              client.println("<!DOCTYPE HTML>");
              client.println("<html>");
              // output the value of each analog input pin
              client.print("Was counting: ");
              if( requestCount>0 ) {
                client.print("YES (request count is ");
                client.print(requestCount);
                client.print(")");
              }
              else {
                client.print("NO");
              }
              client.println("
");
              for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
                client.print("analog input ");
                client.print(analogChannel);
                client.print(" is ");
                client.print(currVals[analogChannel]);
                client.print(", up changes count is ");
                client.print(upCounts[analogChannel]);
                client.print(", and down changes count is ");
                client.print(downCounts[analogChannel]);
                client.println("
");
              }
              client.println("</html>");
    
              requestCount++;
              break;
            }
            if (c == '\n') {
              // you're starting a new line
              currentLineIsBlank = true;
            } else if (c != '\r') {
              // you've gotten a character on the current line
              currentLineIsBlank = false;
            }
          }
        }
        // give the web browser time to receive the data
        delay(1);
        // close the connection:
        client.stop();
        //Serial.println("client disconnected");
      }
    }

The situation is the same:

It is plugged into Samsung tablet USB power of 2A, so insufficient current is unprobable reason.


I also tried to remove inclusion of SPI.h


If I connect another Arduino board (but of the same vendor, it is from AliExpress), the behavior is the same.


I have compiled blink example and it works in any combination. If I connect Ethernet shield, then it blinks with both LEDs on Arduino board and on Ethernet shield.


I bought different Ethernet Board and it doesn't work too.

Please help. Have anybody ever powering Arduino + Ethernet not from USB?

Improper grounding I suspect.

ieee488:
Improper grounding I suspect.

How to make it proper? How it appears proper with computer USB?