WiFi Rev2 strange connection problem

I'm experiencing a problem where the Uno connects to the WiFi network when running with USB connected, but fails when powered externally.

I'm just starting with Uno WiFi Rev2, but I've done a lot with Uno and Nano

I built a sketch based on the example "WiFi Web Server"

The real sketch is a simple thing to put the RSSI on a web page, but I'm having connection problems.

The sketch below is a stripped-down version that I'm using for troubleshooting.

/*
  WiFi Link Strength

 Monitors link strength, exposing the result via a web server
 
  This example is written for a network using WPA encryption. For
 WEP or WPA, change the WiFi.begin() call accordingly.

 BASED ON
     WiFi Web Server example
     created 13 July 2010
     by dlf (Metodo2 srl)
     modified 31 May 2012
     by Tom Igoe

 */

#include <SPI.h>
#include <WiFiNINA.h>

#include "arduino_secrets.h" 
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;        // your network SSID (name)
char pass[] = SECRET_PASS;        // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;                 // your network key index number (needed only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(80);

void setup() {

  pinMode(LED_BUILTIN,OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true) {
      blink(1, 10000);
    }
  }

  String fv = WiFi.firmwareVersion();
  Serial.print("Firmware version: ");
  Serial.println(fv);
  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
    Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to WiFi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    blink(2, 1);

    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    delay(10000);

    if (status != WL_CONNECTED) {
      WiFi.disconnect();
      WiFi.end();
    }
  }

  digitalWrite(LED_BUILTIN, HIGH);

  // you're connected now, so print out the status:
  printWifiStatus();
}

void
blink(int blinks, int repeats)
{
    while (repeats-- > 0) {
      for (int i = 0; i < blinks; i++) {
        digitalWrite(LED_BUILTIN, HIGH);
        delay(500);
        digitalWrite(LED_BUILTIN, LOW);
        delay(500);
      }
      delay(1000);
    }
}

void loop() {
  
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

The disconnect() and end() calls were added based on a search for solution. It behaves the same with and without them.

When I run this and monitor the console, I get

Firmware version: 1.4.8
Attempting to connect to SSID: postmonster
Attempting to connect to SSID: postmonster
SSID: postmonster
IP Address: 192.168.0.151
signal strength (RSSI):-33 dBm

I have LED blinks to help troubleshoot, since it only fails when I don't have the console.
While the console output above was being generated, I also got a double blink (attempting to connect), then another double after 10 seconds, and finally a steady on LED after another 10 seconds, meaning it's connected. I can also see the device in my wireless router control panel.

So far, this is as expected. But when I disconnect USB and put 9V into the power jack, it never connects.

It boots up, and quickly shows a double blink, meaning trying to connect. But then it does the same every 11-12 seconds. I've tried the reset button, and tried cycling power, no change in behavior.

I'm running 1.8.16 of the IDE, 1.8.3 of AVR boards, and 1.4.8 of firmware.

9V from a solid power supply, or a flimsy smoke detector battery?

Try to power it via a 5V supply connected to the 5V pin.

Good call, Whandall!

I put a 2.1mm plug on a bench power supply to supply power, and it connected fine.
For anyone else with a similar problem, I was seeing 120 mA while it was trying to connect, dropped down to 80-90 mA once connected.

It's an Energizer, but I don't know how old and tired. I would expect a fresh, quality battery to supply 120 mA, but this doesn't.

Thanks for the pointer!!

The PP batteries are not rated for that type of current, just do not use them,
they have a legit place in smoke detectors or other very low current applications.