Automation/RaspberryPi: Difference between revisions

From Medien Wiki
m (Created page with "The Raspberry Pi is an inexpensive Linux Computer which you can for example use to play back videos (up to Fill-HD). This page shows you how to set it up: == Making the Rapberr...")
 
mNo edit summary
Line 8: Line 8:
Connect to the internet (Ethernet + DHCP) and bring the OS up to date:
Connect to the internet (Ethernet + DHCP) and bring the OS up to date:


sudo apt-get update
sudo apt-get update
sudo apt-get upgrade
sudo apt-get upgrade




Test video playback:
Test video playback: [http://www.raspberrypi.org/documentation/usage/video/README.md source]
(source: http://www.raspberrypi.org/documentation/usage/video/README.md )


omxplayer /opt/vc/src/hello_pi/hello_video/test.h264
omxplayer /opt/vc/src/hello_pi/hello_video/test.h264


add option -r to change display frame rate and resolution to the one that the movie file has:
add option -r to change display frame rate and resolution to the one that the movie file has:


omxplayer -r /opt/vc/src/hello_pi/hello_video/test.h264
omxplayer -r /opt/vc/src/hello_pi/hello_video/test.h264


startup_script.sh
startup_script.sh
--- begin ---


clear
clear
echo "Startup script running"
echo "Startup script running"
echo "some useful information here"
echo "some useful information here"
sleep 2
sleep 2
omxplayer -r movie.mp4 --loop
omxplayer -r movie.mp4 --loop
--- end ---
 




Line 36: Line 34:


Step 1: Open a terminal session and edit inittab file.
Step 1: Open a terminal session and edit inittab file.
sudo nano /etc/inittab
sudo nano /etc/inittab
Step 2: Disable the getty program.
Step 2: Disable the getty program.
Navigate to the following line in inittab
Navigate to the following line in inittab
1:2345:respawn:/sbin/getty 115200 tty1
1:2345:respawn:/sbin/getty 115200 tty1
 
And add a # at the beginning of the line to comment it out
And add a # at the beginning of the line to comment it out
#1:2345:respawn:/sbin/getty 115200 tty1
#1:2345:respawn:/sbin/getty 115200 tty1
Step 3: Add login program to inittab.
Step 3: Add login program to inittab.
Add the following line just below the commented line
Add the following line just below the commented line
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
This will run the login program with pi user and without any authentication
This will run the login program with pi user and without any authentication
Step 4: Save and Exit.
Step 4: Save and Exit.


Make it start the script automatically:
Make it start the script automatically:
sudo nano .bashrc
sudo nano .bashrc
and right at the end put:
and right at the end put:
if [ $(tty) == /dev/tty1 ]; then
if [ $(tty) == /dev/tty1 ]; then
   ./startup_script.sh
   ./startup_script.sh
fi
fi




2. Synchronizing multiple RaspberryPis
==Synchronizing multiple RaspberryPis==
-----------------------------------------------------------------


maybe you want to have the different pis different hostnames, so you don't get condused.
maybe you want to have the different pis different hostnames, so you don't get confused
change the hostname with


sudo raspi-config
sudo raspi-config




install pexpect:
install pexpect:


sudo apt-get install python-pexpect
sudo apt-get install python-pexpect




install python bindings for DBUS https://github.com/LEW21/pydbus
install python bindings for DBUS https://github.com/LEW21/pydbus


sudo apt-get install python3-setuptools
sudo apt-get install python3-setuptools
sudo wget https://github.com/LEW21/pydbus/archive/master.zip
sudo wget https://github.com/LEW21/pydbus/archive/master.zip
sudo unzip master.zip
sudo unzip master.zip
rm master.zip
rm master.zip
cd pydbus-master/
cd pydbus-master/
sudo chmod 777 setup.py
sudo chmod 777 setup.py
sudo ./setup.py build
sudo ./setup.py build
sudo ./setup.py install
sudo ./setup.py install




sudo apt-get remove omxplayer
sudo apt-get remove omxplayer
sudo rm -rf /usr/bin/omxplayer /usr/bin/omxplayer.bin /usr/lib/omxplayer
sudo rm -rf /usr/bin/omxplayer /usr/bin/omxplayer.bin /usr/lib/omxplayer
sudo wget -O- http://yokto.net/0/omxplayer/omxplayer-3176db4.tar.bz2 | sudo tar -C / -xjvf -
sudo wget -O- http://yokto.net/0/omxplayer/omxplayer-3176db4.tar.bz2 | sudo tar -C / -xjvf -
sudo ln -sf /lib/arm-linux-gnueabihf/libpcre.so.3 /lib/arm-linux-gnueabihf/libpcre.so.1
sudo ln -sf /lib/arm-linux-gnueabihf/libpcre.so.3 /lib/arm-linux-gnueabihf/libpcre.so.1
sudo wget -O /usr/bin/omxplayer-sync https://github.com/turingmachine/omxplayer-sync/raw/master/omxplayer-sync
sudo wget -O /usr/bin/omxplayer-sync https://github.com/turingmachine/omxplayer-sync/raw/master/omxplayer-sync
sudo chmod 0755 /usr/bin/omxplayer-sync
sudo chmod 0755 /usr/bin/omxplayer-sync
sudo wget https://github.com/turingmachine/omxplayer-sync/raw/master/synctest.mp4
sudo wget https://github.com/turingmachine/omxplayer-sync/raw/master/synctest.mp4




Make a local network, connect them with Ethernet cable (+Hub if more then two) and configure static IPs
Make a local network, connect them with Ethernet cable (+Hub if more then two) and configure static IPs [http://elinux.org/Configuring_a_Static_IP_address_on_your_Raspberry_Pi source]
http://elinux.org/Configuring_a_Static_IP_address_on_your_Raspberry_Pi
sudo nano /etc/network/interfaces
sudo nano /etc/network/interfaces


# start on master
# start on master
omxplayer-sync -muv synctest.mp4
omxplayer-sync -muv synctest.mp4


# start on slave
# start on slave
omxplayer-sync -luv synctest.mp4
omxplayer-sync -luv synctest.mp4


05:01, 7 May 2015 (UTC)05:01, 7 May 2015 (UTC)05:01, 7 May 2015 (UTC)~~notes05:01, 7 May 2015 (UTC)05:01, 7 May 2015 (UTC)05:01, 7 May 2015 (UTC)~~
==Notes==


other ressources:
other ressources:
Use multiple RasberryPis to make a video wall (needs one extra server-Pi, plus one Pi per client) http://www.piwall.co.uk/
Use multiple RasberryPis to make a video wall (needs one extra server-Pi, plus one Pi per client) [http://www.piwall.co.uk Piwall]


make a backup of SDCard:
make a backup of SDCard:
sudo dd if="/dev/mmcblk0" of="Pi.bin"
sudo dd if="/dev/mmcblk0" of="Pi.bin"


put backup on card:
put backup on card:
sudo dd bs=4M if=Pi.bin of=/dev/mmcblk0
sudo dd bs=4M if=Pi.bin of=/dev/mmcblk0


(both these commands take a long time and the terminal seems like frozen, there is no progress feedback)
(both these commands take a long time and the terminal seems like frozen, there is no progress feedback)


reboot:
reboot:
sudo reboot -h
sudo reboot -h


shutdown:
shutdown:
sudo shutdown -h now
sudo shutdown -h now

Revision as of 13:26, 7 May 2015

The Raspberry Pi is an inexpensive Linux Computer which you can for example use to play back videos (up to Fill-HD). This page shows you how to set it up:


Making the RapberryPi run a video at startup

Install The Raspbian image (NOOBS is okay for the beginning, but it wastes a bit space on the SDcard for the recovery image which we don't need. here is how to copy the raspbian on the card: [1]

Connect to the internet (Ethernet + DHCP) and bring the OS up to date:

sudo apt-get update
sudo apt-get upgrade


Test video playback: source

omxplayer /opt/vc/src/hello_pi/hello_video/test.h264

add option -r to change display frame rate and resolution to the one that the movie file has:

omxplayer -r /opt/vc/src/hello_pi/hello_video/test.h264

startup_script.sh

clear
echo "Startup script running"
echo "some useful information here"
sleep 2
omxplayer -r movie.mp4 --loop


Make it log in automatically: http://opentechguides.com/how-to/article/raspberry-pi/5/raspberry-pi-auto-start.html

Step 1: Open a terminal session and edit inittab file.

sudo nano /etc/inittab

Step 2: Disable the getty program. Navigate to the following line in inittab

1:2345:respawn:/sbin/getty 115200 tty1

And add a # at the beginning of the line to comment it out

#1:2345:respawn:/sbin/getty 115200 tty1

Step 3: Add login program to inittab. Add the following line just below the commented line

1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1

This will run the login program with pi user and without any authentication Step 4: Save and Exit.

Make it start the script automatically:

sudo nano .bashrc

and right at the end put:

if [ $(tty) == /dev/tty1 ]; then
  ./startup_script.sh
fi


Synchronizing multiple RaspberryPis

maybe you want to have the different pis different hostnames, so you don't get confused

sudo raspi-config


install pexpect:

sudo apt-get install python-pexpect


install python bindings for DBUS https://github.com/LEW21/pydbus

sudo apt-get install python3-setuptools
sudo wget https://github.com/LEW21/pydbus/archive/master.zip
sudo unzip master.zip
rm master.zip
cd pydbus-master/
sudo chmod 777 setup.py
sudo ./setup.py build
sudo ./setup.py install


sudo apt-get remove omxplayer
sudo rm -rf /usr/bin/omxplayer /usr/bin/omxplayer.bin /usr/lib/omxplayer
sudo wget -O- http://yokto.net/0/omxplayer/omxplayer-3176db4.tar.bz2 | sudo tar -C / -xjvf -
sudo ln -sf /lib/arm-linux-gnueabihf/libpcre.so.3 /lib/arm-linux-gnueabihf/libpcre.so.1
sudo wget -O /usr/bin/omxplayer-sync https://github.com/turingmachine/omxplayer-sync/raw/master/omxplayer-sync
sudo chmod 0755 /usr/bin/omxplayer-sync
sudo wget https://github.com/turingmachine/omxplayer-sync/raw/master/synctest.mp4


Make a local network, connect them with Ethernet cable (+Hub if more then two) and configure static IPs source

sudo nano /etc/network/interfaces
  1. start on master
omxplayer-sync -muv synctest.mp4
  1. start on slave
omxplayer-sync -luv synctest.mp4

Notes

other ressources: Use multiple RasberryPis to make a video wall (needs one extra server-Pi, plus one Pi per client) Piwall

make a backup of SDCard:

sudo dd if="/dev/mmcblk0" of="Pi.bin"

put backup on card:

sudo dd bs=4M if=Pi.bin of=/dev/mmcblk0

(both these commands take a long time and the terminal seems like frozen, there is no progress feedback)

reboot:

sudo reboot -h

shutdown:

sudo shutdown -h now