Vorlage:Sensor: Unterschied zwischen den Versionen
Aus Linkerkit.de
(→Codesprache Python) |
|||
Zeile 45: | Zeile 45: | ||
==Codebeispiel Raspberry Pi== | ==Codebeispiel Raspberry Pi== | ||
− | + | Codesprache Python | |
<pre class="brush:py"># Include | <pre class="brush:py"># Include |
Version vom 9. Februar 2016, 10:48 Uhr
Inhaltsverzeichnis
Bild
Technische Daten / Kurzbeschreibung
Chipsatz: DS18B20 | Kommunikationsprotokoll: 1-Wire
9- 12Bit genaue Temperaturmessung im Meßbereich von –55°C bis +125°C
Pin-Belegung
Codebeispiel Arduino
# 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 (); }
Codebeispiel Raspberry Pi
Codesprache Python
# 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 (); }