Q:

WiFi disconnects after period of time on Raspberry Pi, doesn't reconnect

I was finally able to get my Raspberry Pi connected to a hidden SSID network (WPA2 Personal) using the below settings (not using wpa_supplicant.conf).
However, after a few hours it disconnects and does not reconnect.

Raspberry Pi B+, running NOOBS. 
USB powered WiFi card (Ralink RT5370    chipset)
Connected to a hidden SSID (I'm not sure the hidden SSID has anything to do with this issue, might be a red herring)

Here is the log:
Feb  6 14:36:01 raspberrypi wpa_supplicant[1641]: wlan0: CTRL-EVENT-DISCONNECTED bssid=90:72:40:1c:ed:c8 reason=4
Feb  6 14:36:01 raspberrypi kernel: [33883.785257] cfg80211: Calling CRDA to update world regulatory domain
Feb  6 14:36:01 raspberrypi ifplugd(wlan0)[1634]: Link beat lost.
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: Executing '/etc/ifplugd/ifplugd.action wlan0 down'.
Feb  6 14:36:11 raspberrypi dhclient: Internet Systems Consortium DHCP Client 4.2.2
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: Internet Systems Consortium DHCP Client 4.2.2
Feb  6 14:36:11 raspberrypi dhclient: Copyright 2004-2011 Internet Systems Consortium.
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: Copyright 2004-2011 Internet Systems Consortium.
Feb  6 14:36:11 raspberrypi dhclient: All rights reserved.
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: All rights reserved.
Feb  6 14:36:11 raspberrypi dhclient: For info, please visit https://www.isc.org/software/dhcp/
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: For info, please visit https://www.isc.org/software/dhcp/
Feb  6 14:36:11 raspberrypi dhclient: 
Feb  6 14:36:11 raspberrypi dhclient: Listening on LPF/wlan0/00:0f:60:01:de:14
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: Listening on LPF/wlan0/00:0f:60:01:de:14
Feb  6 14:36:11 raspberrypi dhclient: Sending on   LPF/wlan0/00:0f:60:01:de:14
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: Sending on   LPF/wlan0/00:0f:60:01:de:14
Feb  6 14:36:11 raspberrypi dhclient: Sending on   Socket/fallback
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: Sending on   Socket/fallback
Feb  6 14:36:11 raspberrypi dhclient: DHCPRELEASE on wlan0 to 192.168.128.254 port 67
Feb  6 14:36:11 raspberrypi ifplugd(wlan0)[1634]: client: DHCPRELEASE on wlan0 to 192.168.128.254 port 67
Feb  6 14:36:12 raspberrypi wpa_supplicant[1641]: wlan0: CTRL-EVENT-TERMINATING - signal 15 received
Feb  6 14:36:12 raspberrypi ifplugd(wlan0)[1634]: Program executed successfully.
Feb  6 14:36:14 raspberrypi ntpd[2157]: Deleting interface #2 wlan0, 192.168.128.122#123, interface stats: received=389, sent=396, dropped=0, active_time=33841 secs
Feb  6 14:36:14 raspberrypi ntpd[2157]: 192.96.207.244 interface 192.168.128.122 -> (none)
Feb  6 14:36:14 raspberrypi ntpd[2157]: 178.18.16.124 interface 192.168.128.122 -> (none)
Feb  6 14:36:14 raspberrypi ntpd[2157]: 204.2.134.164 interface 192.168.128.122 -> (none)
Feb  6 14:36:14 raspberrypi ntpd[2157]: 216.152.240.220 interface 192.168.128.122 -> (none)
Feb  6 14:36:14 raspberrypi ntpd[2157]: peers refreshed

Here is the /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
    wpa-scan-ssid 1
    wpa-ap-scan 1
    wpa-key-mgmt WPA-PSK
    wpa-proto RSN WPA
    wpa-pairwise CCMP TKIP
    wpa-group CCMP TKIP
    wpa-ssid "Na*****"
    wpa-psk *********************************************************

A:

The only way I as able to resolve this issue was to write a shell script that is run every minute by a cron job. It checks if the network is down, if so, reconnects it. It has worked very well for the last week.
#!/bin/bash

MY_PATH="`dirname \"$0\"`"              # relative
LOG_PATH="`( cd \"$MY_PATH\" && cd .. && pwd )`/log/network.log"
now=$(date +"%m-%d %r")

# Which Interface do you want to check
wlan='wlan0'
# Which address do you want to ping to see if you can connect
pingip='google.com'

# Perform the network check and reset if necessary
/bin/ping -c 2 -I $wlan $pingip > /dev/null 2> /dev/null
if [ $? -ge 1 ] ; then
    echo "$now Network is DOWN. Perform a reset" >> $LOG_PATH
    /sbin/ifdown $wlan
    sleep 5
    /sbin/ifup --force $wlan
else
    echo "$now Network is UP. Just exit the program." >> $LOG_PATH
fi

A:

This is expected behaviour; WiFi can not be guaranteed 100% of the time.

This applies to Raspbian Wheezy prior to 2015-05-05 for later (and Jessie) See How do I set up networking/WiFi/Static IP

If you want it to reconnect automatically after loss of connectivity use wpa-roam in conjunction with wpa_supplicant.conf)
PS It is not sensible to publish your SSID and PSK
/etc/network/interfaces
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface home inet dhcp
iface default inet dhcp

/etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    scan_ssid=1
    ssid="xxx"
    psk="yyy"
    id_str="home"
    proto=RSN
    key_mgmt=WPA-PSK
    pairwise=CCMP
    auth_alg=OPEN
    eap=MD5
}

A:

As suggested you can use wpa-roam, though I would recommend to use wicd or network manager. They take care of all the settings, they also deal with multiple networks and are more user friendly.
For instance wicd has a curses gui that you can install with:
sudo apt-get install wicd-curses

And run with:
wicd-curses

