how to use arduino yun to scan networks around?

when using arduino uno, there is an official example "ScanNetWorks". Now i have bought an anduino yun. however i find the former example is no longer suitable. If i still use that example, there will be errors like "WiFi shield not present". I'd like to use the arduino yun to scan the wifi around and get the imformation of those wifi. I haven't find an useful example in the bridge library. So I come here for help. Please give me a hand guys.

As you've noticed, the WiFi on the Yun is nothing like a WiFi shield. Any code that is specific to the WiFi shield is not going to work, because the WiFi interface is not directly accessible by the Arduino processor. The WiFi interface is controlled by the Linux side.

Take a look at this post: http://forum.arduino.cc/index.php?topic=274783.msg1935579#msg1935579

The first half of the procedure might be just what you want.

Note that you should SSH into the Yun when trying to do this process. You can run it using the YunSerialTerminal sketch and the USB interface, but doing so doesn't show the screen output for some reason (you just get a blank screen while it's running.)

thank you sir! i am a fresh man in this area. And the code in your question "yun as wifi monitor" seems quite different from the codes in official examples, so it is a little difficult for me to understand. I am now using the software "arduino 1.5.8". i tried to copy the code, but it came to be lots of errors. I wonder whether your code is used in the same compiler. thx again for your kindness.

You can scan networks in the linux side and then pass the data to the Atmega.

To scan the network you can use command line utilities or you can write a python script. Once the linux side is ready the Atmega can run the script or the command through the Bridge library and then get the output.

http://arduino.cc/en/Reference/YunProcessConstructor

grasstree: I am now using the software "arduino 1.5.8". i tried to copy the code, but it came to be lots of errors. I wonder whether your code is used in the same compiler.

Those are commands that are meant to be typed into the Linux command line, not compiled into a sketch. As such, while they will let you see what networks are out there, they are not going to be helpful if you want that functionality embedded in a sketch. Angelo has better ideas.

List nearby of access points and signal strength

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

Angelo9999: You can scan networks in the linux side and then pass the data to the Atmega.

To scan the network you can use command line utilities or you can write a python script. Once the linux side is ready the Atmega can run the script or the command through the Bridge library and then get the output.

http://arduino.cc/en/Reference/YunProcessConstructor

Thank you, sir! Do you mean that I need to change the program in the linux side? I don't know anything about the linux. Or there have been such scripts already in the linux side and i just need to write some command in the Atmega? If so can you tell me where to search such commands. Thanks a lot

In the linux side there is a complete operating system that runs many processes.

You have three ways to control the Linux OS:

  • Sending commands with the Bridge library from the Sketch
  • Using the Terminal with the YunSerialTerminal sketch
  • Using the Terminal through ssh

In your case, you can create a script (bash or python) that scans networks and then copy that script in the linux side.

After the file is inside the Yun you can run it from the sketch with the Bridge library and get its output.

For example if you created a sh script named myscript.sh:

Copy the myscript.sh to the linux side with scp or using a SD card. Then from the sketch you have to write (assuming your file is in /mnt/sd/)

Process myprocess;
myprocess.run("sh /mnt/sd/myscript.sh");

And then read the output with

myprocess.read();

Hello, I am now installed putty in my computer (windows operation system), so I am able to use ssh to install some softwares etc. However, I do not know how to write a python script, I mean how to open the python which is inside the arduino yun?

Thank you very much

Bosssjc: I mean how to open the python which is inside the arduino yun?

Once you are logged into the Yun's SSH command line, simply type [color=blue]python[/color].

You will undoubtably have more questions about Python. The official resource for Python is https://www.python.org