Low signal strength is likely to be the cause of your problems. You should be aiming for a signal strength above 75% and ideally above 90% for reliable, constant operation.
WiFi sits at the bottom of the protocol stack, between the DataLink and Physical layers. Low signal strengths cause radio retransmission, which causes the TCP/IP protocols higher up the stack, to start to fail. The radio signal may improve but their is the protocol stack lacks a mechanism to notify the higher layers when the link is degraded and when it should recover.
When you change the WiFi channel, the entire protocol stack is re-initialised but it takes a relatively long time.
Low signal strength is the radio equivalent of a noisy Ethernet cable. Intermittent connections being in many ways, worse than a connection which is completely broken. If symptoms are apparent, they can include stale ARP caches, DHCP failures, phantom address clashes and degradation of the whole segment.
You can find a python script that monitors the wifi connection, and if broken will (optionally) restart the WLAN: http://myyafa.blogspot.be/2014/07/wifi-monitor-to-troubleshoot-yun.html
You might want to use some snippets from that code.
I have this script always running in the background. Since I added an extra access point in my house, I have no more broken links.
Dawiinci: I agree with you and this situation would be ideal.
I am mainly a network support analyst and I would say, for a fixed installation, signal strength over 75% is essential.
All I need is an automated restart of the wifi if it fails.
Quick and dirty. How about a scheduled restart of the network every minute. Then you don't have to detect if it fails.
crontab -e 1 * * * * /init.d/network reload
Dawiinci: Thanks, I will try the py Script first. How do I install and use this with the yun?
You just download the zip, and unpack it somewhere on the Yun (e.g. /mnt/sda1/arduino) Next configure it like you want, e.g:
LOGFILE="/tmp/wifiMonitor" LOGFILESD="/mnt/sda1/arduino/wifiMonitor_" RESTART_WIFI_WHEN_LOST = True TO_PING = "192.168.1.1" KEEP_ONLY_LAST_BACKUP = True # if false --> will grow forever, could run out of 'disk' space CHECK_WIFI_INTERVAL = 16 # seconds BACKUP_INTERVAL = 3600 # seconds
and start the script by typing wifiMonitor, alternatively you can add the following line to /etc/rc.local to have it started at every boot:
/mnt/sda1/arduino/wifiMonitor.py 1> /tmp/wifi.print 2>&1 &
You can put the scripts anywhere you want.
With sshfs you can mount a Yun folder to your PC, which should make it easy to transfer the files. See http://myyafa.blogspot.de/2013/11/mounting-yun-sd-card-on-my-linux.html, but change the paths to something else than the SD card.
If you don't have an SD card, you dont want to do repeated writes to the flash of your Yun, so make sure that the LOGFILESD is also set to somewhere in /tmp (which is RAM based, but means you will lose the file at reboot).
NewLine: ... I have this script always running in the background. Since I added an extra access point in my house, I have no more broken links.
Understanding Wifi Signal Strength:
Wireless signal strength is traditionally measured in either percentile or dBm (the power ratio in decibels of the measured power referenced to one milliwatt.) The level of 100% is equivalent to the signal level of -35 dBm and higher, e.g. both -25 dBm and -15 dBm will be shown as 100%, because this level of signal is very high. The level of 1% is equivalent to the signal level of -95 dBm. Between -95 dBm and -35 dBm, the percentage scale is linear, i.e. 50% is equivalent to -65 dBm.
Get Wireless signal strength in dBm at Yun:
iwconfig 2>&1 | grep 'Signal level'
Link Quality=70/70 Signal level=-37 dBm
Device A: -35 dBm=100%
Device B:-23 dBm=100%
But Device B have 400% more power than Device A. ( every 6 dBm double power)
If you have a Yun as Device A to compete a group of Device Bs at same channel. Even 100% Link Quality could be failed.
Dawiinci: I constantly have interrupts in the connection to my Yun. It has 30 to 40 % strength signal. ...
Unless you are at basement, desert... which means no one compete with you. The interrupts in the connection is guarantee.
I don't get this, is it a single entry in the file?
I would love to see it as a contribution to https://github.com/arduino/openwrt-packages-yun/
I would be happy to add this. But I have no experience 'creating' an installable package. I see most of them just provide a makefile (which I have experience with). Any pointer to a document or so that could get me started?
Here it is: http://wiki.openwrt.org/doc/devel/packages Since there may be no actual source to download/compile, consider "getting inspired" by the yun-scripts package, which just copies files from "files" folder
Even arduino Wifi shield has the same issue in loose connection and can not recconect.
how can arduino make the same mistake twice.