User Tools

Site Tools


pi

Pi Info:

Set editor to vi: update-alternatives –config editor

Get current temperature:

#!/bin/bash
wget "http://www.srh.noaa.gov/getrwr.php?node=ewx&sid=tx" -O current_conditions.txt
clear
echo "Current Temperature:"
grep "^SAN ANTONIO" current_conditions.txt | awk '{print $4}'

Get Temperature Forecast:

wget "http://forecast.weather.gov/MapClick.php?CityName=San+Antonio&state=TX&site=EWX&textField1=29.4577&textField2=-98.5054&e=1" -O forecast.txt
egrep "Low:|High:" forecast.txt | awk '{print $3}'

Pandora command line client:

http://6xq.net/projects/pianobar/

Sound output was not fun, but this helped:

http://www.include.gr/debian/mpg321/

# modprobe snd_pcm_oss
# modprobe snd_mixer_oss

Stop sound pops:

Next edit /etc/pulse/system.pa and comment out this line:

load-module module-suspend-on-idle

Enable Watchdog:

You can use the BCM2708's hardware watchdog.

To use it begin by loading the module:

sudo modprobe bcm2708_wdog
Then edit the /etc/modules file:

sudo nano /etc/modules
and add the following line:

bcm2708_wdog
Next you will need to setup the watchdog daemon.

Install and confiigure it to start on bootup:

sudo apt-get install watchdog chkconfig
chkconfig watchdog on
sudo /etc/init.d/watchdog start
Next configure watchdog:

sudo nano /etc/watchdog.conf
# Uncomment the line watchdog-device = /dev/watchdog
The watchdog daemon will send /dev/watchdog a heartbeat every 10 seconds. If /dev/watchdog does not receive this signal it will restart your Raspberry Pi.

Force WiFi reconnect if lost:

Add this to root cron:

*/5 * * * * /usr/local/bin/WiFi_Check

Bash script from Kevin Reed https://github.com/dweeber/WiFi_Check

#!/bin/bash
##################################################################
# A Project of TNET Services, Inc
#
# Title:     WiFi_Check
# Author:    Kevin Reed (Dweeber)
#            dweeber.dweebs@gmail.com
# Project:   Raspberry Pi Stuff
#
# Copyright: Copyright (c) 2012 Kevin Reed <kreed@tnet.com>
#            https://github.com/dweeber/WiFi_Check
#
# Purpose:
#
# Script checks to see if WiFi has a network IP and if not
# restart WiFi
#
# Uses a lock file which prevents the script from running more
# than one at a time.  If lockfile is old, it removes it
#
# Instructions:
#
# o Install where you want to run it from like /usr/local/bin
# o chmod 0755 /usr/local/bin/WiFi_Check
# o Add to crontab
#
# Run Every 5 mins - Seems like ever min is over kill unless
# this is a very common problem.  If once a min change */5 to *
# once every 2 mins */5 to */2 ... 
#
# */5 * * * * /usr/local/bin/WiFi_Check 
#
##################################################################
# Settings
# Where and what you want to call the Lockfile
lockfile='/var/run/WiFi_Check.pid'
# Which Interface do you want to check/fix
wlan='wlan0'
##################################################################
echo
echo "Starting WiFi check for $wlan"
date
echo 

# Check to see if there is a lock file
if [ -e $lockfile ]; then
    # A lockfile exists... Lets check to see if it is still valid
    pid=`cat $lockfile`
    if kill -0 &>1 > /dev/null $pid; then
        # Still Valid... lets let it be...
        #echo "Process still running, Lockfile valid"
        exit 1
    else
        # Old Lockfile, Remove it
        #echo "Old lockfile, Removing Lockfile"
        rm $lockfile
    fi
fi
# If we get here, set a lock file using our current PID#
#echo "Setting Lockfile"
echo $$ > $lockfile

# We can perform check
echo "Performing Network check for $wlan"
if ifconfig $wlan | grep -q "inet addr:" ; then
    echo "Network is Okay"
else
    echo "Network connection down! Attempting reconnection."
    ifdown $wlan
    sleep 5
    ifup --force $wlan
    ifconfig $wlan | grep "inet addr"
fi

echo 
echo "Current Setting:"
ifconfig $wlan | grep "inet addr:"
echo
 
# Check is complete, Remove Lock file and exit
#echo "process is complete, removing lockfile"
rm $lockfile
exit 0

##################################################################
# End of Script
##################################################################
pi.txt · Last modified: 2015/03/22 10:05 by vinny