{"id":2378,"date":"2012-12-19T20:48:54","date_gmt":"2012-12-19T19:48:54","guid":{"rendered":"http:\/\/svay.com\/blog\/?p=2378"},"modified":"2013-10-21T22:15:31","modified_gmt":"2013-10-21T20:15:31","slug":"setting-up-a-wifi-connection-on-the-raspberrypi","status":"publish","type":"post","link":"https:\/\/svay.com\/blog\/setting-up-a-wifi-connection-on-the-raspberrypi\/","title":{"rendered":"Setting up a WiFi connection on the RaspberryPi"},"content":{"rendered":"<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2386\" alt=\"raspberrypi-wifi\" src=\"http:\/\/svay.com\/blog\/wp-content\/uploads\/2012\/12\/raspberrypi-wifi.jpg\" width=\"580\" height=\"340\" srcset=\"https:\/\/svay.com\/blog\/wp-content\/uploads\/2012\/12\/raspberrypi-wifi.jpg 580w, https:\/\/svay.com\/blog\/wp-content\/uploads\/2012\/12\/raspberrypi-wifi-300x175.jpg 300w\" sizes=\"(max-width: 580px) 100vw, 580px\" \/><\/p>\n<p>I&#8217;ve recently tried to setup a WiFi connection with the RaspberryPi and encountered some issues: the connection didn&#8217;t start automatically and it wasn&#8217;t stable. I&#8217;m using an Edimax EW-7811Un USB dongle, which is supposed to be supported out of the box with Raspian Wheezy (2012-12-16).<\/p>\n<p>After researching the issue, I finally have a configuration that works reliably. Here are the steps I&#8217;ve followed.<\/p>\n<p><!--more--><\/p>\n<h2>Setting up the configuration<\/h2>\n<p>Edit the\u00a0\/etc\/network\/interfaces file to look like this:<\/p>\n<pre>auto lo\r\n\r\niface lo inet loopback\r\niface eth0 inet dhcp\r\n\r\n#auto wlan0\r\nallow-hotplug wlan0\r\niface wlan0 inet manual\r\nwpa-roam \/etc\/wpa_supplicant\/wpa_supplicant.conf\r\niface default inet dhcp<\/pre>\n<p>Then add your WiFi parameters to \/etc\/wpa_supplicant\/wpa_supplicant.conf.<br \/>\nHere are my parameters to connect to my freebox (French ISP router).<\/p>\n<pre>network={\r\n        ssid=\"YOURSSID\"\r\n        scan_ssid=1\r\n        key_mgmt=WPA-PSK\r\n        proto=WPA\r\n        psk=\"YOURPASSWORD\"\r\n}<\/pre>\n<p>At this point, the you should be able to start the connection with this command:<\/p>\n<pre>sudo ifup wlan0<\/pre>\n<p>In some cases, you might need to do <code>sudo ifup wlan0<\/code> first.<\/p>\n<h2>Connect automatically when booting<\/h2>\n<p>To make the connection work when the RaspberryPi boots, I have added a few lines to\u00a0\/etc\/rc.local (<a href=\"http:\/\/stinebaugh.info\/auto-start-your-wifi-on-raspberry-pi\/\">source<\/a>) :<\/p>\n<pre>echo \"Starting WiFi...\"\r\nwpa_supplicant -B -i wlan0 -c \/etc\/wpa_supplicant.conf\r\nsleep .5s\r\ndhclient wlan0\r\necho \"WiFi should be started\"\r\n\r\nexit 0<\/pre>\n<h2>Keep the connection alive<\/h2>\n<p>To make sure that the connection stays up, I&#8217;ve done two things.<\/p>\n<p>First, disable the power management of the WiFi dongle. Create a new\u00a0\/etc\/modprobe.d\/8192cu.conf file with this content (<a href=\"http:\/\/forum.doozan.com\/read.php?6,8618\">source<\/a>):<\/p>\n<pre>options 8192cu rtw_power_mgnt=0 rtw_enusbss=0<\/pre>\n<p>Then, make the RaspberryPi ping the router every minute. Open your crontab:<\/p>\n<pre>$ crontab -e<\/pre>\n<p>and add this line at the end :<\/p>\n<pre>*\/1 * * * * ping -c 1 192.168.0.254<\/pre>\n<p>Replace the IP address by the actual IP address of your router.<\/p>\n<p>It took me some time to get it right, but now the Pi connection seems to work fine.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve recently tried to setup a WiFi connection with the RaspberryPi and encountered some issues: the connection didn&#8217;t start automatically and it wasn&#8217;t stable. I&#8217;m using an Edimax EW-7811Un USB dongle, which is supposed to be supported out of the box with Raspian Wheezy (2012-12-16). After researching the issue, I finally have a configuration that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[26],"tags":[],"_links":{"self":[{"href":"https:\/\/svay.com\/blog\/wp-json\/wp\/v2\/posts\/2378"}],"collection":[{"href":"https:\/\/svay.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/svay.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/svay.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/svay.com\/blog\/wp-json\/wp\/v2\/comments?post=2378"}],"version-history":[{"count":11,"href":"https:\/\/svay.com\/blog\/wp-json\/wp\/v2\/posts\/2378\/revisions"}],"predecessor-version":[{"id":2496,"href":"https:\/\/svay.com\/blog\/wp-json\/wp\/v2\/posts\/2378\/revisions\/2496"}],"wp:attachment":[{"href":"https:\/\/svay.com\/blog\/wp-json\/wp\/v2\/media?parent=2378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/svay.com\/blog\/wp-json\/wp\/v2\/categories?post=2378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/svay.com\/blog\/wp-json\/wp\/v2\/tags?post=2378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}