|
|
(5 dazwischenliegende Versionen von einem anderen Benutzer werden nicht angezeigt) |
Zeile 1: |
Zeile 1: |
| ==Bild== | | ==Bild== |
− | [[Datei:KY-001.jpg|none|358x358px]] | + | [[Datei:lk_accel.png|none|250x187px]] |
| | | |
| ==Technische Daten / Kurzbeschreibung== | | ==Technische Daten / Kurzbeschreibung== |
− | Chipsatz: DS18B20 | Kommunikationsprotokoll: 1-Wire<br /><br />9- 12Bit genaue Temperaturmessung im Meßbereich von –55°C bis +125°C
| + | Linker Kit Platine mit Beschleunigungs-/Bewegungssensor |
| | | |
− | ==Pin-Belegung==
| |
− | [[Datei:3_S_V_G.png|none]]
| |
| | | |
| | | |
| ==Codebeispiel Arduino== | | ==Codebeispiel Arduino== |
− | Das Programm
| + | <pre class="brush:cpp"> </pre> |
− | | + | |
− | <pre class="brush:cpp"> | + | |
− | # Include
| + | |
− | OneWire ds (10); / / on pin 10
| + | |
− | void setup (void) {
| + | |
− | // Initialize inputs / outputs
| + | |
− | // Start serial port
| + | |
− | Serial.begin (9600);
| + | |
− | }
| + | |
− | void loop (void) {
| + | |
− | byte i;
| + | |
− | byte present = 0;
| + | |
− | byte data [12];
| + | |
− | byte addr [8];
| + | |
− | int Temp;
| + | |
− | if (! ds.search (addr)) {
| + | |
− | // Serial.print ("No more addresses.");
| + | |
− | ds.reset_search ();
| + | |
− | return;
| + | |
− | }
| + | |
− | Serial.print ("R ="); // R = 28 Not sure what this is
| + | |
− | for (i = 0; i <8; i ) {
| + | |
− | Serial.print (addr [i], HEX);
| + | |
− | Serial.print ("");
| + | |
− | }
| + | |
− | if (OneWire :: crc8 (addr, 7)! = addr [7]) {
| + | |
− | Serial.print ("CRC is not valid!");
| + | |
− | return;
| + | |
− | }
| + | |
− | if (addr [0]! = 0x28) {
| + | |
− | Serial.print ("Device is not a DS18S20 family device.");
| + | |
− | return;
| + | |
− | }
| + | |
− | ds.reset ();
| + | |
− | }
| + | |
− | | + | |
− | </pre> | + | |
− | | + | |
− | '''Anschlussbelegung Arduino:'''
| + | |
− | | + | |
− | {| style="height: 58px; padding-left: 30px;" width="228"
| + | |
− | |-
| + | |
− | ||LED +
| + | |
− | ||=
| + | |
− | ||[Pin 13]
| + | |
− | |-
| + | |
− | ||LED -
| + | |
− | ||=
| + | |
− | ||[Pin GND]
| + | |
− | |-
| + | |
− | ||Sensor Signal
| + | |
− | ||=
| + | |
− | ||[Pin 10]
| + | |
− | |-
| + | |
− | ||Sensor +V
| + | |
− | ||=
| + | |
− | ||[Pin 5V]
| + | |
− | |-
| + | |
− | ||Sensor -
| + | |
− | ||=
| + | |
− | ||[Pin GND]
| + | |
− | |}
| + | |
− | | + | |
− | '''Beispielprogramm Download'''
| + | |
− | | + | |
− | [[Medium:SensorTest_Arduino.zip|SensorTest_Arduino.zip]]
| + | |
| | | |
| ==Codebeispiel Raspberry Pi== | | ==Codebeispiel Raspberry Pi== |
− | Programmierbeispiel in der Programmiersprache Python
| + | <pre class="brush:py"> </pre> |
− | | + | |
− | <pre class="brush:py"># Benoetigte Module werden importiert und eingerichtet | + | |
− | import RPi.GPIO as GPIO
| + | |
− | import time
| + | |
− |
| + | |
− | GPIO.setmode(GPIO.BCM)
| + | |
− |
| + | |
− | # Hier wird der Eingangs-Pin deklariert, an dem der Sensor angeschlossen ist. Zusaetzlich wird auch der PullUP Widerstand am Eingang aktiviert
| + | |
− | GPIO_PIN = 24
| + | |
− | GPIO.setup(GPIO_PIN, GPIO.IN, pull_up_down = GPIO.PUD_UP)
| + | |
− |
| + | |
− | print "Sensor-Test [druecken Sie STRG+C, um den Test zu beenden]"
| + | |
− |
| + | |
− | # Diese AusgabeFunktion wird bei Signaldetektion ausgefuehrt
| + | |
− | def ausgabeFunktion(null):
| + | |
− | print("Signal erkannt")
| + | |
− |
| + | |
− | # Beim Detektieren eines Signals (fallende Signalflanke) wird die Ausgabefunktion ausgeloest
| + | |
− | GPIO.add_event_detect(GPIO_PIN, GPIO.FALLING, callback=ausgabeFunktion, bouncetime=100)
| + | |
− |
| + | |
− | # Hauptprogrammschleife
| + | |
− | try:
| + | |
− | while True:
| + | |
− | time.sleep(1)
| + | |
− |
| + | |
− | # Aufraeumarbeiten nachdem das Programm beendet wurde
| + | |
− | except KeyboardInterrupt:
| + | |
− | GPIO.cleanup()
| + | |
− | | + | |
− | </pre> | + | |
− | '''Anschlussbelegung Raspberry Pi:'''
| + | |
− | | + | |
− | {| style="height: 58px; padding-left: 30px;" width="228"
| + | |
− | |-
| + | |
− | ||Signal
| + | |
− | ||=
| + | |
− | ||GPIO24
| + | |
− | ||[Pin 18]
| + | |
− | |-
| + | |
− | ||+V
| + | |
− | ||=
| + | |
− | ||3,3V
| + | |
− | ||[Pin 1]
| + | |
− | |-
| + | |
− | ||GND
| + | |
− | ||=
| + | |
− | ||Masse
| + | |
− | ||[Pin 6]
| + | |
− | |}
| + | |
| | | |
| '''Beispielprogramm Download''' | | '''Beispielprogramm Download''' |
| | | |
− | [[Medium:SensorTest_RPi.zip|SensorTest_RPi.zip]] | + | [[Medium:KY-001_RPi_TemperaturSensor.zip|KY-001_RPi_TemperaturSensor.zip]] |
− | | + | |
− | Zu starten mit dem Befehl:
| + | |
− | | + | |
− | <pre class="brush:bash">sudo python SensorTest_RPi.py
| + | |
− | </pre>
| + | |