WiFinina and UNO WiFi Rev 2 compatibility

I'm having trouble getting UNO WiFi Rev2 functions to work as expected. I am wondering if WiFinina is compatible with this board.

The current problem is finding my PC's IP address using hostByName

No matter what server name I supply, the returned IP address is always 198.105.254.17. If I supply an empty string, "" then hostByName gets an err of 0.

#include "secrets.h"
#include <WiFiNINA.h>
char ssid[] = SECRET_SSID;
char pass[] = SECRET_PASS;
int status = WL_IDLE_STATUS;
IPAddress result = {0,0,0,0};
int err;

void setup()
{
  Serial.begin(57600);

  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    status = WiFi.begin(ssid, pass);
    delay(10000);
  }

  Serial.println("Connected to wifi");
  err = WiFi.hostByName("Sprinkler", result);
  if (err == 1) {
    Serial.print("Ip address: ");
    Serial.println(result);
  } else
  {
    Serial.print("Error code: ");
    Serial.println(err);
  }
}

void loop() {}

The current problem is finding my PC's IP address using hostByName

That's probably because your PC doesn't have a DNS name on the network. hostByName() only knows how to resolve DNS names, so if you ask it to resolve "www.google.com" it probably returns the correct IP.

You're probably fooled by the mDNS names (Apple calls that service Bonjour). They are relatively new feature and require much more resources than a simple DNS lookup. Although you'll find libraries for the Arduino world you probably don't want to "waste" resources (RAM and flash) for that limited functionality.

You are correct, the www.google.com does return with the google IP address.
I was confused by the fact that it kept returning a bad IP address (the same one 198.105.254.17) when it didn't find the name it was looking for. That is true regardless of the name used. Only with a blank name "" would it return the correct error code.

I'll see if I can figure our how to add a DNS name to the Sprinkler device which is an Arduino WiFi Rev2. This board seems to have plenty of memory left so that shouldn't be a problem.

Just for clarification:
When I go to the windows network, I do see Sprinkler on the network. What is the difference between what Windows is seeing and the DNS name you explained?

Thank you for your help

When I go to the windows network, I do see Sprinkler on the network. What is the difference between what Windows is seeing and the DNS name you explained?

Read the second paragraph of my answer. mDNS != DNS, despite the similar name they are something completely different, from a technological point of view. The PC OSes did a great job to let them appear to be the same but in the embedded world it's a bit more difficult.

Got it. Thanks