Skip to main content

Posts

Showing posts from June, 2014

How To Send Email With Python (smtplib and MIMEText)

It is actually pretty easy to  send emails with python. The smtplib module provides the necessary "tools" to send mail to any Internet machine with an SMTP or ESMTP listener daemon. In this script I am using gmail, but it is not limited to Google as long as your provide the correct smtp server + port. Python 2.7.3  from   email .mime.text  import  MIMEText   import   smtplib       def  sendmail(to,subject,text):        user  = 'name@gmail.com'        pwd  = 'password'       msg = MIMEText(text)       msg['From'] = 'james@gmail.com'       msg['To'] = to       msg['Subject'] = subject        try :           smtpServer =  smtplib .SMTP('smtp.gmail.com', 587)           smtpServer.ehlo()           smtpServer.starttls()           smtpServer.ehlo()           smtpServer.login( user ,  pwd )           smtpServer.sendmail( user , to, msg.as_string())           smtpServer. close ()            print

Automatically Check The Raspberry Pi's Temperature (+Prevent Overheating)

No need to install anything. Just open a terminal and execute the following command to get the temperature of your RasPi. /opt/vc/bin/vcgencmd measure_temp Automate the process The below script will automatically reboot your Raspberry Pi should it reach a specified threshold (maxtemp). First of all make sure you can reboot/shutdown your raspi without linux asking you for a password.  user@user:~$ sudo visudo Add the following to the sudoers file.  user ALL=NOPASSWD: /sbin/shutdown The script Save as temp.sh. Maxtemp specifies the temperature cut-off point, at which the Raspi will reboot.  #!/bin/bash #title :temp.sh #description :Checks Temperature of Raspberry Pi and reboots at maxtemp. #author :Mike M | www.linuxx.eu #notes :Add "user ALL=NOPASSWD: /sbin/shutdown" to sudoers file temp=`/opt/vc/bin/vcgencmd measure_temp | cut -c 6-7` maxtemp=75 if [ $temp -ge $maxtemp ]; then xmessage "Alert! Temp ab

Streaming Video From Your Raspberry Pi Camera Module with VLC

If you want to build a surveillance cam you might want to have a look at motion, but for simple video streaming I 'd go for vlc. Enable Camera Module sudo raspi-config Install VLC Media Player sudo apt-get install vlc Stream (RTSP)  raspivid -o - -t 0 -n -w 800 -h 600 -fps 20 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264 - w: width - h: heigt - fps: frames per second Viewing The RTSP Stream   You need a video player capable of RTSP (e.g. VLC). Open a network stream: rtsp://###.###.###.###:8554/ ###.###.###.### is the IP address of your raspberry pi. Also, do not forget the '/'  at the end, otherwise it won't work. Streaming Over HTTP  raspivid -o - -t 0 -n -w 800 -h 600 -fps 20 | cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8554}' :demux=h264 Camera Module

How to Setup Wi-Fi On Your Raspberry Pi via the Command Line

Configure Your AP Details sudo nano /etc/wpa_supplicant/wpa_supplicant.conf Make sure the file reads like this ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="SSID" proto=RSN key_mgmt=WPA-PSK pairwise=CCMP TKIP group=CCMP TKIP psk="yourkey" } Configuring the interface  sudo nano /etc/network/interfaces Add the following allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp sudo ifconfig wlan0 down sudo ifconfig wlan0 up Reboot. Done. Model B