MKR1010 wont connect to wifi when independently powered

I was able to upload sketches to connect my MKR wifi1010 to internet when connected to my computer but when I independently powered my device, it was no longer connected. I noted the IP address when it was connected and then pinged it when disconnected from computer and all packages were lost. What am I missing?

I will take a SWAG: It sounds like an RF problem, no ground plain for the antenna. Add a piece of wire (maybe 2'-3') to the ground connections and see if that solves it.

Curious - why would it need an antenna when the device is made for wifi?

The antenna is that square squiggly line on the end of the board. It generates a RF (Radio Frequency) signal that it transmits on and receives with. It needs a ground reference, holding it in you hand may solve the problem. This reference is at the RF frequency, it does not have to be DC or a wire. Try this link for a getter explanation: Antenna RF Ground: Theory & Practice » Electronics Notes I have seen this before and sometimes it even works then it does not.

do you have while (!Serial); in setup()?

I used the tutorial code. I know some of it wont work while connected independently, but Im not sure how to write the code I need. Here is what I have:

#include <WiFiNINA.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 status = WL_IDLE_STATUS;     // the Wifi radio's status

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial);

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to network: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }

  // you're connected now, so print out the data:
  Serial.println("You're connected to the network");
  
  Serial.println("----------------------------------------");
  printData();
  Serial.println("----------------------------------------");
}

void loop() {
  // check the network connection once every 10 seconds:
 delay(10000);
 printData();
 Serial.println("----------------------------------------");
}

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

  Serial.println();
  Serial.println("Network Information:");
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

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

  byte encryption = WiFi.encryptionType();
  Serial.print("Encryption Type:");
  Serial.println(encryption, HEX);
  Serial.println();
}

while (!Serial); waits for USB connection

Thank you for that input.

and does it now work?

I will try in the next couple days and let you know.

I tried it and it did not help. I then decided I would try some other project hoping it would help me get a better grasp of things. I tried the https://docs.arduino.cc/cloud/iot-cloud/tutorials/alexa-mkr-rgb-shield project and I got errors because it didnt recognize loungeArea and stated it "was not declared in this scope". I dont know how I would correct that. I entered the code exactly as in the demonstration.

// ArduinoGraphics - Version: Latest 
#include <ArduinoGraphics.h>
#include "Arduino_MKRRGB.h"
#include "thingProperties.h"

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);

  MATRIX.begin();
  
  MATRIX.brightness(10);

  while(!Serial);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}


void loop() {
  ArduinoCloud.update();
  // Your code here
}

void onLoungeAreaChange() {
  uint8_t r, g, b;
  loungeArea.getValue().getRGB(r, g, b);
  if (loungeArea.getSwitch()) {
  Serial.println("R:"+String(r)+" G:"+String(g)+ " B:"+String(b)); //prints the current R, G, B values
  MATRIX.beginDraw(); //starts a new "drawing" on the RGB shield's pixels
  MATRIX.clear(); //clears the RGB shield's pixels
  MATRIX.noStroke();
  MATRIX.fill(r, g, b); //the r, g, b values are fed into the shield's pixels
  MATRIX.rect(0, 0, MATRIX.width(), MATRIX.height()); //creates a rectangle (this covers the entire matrix)
  MATRIX.endDraw(); // ends the draw, and displays the new "drawing"

  }
  else{
  Serial.println("Lamp Off");
  //the following code simply turns everything off
  MATRIX.beginDraw();
  MATRIX.clear();
  MATRIX.noStroke();
  MATRIX.fill(0, 0, 0);
  MATRIX.rect(0, 0, MATRIX.width(), MATRIX.height());
  MATRIX.endDraw();

  }
}

I see you don't know what you are doing.
while (!Serial); will stop the sketch forever if the USB is not connected to a computer. you have to remove the line to run without USB connection.

I understand that about the while serial line. Forgive the lack of code. I am using my phone to reply. After your input, I turned it into a comment which should prevent it from being acted upon. I then decided to try the other code that I posted. I understand a little programming but am so rusty that writing it feels almost foreign. Thanks for your help so far.

With your guidance I got it to work. Thank you very much.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.