Can the Yun be programmed to connect automatically to a Wi-fi connection?

Hello there. I created a sketch to scan all availabe networks with the arduino Yun, with names and signal quality. I'd like to make it connect to one of these networks, like the first of the list or something like that. Is that possible? thank you.

No, unless you have every password of each wifi network.

sonnyyu:
No, unless you have every password of each wifi network.

what if i have the passwords/the networks are free?

nano setupwifi.sh
#!/bin/sh
/sbin/uci set  network.lan=interface
/sbin/uci set  network.lan.proto=dhcp
/sbin/uci delete  network.lan.ipaddr
/sbin/uci delete  network.lan.netmask
/sbin/uci set wireless.@wifi-iface[0].mode=sta
/sbin/uci set wireless.@wifi-iface[0].ssid=wifi_ssid
/sbin/uci set wireless.@wifi-iface[0].encryption=psk
/sbin/uci set wireless.@wifi-iface[0].key=wifi_password
/sbin/uci commit wireless; /sbin/wifi
/etc/init.d/network  restart

if you know ssid, encryption type, password.

chmod 755 setupwifi.sh
./setupwifi.sh

@sonnyyu karma++

@ sonnyyu thank you!

theenggprojects: I want to connect to the YUN with my WIFI, I know my pass n ssid. You provided the code in this forum, http://forum.arduino.cc/index.php?PHPSESSID=tcib88l4ks5n9hv2j0mj67sbr1&topic=216850.0 .... I copied it and pasted it like that

File script = FileSystem.open("/tmp/setupwifi.sh", FILE_WRITE);
  // Shell script header
  script.print("#!/bin/sh\n");
  script.print("/sbin/uci set  network.lan=interface\n");
  script.print("/sbin/uci set  network.lan.proto=dhcp\n");
  script.print("/sbin/uci delete  network.lan.ipaddr\n");
  script.print("/sbin/uci delete  network.lan.netmask\n");
  script.print("/sbin/uci set wireless.@wifi-iface[0].mode=sta\n");
  script.print("/sbin/uci set wireless.@wifi-iface[0].ssid=XEO\n"); 
  script.print("/sbin/uci set wireless.@wifi-iface[0].encryption=psk\n");
  script.print("/sbin/uci set wireless.@wifi-iface[0].key=pakistan\n");
  script.print("/sbin/uci commit wireless; /sbin/wifi\n");
  script.print("/etc/init.d/network  restart\n");
  script.close();  // close the file

  // Make the script executable   Process chmod;   chmod.begin("chmod");      // chmod: change mode   chmod.addParameter("+x");  // x stays for executable   chmod.addParameter("/tmp/setupwifi.sh");  // path to the file to make it executable   chmod.run();




After that I run the script and checked the status like this:



Process myscript;   myscript.begin("/tmp/setupwifi.sh");   myscript.run();

  String output = "";

  // read the output of the script   while (myscript.available()) {     output += (char)myscript.read();   }   // remove the blank spaces at the beginning and the ending of the string   output.trim();   Serial.println(output);     Process wifiCheck;  // initialize a new process

  wifiCheck.runShellCommand("/usr/bin/pretty-wifi-info.lua");  // command you want to run

  // while there's any characters coming back from the   // process, print them to the serial monitor:   while (wifiCheck.available() > 0) {     char c = wifiCheck.read();     Serial.print(c);   }

  Serial.println();     Serial.flush();




But its still not working. The response I am getting is something like that:



Current WiFi configuration SSID: XEO Mode: Client Signal: 0% Encryption method: - ```

Am I doing something wrong here. Please let me know.

Step 1. Web portal interface have to work. Step 2. "./setupwifi.sh " have to work, compare "/etc/config/network" and "/etc/config/wireless" with Step 1 setting. Step 3. compare "/tmp/setupwifi.sh" with "./setupwifi.sh "

PaoloNotarsanti: Hello there. I created a sketch to scan all availabe networks with the arduino Yun, with names and signal quality. I'd like to make it connect to one of these networks, like the first of the list or something like that. Is that possible? thank you.

Would you mind sharing your sketch to scan all available networks? It would complete wonderfully this thread with everything I need to connect the Yun to any open network found.

nicolaci: ... Would you mind sharing your sketch to scan all available networks? It would complete wonderfully this thread with everything I need to connect the Yun to any open network found.

http://forum.arduino.cc/index.php?topic=220440.msg1604651#msg1604651