Raspberry Pi change default ssh login message

Changing this message requires editing two different files. The first three sections can be modified by editing the following file:
/etc/motd

To disable the last login message (which I don’t recommend doing), you will need to edit the following file in sudo mode:
/etc/ssh/sshd_config
Find this line in the file and change the yes to no as shown:
PrintLastLog no

Json live temperature update

Get temperature with DS18B20 and save live update with python+php+Json
You can buy DS18B20 from ebay, cost >1$ and you need RaspberryPi.
Full tutorial
temp.py
import os
import glob
import time

os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')

base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0]
device_file = device_folder + '/w1_slave'

def read_temp_raw():
    f = open(device_file, 'r')
    lines = f.readlines()
    f.close()
    return lines

def read_temp():
    lines = read_temp_raw()
    while lines[0].strip()[-3:] != 'YES':
        time.sleep(0.2)
        lines = read_temp_raw()
    equals_pos = lines[1].find('t=')
    if equals_pos != -1:
        temp_string = lines[1][equals_pos+2:]
        temp_c = float(temp_string) / 1000.0
        temp_f = temp_c * 9.0 / 5.0 + 32.0
        return temp_c, temp_f
   
while True:
    print(read_temp())
    deg_c, deg_f = read_temp()
    msg='<?php echo json_encode(array( "author" => "razib","tweet" => "Temparature is: " . '+str(deg_c)+',"date" => date("l jS \of F Y h:i:s A"))); ?>'
    f = open('/var/www/python/feed.php','w')
    f.write(msg)
    f.close()
    time.sleep(1)

 


index.php
<html>
<head><title>Tweets</title>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<style>
#tweets {
    width: 500px;
    font-family: Helvetica, Arial, sans-serif;
}
#tweets li {
    background-color: #E5EECC;
    margin: 2px;
    list-style-type: none;
}
.author {
    font-weight: bold
}
.date {
    font-size: 10px;
}
</style>

<script>
jQuery(document).ready(function() {
    setInterval("showNewTweets()", 1000);
});

function showNewTweets() {
    $.getJSON("feed.php", null, function(data) {
        if (data != null) {
            $("#tweets").prepend($("<li><span class=\"author\">" + data.author + "</span> " +  data.tweet + "<br /><span class=\"date\">" + data.date + "</span></li>").fadeIn("slow"));
        }
    });
}
</script>

</head>
<body>

<ul id="tweets"></ul>

</body>
</html>

feed.php
<?php
echo json_encode(array( "author" => "razib",
                        "tweet" => "The time is: " . time(),
                        "date" => date('l jS \of F Y h:i:s A')));
?>

crontab -e

Just add to your crontab
* * * * * for i in {0..59};

RaspberryPi python+php web switch control or car controll with camera

python code:

#!/usr/bin/python
import MySQLdb
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)

def dbConn():
        db = MySQLdb.connect("localhost",user=" ",passwd=" ",db=" ")
        cur = db.cursor(MySQLdb.cursors.DictCursor)
        cur.execute("SELECT * FROM pinMap")
        return cur
# you must create a Cursor object. It will let
#  you execute all the queries you need

# Use all the SQL you like

# print all the first cell of all the rows

try:
   while True:
        cur=dbConn()
        print "|ID  |GPOI num\t|Status\t|"
        print "+-----------------------+"
        for row in cur.fetchall() :
            print "|",row['id'], "|" ,row["pin"], "\t|" , row['status'], "\t|"
            GPIO.setup(int(row["pin"]), GPIO.OUT)
            GPIO.output(int(row["pin"]),int(row["status"]))
        print "+-----------------------+"
        time.sleep(2)
except KeyboardInterrupt:
                pass
GPIO.cleanup()

PHP code:

<!DOCTYPE html>
<html>
<head>
<title>PiCar</title>

</head>

<body>

<div style="text-align:center">
    <h1>Raspberry Pi GPIO</h1>
<form action="index.php" method="post">
    <input type="image" src="forward.jpg" name="forward"  value="forward">
<br>
    <input type="image" src="left.jpg" name="left"  value="left">
    <input type="image" src="right.jpg" name="right"  value="right">

<br>
        <input type="image" src="backward.jpg" name="backward"  value="backward">
<br>
        <input type="image" src="stop.jpg" name="stop"  value="stop">
    </div>
</form>

