MKR1010 Static IP with WiFiNINA keeps DHCP

Greetings everyone. I can't seem to figure out how to get the MKR1010 configured with a static IP. We operate on a Class B (/16). I've tried creating a regular Class C /24 network as well. I've tried just supplying the "ip" variable and ignoring subnet, dns and gateway but the board defaults to DHCP every time. I've also tried moving the config function to after begin() and it does the same result. Am I missing something?

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

IPAddress ip(192, 168, 3, 3);
IPAddress subnet(255, 255, 0, 0);
IPAddress dns(8, 8, 8, 8);
IPAddress gateway(192, 168, 2, 1);

char ssid[] = SECRET_SSID;
char pass[] = SECRET_PASS;

int status = WL_IDLE_STATUS; 

void setup() {

  while ( status != WL_CONNECTED) {
    WiFi.config(ip, dns, gateway, subnet);
    status = WiFi.begin(ssid, pass);
    delay(10000);
  }
}

void loop() {

}

what is that mix of addresses? use same network for ip and gateway 192.168.2 or 192.168.3. right subnet mask for 192.168 local IP addresses is 255.255.255.0. what is that 8.8.8.8 address for DNS?

It's a /16 network. They can see each other. 192.168.. can see anything on 255.255.0.0

That's not the issue. I've tried making it all /24. It won't take a static IP address. The issue is simply whatever I specify as IP, DNS, Gateway, Subnet is ignored by DHCP function within WiFiNINA. I can't trigger DHCP to stop via config() ... either before or after the begin() call.

try WiFi.disconnect() before config(). for esp8266 it helps

Same result. It pulls DHCP. This is interesting. "WiFi.localIP()" believes it is 192.168.3.90 however it's still requesting DHCP from the router and pulling a completely different IP. I've tried in this configuration with config() stated after begin() as well. Same result. I don't think config() is disabling or passing its values to begin().

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

IPAddress ip(192, 168, 3, 90);

char ssid[] = SECRET_SSID;
char pass[] = SECRET_PASS;

int status = WL_IDLE_STATUS;

void setup() {

  Serial.begin(9600);

  while (status != WL_CONNECTED) {
    //WiFi.disconnect();
    WiFi.config(ip);
    status = WiFi.begin(ssid, pass);
    delay(5000);
  }
  Serial.println(WiFi.localIP());
}

void loop() {
  delay(5000);
  Serial.println(WiFi.localIP());
}

Does anyone have a sample of a static IP on the MKR1010 that's working?

Hi @drakerex,

Could you please open an issue on Github to track this? Issues · arduino-libraries/WiFiNINA · GitHub

With the current firmware setup, WiFi.begin(...); will always request DHCP, but you can set a static IP afterwards:

void setup() {
  //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);
  }

  String fv = WiFi.firmwareVersion();
  if (fv != "1.0.0") {
    Serial.println("Please upgrade the firmware");
  }

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

    WiFi.config(IPAddress(10, 0, 1, 8)); <- static IP


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

  // ....
}

The firmware running on the NINA needs to be correct to disable DHCP when WiFi.config(...); is called before config.

When you say current firmware (I'm assuming you mean for WiFiNINA 1.0.0), it doesn't work. Placing wifi.cofnig() after the begin() statement. I see WiFiNINA 1.1.0 is out, but I don't understand how to install it. I have the latest IDE/build and have run the firmware upgrade sketch.

Never the less, I will open it up on github.

My work around is to use the reservation feature of our router to tag the MAC with the specific IP address and options we want to assign.

NOTE: If you test this... and your means is to Serial.println(ip..) you will get what the MKR1010 thinks is the proper IP. However, check your router, and you'll notice you'll pull a DHCP address.

#include <SPI.h>
#include <WiFiNINA.h>
//#include "arduino_secrets.h"

char ssid[] = "neighborshouse";
char pass[] = "password";

int status = WL_IDLE_STATUS;

void setup() {
  //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);
  }

  String fv = WiFi.firmwareVersion();
  if (fv != "1.0.0") {
    Serial.println("Please upgrade the firmware");
  }

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

    WiFi.config(IPAddress(192, 168, 3, 91)); //<- static IP


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

  // ....
}

void loop(){};

So the firmware version is independent of the library version. We are still working on a tool to update the firmware on the u-blox NINA module.

NOTE: If you test this... and your means is to Serial.println(ip..) you will get what the MKR1010 thinks is the proper IP. However, check your router, and you'll notice you'll pull a DHCP address.

Yes understood, it requests a lease in WiFi.begin(...). I understand it's not the desired behaviour you need.