Metainformationen zur Seite
GPIO
Quelle: https://sites.google.com/site/semilleroadt/raspberry-pi-tutorials/gpio
Quelle: http://www.doctormonk.com/2013/02/raspberry-pi-and-breadboard-raspberry.html
Sehr sinnvoll für ein möglichst sicheres basteln ist diese Idee:
Pegelanpassung
Quelle: http://www.rn-wissen.de/index.php/Raspberry_PI:_GPIO
Manche Geräte müssen mit einer 5V-Logik angesteuert werden. Der RaspberryPi nutzt eine 3,3V-Logik. Hierzu lassen sich die Pegel anpassen.
Der nebenstehende Schaltplan zeigt eine Möglichkeit anhand von 2 Transistoren den Ausgang auf 5V anzuheben.
Sichtbar ist auch, dass für einen Eingang nur eine Spannungsteilung notwendig ist.
Ansprechen über die Shell
Um eine LED mithilfe eines Raspberry Pis zum Blinken zu bringen, benötigt man zu allererst WiringPi.
wget http://project-downloads.drogon.net/files/wiringPi.tgz
Das Programm muss nun entpackt, kompiliert und installiert werden:
tar xfz wiringPi.tgz cd wiringPi/wiringPi make make install cd ../gpio make clean
Ist das Programm installiert, so lassen sich Pins wie folgt ansprechen:
/usr/local/bin/gpio -g mode 23 out /usr/local/bin/gpio -g write 23 1
Ansprechen mit Python
apt-get install python-rpi.gpio
Beipielcode: https://code.google.com/p/raspberry-gpio-python/wiki/BasicUsage
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT) GPIO.output(18, False) GPIO.setup(17, GPIO.IN) GPIO.setup(18, GPIO.OUT) input_value = GPIO.input(17) GPIO.output(18, GPIO.HIGH)
Pull-Up und Pull-Down
Quelle: https://code.google.com/p/raspberry-gpio-python/wiki/Inputs
„If you do not have the input pin connected to anything, it will 'float'. In other words, the value that is read in is undefined because it is not connected to anything until you press a button or switch. It will probably change value a lot as a result of receiving mains interference.
To get round this, we use a pull up or a pull down resistor. In this way, the default value of the input can be set. It is possible to have pull up/down resistors in hardware and using software. In hardware, a 10K resistor between the input channel and 3.3V (pull-up) or 0V (pull-down) is commonly used. The RPi.GPIO module allows you to configure the Broadcom SOC to do this in software:“
GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_UP)
or
GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
Problem: SDA und SCL-Pins funktionieren nicht wie erwarten:
Quelle: http://raspberrypi.stackexchange.com/questions/4919/unable-to-read-from-sda-scl-as-gpio
„SDA and SCL pins have external 1k8 pull-up resistors connected. This is indeed because they are intended for I²C usage (which requires them). Unfortunately, since they are external, they can't be disabled in software.
Having pull-up resistors means that default state of the pin in HIGH, unless they are pulled to ground.“
Problem: Prellen
Portexpander
Kontroller-Chip, um 16 Ausgänge mit 2 Leitungen anzusteuern:
https://ex.ploit.ws/themagpi/The-MagPi-issue-13-en.pdf Seite 11:
Laden der Treiber zulassen:
In /etc/modprobe.d/raspi-blacklist.conf den Eintrag für i2c-bcm2708 einkommentieren. In /etc/modules einen Zeile mit i2c-dev anlegen.
Installieren der Tools zur Ansteuerung:
sudo apt-get update sudo apt-get install python-smbus sudo apt-get install i2c-tools sudo adduser pi i2c sudo reboot sudo i2cdetect -y 1
…