</body>
</html>
<?php
function fileRead($num){
    $myFile = "example.txt";
    $fh = fopen($myFile, 'w') or die("can't open file");
    $stringData = "$num\n";
    fwrite($fh, $stringData);
    fclose($fh);
}
function db($pin,$setting){
    include('db.php');
    //$setting = "1";
    //$pin=4;
    mysql_query("UPDATE pinMap SET status='$setting' WHERE pin='$pin';");
    mysql_close();
    header('Location: index.php');
}
function resetPinZero($id,$setting){
    include('db.php');
    //$setting = "1";
    //$pin=4;
    mysql_query("UPDATE pinMap SET status='$setting' WHERE id='$id';");
    mysql_close();
    header('Location: index.php');
}

if (isset($_POST['forward']) && ($_POST['forward'] == 'forward')) {
    echo "forward";
        fileRead("1");
        db("8","0");
        db("7","1");
/*        sleep(1);
        fileRead("0");
        header("Location: fileOne.php");*/
}
else if (isset($_POST['backward']) && ($_POST['backward'] == 'backward')) {
    echo "backward";
        db("7","0");
        db("8","1");
        fileRead("2");
}

else if (isset($_POST['left']) && ($_POST['left'] == 'left')) {
    echo "left";
        db("23","0");
        db("24","1");
        fileRead("2");
}
else if (isset($_POST['right']) && ($_POST['right'] == 'right')) {
    echo "right";
        db("24","0");
        db("23","1");
        fileRead("3");
}
else if (isset($_POST['stop']) && ($_POST['stop'] == 'stop')) {
    echo "stop";
        for($i=0;$i<=17;$i++)
            resetPinZero($i,0);
        fileRead("4");
}
?>
db.php:
<?php
      $conn = mysql_connect('localhost', ' ', ' ');
      $db   = mysql_select_db(' ');
            if($conn)
                echo "success";
            else
                echo "not success!";
?>

MySql:-- phpMyAdmin SQL Dump
-- version 3.4.11.1deb2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 14, 2014 at 04:40 PM
-- Server version: 5.5.37
-- PHP Version: 5.4.4-14+deb7u12

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `gpioPin`
--

-- --------------------------------------------------------

--
-- Table structure for table `pinMap`
--

CREATE TABLE IF NOT EXISTS `pinMap` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `pin` int(10) NOT NULL,
  `status` int(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;

--
-- Dumping data for table `pinMap`
--

INSERT INTO `pinMap` (`id`, `pin`, `status`) VALUES
(0, 7, 0),
(2, 8, 0),
(3, 10, 0),
(4, 11, 0),
(5, 12, 0),
(6, 13, 0),
(7, 15, 0),
(8, 16, 0),
(9, 18, 0),
(10, 19, 0),
(11, 21, 0),
(12, 22, 0),
(13, 23, 0),
(14, 24, 0),
(15, 26, 0),
(16, 3, 0),
(17, 5, 0);

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

Picture:




motorControl.py :
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)

"""back motor"""
GPIO.setup(11, GPIO.OUT)
GPIO.setup(12, GPIO.OUT)
"""front motor"""
GPIO.setup(8, GPIO.OUT)
GPIO.setup(10, GPIO.OUT)
"""
GPIO.output(11,1)
GPIO.output(12,0)
time.sleep(0.5)
GPIO.output(11,0)
GPIO.output(12,1)
time.sleep(0.5)
"""
speed=80
clock=50
p=GPIO.PWM(11,clock)
q=GPIO.PWM(12,clock)

p.start(0)
q.start(0)

try:
    while True:
                    for i in range(speed):
                                p.ChangeDutyCycle(i)
                                time.sleep(0.02)
                    for i in range(speed):
                                p.ChangeDutyCycle(speed-i)

                    p.ChangeDutyCycle(0)

                    for i in range(speed):
                                q.ChangeDutyCycle(i)
                                time.sleep(0.02)
                    for i in range(speed):
                                q.ChangeDutyCycle(speed-i)

                    q.ChangeDutyCycle(0)
except KeyboardInterrupt:
                pass
p.stop()
"""
GPIO.output(8,1)
GPIO.output(10,0)
time.sleep(0.5)
GPIO.output(8,0)
GPIO.output(10,1)
time.sleep(0.5)
"""
GPIO.cleanup()

I am using ebay cheap motor driver and it's cost 1$. You can control 2 dc motor.