summaryrefslogtreecommitdiff
path: root/Howtos/_Raspberry_Pi___42____42__Blink__42____42___.mdwn
blob: 1b4796a8b80034f72993a74174b3cb55a5af3495 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#IOT-Webseite

Urs hat auf thingspeak.com einen Account eingerichtet. Dort können kostenlos channels engerichtet werden. Jeder hat die Möglichkeit, Daten auf seinen Account hochzuladen.

##Upload-Code

Entscheidend für den Upload ist der Key und der entsprechende http-Request.



Während dem Workshop können die Sensordaten hier ausgelesen werden : [[http://thingspeak.com/channels/127415]]



# GPIO vervenden #

## Installation ##

### Um neue Software zu suchen

1. sudo apt-get update
2. sudo apt-get upgrade


### GPIO Software installieren

1. sudo apt-get install python-dev
2. sudo apt-get install python-rpi.gpio


### Adafruit Beispiele installieren

1. sudo apt-get install git
2. git clone http://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
3. cd Adafruit-Raspberry-Pi-Python-Code
4. ls

## Wo ist welcher PIN?

[[ http://pinout.xyz/ ]]


##Eine LED verbinden
<img src="https://cdn-learn.adafruit.com/assets/assets/000/024/147/medium640/raspberry_pi_little_cobbler_bb.png?1427733019" alt="LED mit Raspberry Pi verbinden">
Bild von adafruit.com

##LED mit Python-Interpreter steuern

<pre>
import RPi.GPIO as GPIO ## Importiere GPIO Bibliothek
import time ## Damit man Warten kann

GPIO.setmode(GPIO.BOARD) ## Nutze BOARD PIN-Nummerierung
GPIO.setup(7, GPIO.OUT) ## PIN 7 soll ein Ausgang sein

GPIO.output(7,True) ## Schalte GPIO pin 7 an
GPIO.output(7,False) ## Schalte GPIO pin 7 an

GPIO.cleanup() ## Um das ganze sauber zu beenden
</pre>

## Kleines Blink-Programm
<pre>
import RPi.GPIO as GPIO ## Importiere GPIO Bibliothek
import time ## Damit man Warten kann

GPIO.setmode(GPIO.BOARD) ## Nutze BOARD PIN-Nummerierung
GPIO.setup(7, GPIO.OUT) ## PIN 7 soll ein Ausgang sein


##Define a function named Blink()
def Blink(numTimes,speed):
    for i in range(0,numTimes):## Run loop numTimes
        print "Iteration " + str(i+1)## Print current loop
        GPIO.output(7,True)## Switch on pin 7
        time.sleep(speed)## Wait
        GPIO.output(7,False)## Switch off pin 7
        time.sleep(speed)## Wait
    print "Done" ## When loop is complete, print "Done"
    GPIO.cleanup()

## Ask user for total number of blinks and length of each blink
iterations = raw_input("Enter total number of times to blink: ")
speed = raw_input("Enter length of each blink(seconds): ")

## Start Blink() function. Convert user input from strings to numeric data types and pass to Blink() as parameters
Blink(int(iterations),float(speed))
</pre>


## Beispiel für Luftfeuchte- und Temperatursensor

<img src="https://cdn-learn.adafruit.com/assets/assets/000/001/860/original/raspberry_pi_dht11wiring.gif?1447864313  alt="DHT-Sensor mit Raspberry Pi verbinden">
Bild von adafruit.com

1. sudo apt-get install build-essential python-dev python-openssl
2. git clone https://github.com/adafruit/Adafruit_Python_DHT.git
3. cd Adafruit_Python_DHT/
4. sudo python setup.py install
5. cd examples/
6. sudo ./AdafruitDHT.py 11 4

# Raspberry Pi IoT

Als Beispiel sendet ein Raspberry Pi den Wert eines Potentiometers auf thingspeak.com.

Die Daten können unter dem folgenden Link angesehen werden.
[[ https://thingspeak.com/channels/127415 ]]

## Links

[[ http://www.thirdeyevis.com/pi-page-2.php ]]

[[ https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/overview ]]

[[ https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/overview ]]