Raspberry PI http://www.informatik.htw-dresden.de/~beck/raspberrypi/raspberrypi.html 1
Steckbrief (Reichelt) Broadcom BCM2835 700 MHz ARM1176JZFS-Prozessor mit FPU und Videocore IV, Dual Core, 128 KB L2-Cache, 250 MHz GPU bietet Open GL ES 2.0, OpenVG mit Hardwarebeschleunigung und 1080p30 H.264 High-Profile- Decoding GPU ermöglicht 1 GPixel/s, 1,5 GTexel/s oder 24 GFLOPs mit Texturfilterung und DMA-Infrastruktur 512 MB RAM Startet von SD-Karte, die eine Version des Linux Betriebssystems ausführt (nicht im Lieferumfang enthalten) 10/100 BaseT-Ethernet-Buchse HDMI-Videobuchse 2 x USB 2.0 über internem Hub RCA Composite Video-Buchse SD-Karten-Steckplatz Stromversorgung über microusb-buchse 3,5 mm Buchse für Audioausgang Stiftleiste für GPIO und serielle Busse Stiftleistenabmessung für JTAG-Steckverbinder Steckverbinder für Raspberry Pi HD Videokamera 5 Status LEDs (Power, SD-Card Zugriff, LAN 10/100 MBit, LAN Full-Duplex, LAN Link / Zugriff) Stromverbrauch: max. 3,5W (700mA) Größe (LxBxH): 85,6 x 53,98 x 17 mm 2
Einsatzmöglichkeit Linuxrechner mit/ohne Gui Multimediacenter Einfaches NAS Steuer-/Überwachungsrechner Kamera/Webcam Embedded System für... http://www.pcwelt.de/ratgeber/die_besten_verwendungsmoeglichkeiten_fuer_raspberry_pi-mini-pc-7663628.html 3
Das System Verschiedene vorkonfigurierte Linuxsysteme Verschiedemne Systeme: http://www.raspberrypi.org/downloads/ Eigene Erfahrungen mit Raspbian Einrichtung der SD-Card (mind. 4GB, class 4) Viele Tutorial zum Einrichten http://raspberrypiguide.de/ http://xmodulo.com/2013/11/write-raspberry-pi-image-sdcard.html Bei erstem Start Einstellungen vornehmen Rootpartition vergrößern ssh -Server erlauben Weitere Einstellungen ggf. später mit sudo raspi-config (http://www.welzels.de/blog/2012/12/raspberry-pi-die-installation/ ) Unterschiede bei /dev/sdb bzw. /dev/sdb1 Weitere Pakete mit apt-cache search...finden und apt-get install 4
Raspi im Netz Via 10/100 BaseT-Ethernet-Buchse Konfiguration via /etc/network/interfaces Feste IP Dynamische IP eth0, Feste IP auto lo iface lo inet loopback auto eth0 Eth0, dhcp iface eth0 inet static address 192.168.178.90 netmask 255.255.255.0 gateway 192.168.178.1 network 192.168.178.0 broadcast 192.168.178.255 auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp 5
Raspi + WLAN Via wlan USB-Stick (Raspberry Pi WLAN-Stick EDIMAX EW-7811Un) Conrad: 993655 62, 7,99 Konfiguration via /etc/network/interfaces /etc/wpa_supplicant/wpa_supplicant.conf auto lo iface lo inet loopback iface eth0 inet dhcp allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp 6
ctrl_interface=dir=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="eduroam" scan_ssid=1 proto=wpa key_mgmt=wpa-eap pairwise=ccmp auth_alg=open eap=ttls identity="beck@htw-dresden.de" anonymous_identity="anonymous@htw-dresden.de" password="sagichnicht" phase2="auth=pap" priority=144 id_str="eduroam" } network={ ssid="meinnetzwerkzuhause" psk="sagicherstrechtnicht" proto=rsn key_mgmt=wpa-psk pairwise=tkip auth_alg=open } 7
IP per mail senden Paket heirloom-mailx installieren /etc/mail.rc oder.mailrc im homedir set smtp=webmail.informatik.htw-dresden.de:25 set smtp-auth-user=beck set smtp-auth-password=meinpasswort set smtp-auth=login set from=beck@htw-dresden.de sendip : #!/bin/bash /sbin/ifconfig > /tmp/ifconfig if /bin/fgrep 141.56. /tmp/ifconfig >/dev/null then echo htw MAILRC="/etc/mailhtw.rc" export MAILRC else echo home MAILRC="/etc/mailhome.rc" export MAILRC fi echo. >> /tmp/ifconfig mailx -s ipraspbeckhtw $1 < /tmp/ifconfig chmod 666 /tmp/ifconfig sleep 1 rm /tmp/ifconfig 8
daemons zum Überwachen,... int main() { setuid(1000); //FILE* f; int fdout; char* p; /* Our process ID and Session ID */ pid_t pid, sid; int i=0; /* Fork off the parent process */ pid = fork(); if (pid < 0) { exit(exit_failure); } /* If we got a good PID, then we can exit the parent process. */ if (pid > 0) { exit(exit_success); } /* Change the file mode mask */ umask(0); /* Open any logs here */ openlog("d1_daemon", 0, 0); /* Create a new SID for the child process */ sid = setsid(); if (sid < 0) { /* Log the failure */ exit(exit_failure); } /* Change the current working directory */ if ((chdir("/")) < 0) { /* Log the failure */ exit(exit_failure); } /* Close out the standard file descriptors */ close(stdin_fileno); close(stdout_fileno); close(stderr_fileno); 9
deamons überwachen cronvoltage: ps ax > /mnt/ramdisk/psvoltage if /bin/fgrep voltage /mnt/ramdisk/psvoltage >/dev/null then exit else /srv/voltage /usr/local/bin/sendmsg beck@htw-dresden.de messagefromoben '/srv/voltage restarted' fi crontab: # m h dom mon dow command 00 12 * * * /usr/local/bin/send 11011 1 1 00 17 * * * /usr/local/bin/send 11011 1 0 03 12 * * * /usr/local/bin/send 11011 3 1 03 17 * * * /usr/local/bin/send 11011 3 0 45 12 * * * /usr/local/bin/set22on 01 18 * * * /usr/local/bin/set22off 30 * * * * /usr/local/bin/cronvoltage Schalten von Pollin Funksteckdosen http://fschreiner.de/?p=379 Akkuladegerät von 12:45-18:01 einschalten Via GPIO, ULN2304, Koppelrelais 10
/usr/local/bin/cronvoltage Liest minütlich die aktuelle Spannung ADC: MCP3424 auf AddOn ADC Pi V2.2 http://www.abelectronics.co.uk/products/3/raspberry-pi/17/adc-pi-v2---raspberry-pi-analogue-to-digitalconverter Programmiert mit eigener i²c-lib http://www.informatik.htw-dresden.de/~beck/raspberrypi/raspmcp3422.html #ifndef _H_I2CLIB_ #define _H_I2CLIB_ #include <inttypes.h> uint8_t* i2c_read(int dev, uint8_t pbuf[], int len); int i2c_write(int dev, char* val,int len); int i2c_write_byte(int dev, int val); #endif 11
WiringPI http://wiringpi.com https://projects.drogon.net/raspberry-pi/ Bibliothek für Raspberry Pi Bietet einen hervorragenden Einstieg Bedient: GPIO I²C SPI PWM Spezielle Addons 12
Schalten mit dem Raspberry PI 3,3V GPIO Pins Relais mit Treibertransistor oder Darlingtonarray, Powermosfet, Triac... Addons (Porterweiterung) für I²C und SPI Pollin Funksteckdosen (http://fschreiner.de/?p=379) Kommandozeile In /etc/rc.local echo 22 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio22/direction chmod 666 /sys/class/gpio/gpio22/value In In der Console, script,. echo 1 > /sys/class/gpio/gpio22/value echo 0 > /sys/class/gpio/gpio22/value 13
Verwendung der Kamera raspi-config : enable camera raspistill für Bilder raspivid für Videos 14
Hints Für i2c / SPI vi /etc/modprobe.d/raspi-blacklist.conf Ramdisk einrichten: sudo mount -t tmpfs -o size=20% none /mnt/ramdisk NFS-Server apt-get install nfs-common /etc/exports : / *(rw,sync,no_subtree_check) sudo mount -t nfs RaspObenA:/ /mnt oder sshfs 141.56.64.173:/ /mnt 15