Arduino uno WiFi not work to connect any network by script

Please help me for can not connect to any network by script but used the terminal control is connect.
I buy this board never to work connect any network.

#include <SPI.h>
#include <WiFi.h>

char ssid[] = "ASUS"; // your network SSID (name)
char pass[] = "0894547578"; // your network password

int status = WL_IDLE_STATUS;
char servername[]="google.com"; // remote server we will connect to

WiFiClient client;

void setup() {
Serial.begin(9600);
Serial.println("Attempting to connect to WPA network...");
Serial.print("SSID: ");
Serial.println(ssid);

status = WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
// don't do anything else:
while(true);
}
else {
Serial.println("Connected to wifi");
Serial.println("\nStarting connection...");
// if you get a connection, report back via serial:
if (client.connect(servername, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
}
}
}

void loop() {

}

Arduino Uno WiFi with factory firmware can be used only with "Arduino UNO WiFi Dev Ed Library". you find it in Library Manager. look then at examples.

Thank you Juraj my ready install is not work as same problem.

kanchit:
Thank you Juraj my ready install is not work as same problem.

I do not understand? Is it a google translate? 'ready install', 'not work as same'?

It does appear from your first post the you Arduino WiFi board already has a wlan connection (192.168.1.252).
The web client example you are using, which also attempts to establish a WiFi connection is not appropriate for your special platform.
Also, google.com is a bad example as a target of a web client because it redirects to a https:// address.

The RestClient example doesn't work? What does it print to Serial Monitor?

Thank You Juraj as see is not work.

because arduino.org doesn't exist. change server to www.arduino.cc

Show this one

arduino.cc redirects to https:// and may not be supported by your application:

Try this instead:

	const char* connector = "rest";
	const char* server = "www.switch.ch";
	const char* method = "GET";
	const char* resource = "/index.html";

If it doesn't work, see what happens when you access the page in a web browser.

6v6gt:
Try this instead:

	const char* connector = "rest";
const char* server = "www.switch.ch";
const char* method = "GET";
const char* resource = "/index.html";

it is a rest call. it must be short. 64 bytes max for that library. html will not work.

OK. Maybe this. I can't test it with Uno WiFi though:

	const char* connector = "rest";
	const char* server = "www.swisslake.ch";
	const char* method = "GET";
	const char* resource = "/latest.txt";

kanchit:
Show this one

it works. the replay html is from server.

Show this one not work try to access web browser is show woke.

This new broad Arduino Uno Wifi never use but cannot work any connect to network by script.
I would like some people help me for verification this broad fail or good this would like my make robot for my son is student project.

May be connect by Teamviewer my desktop.

the factory firmware of Uno WiFi and corresponding library are weak.

with Uno WiFi Serial1 library and WiFi Link firmware it is good as an Uno with esp8266 as network adapter can be

Normal we can not access via http://192.168.240.1/arduino/digital/13/1

  • “/arduino/digital/13″ -> digitalRead(13)
  • “/arduino/digital/13/1″ -> digitalWrite(13, HIGH)
  • “/arduino/analog/2/123″ -> analogWrite(2, 123)
  • “/arduino/analog/2″ -> analogRead(2)
  • “/arduino/mode/13/input” -> pinMode(13, INPUT)
  • “/arduino/mode/13/output” -> pinMode(13, OUTPUT)

This case firmware is problem?

kanchit:
Normal we can not access via http://192.168.240.1/arduino/digital/13/1

  • “/arduino/digital/13″ -> digitalRead(13)
  • “/arduino/digital/13/1″ -> digitalWrite(13, HIGH)
  • “/arduino/analog/2/123″ -> analogWrite(2, 123)
  • “/arduino/analog/2″ -> analogRead(2)
  • “/arduino/mode/13/input” -> pinMode(13, INPUT)
  • “/arduino/mode/13/output” -> pinMode(13, OUTPUT)

This case firmware is problem?

this is a functunality of the factory firmware with the preinstalled RestServer.ino example sketch.

I bought an Arduino Uno WiFi Developer Edition and everything seems to be working well -- I'm able to upload and run programs, read sensors that I plug in, etc. However, I'm not able to connect my Arduino to WiFi, or even run the example code provided in the Arduino IDE menu in File > Examples > WiFi Link. Running CheckWiFiLinkFirmwareVersion prints the welcome message "WiFi Link firmware check." but the program stops after that without printing any errors. The Uno WiFi has the ESP8266 chip so the WiFi link library should work, but I have also tried all the other WiFi libraries I could find by typing WiFi into the library manager window in Sketch > Include Library > Manage Libraries.

and did you change the firmware to WiFi Link? there is esp-link from factory