Modèle:Sensor

De SensorKit X40 Wiki

Aller à : navigation, rechercher

Bild

KY-001.jpg

Technische Daten / Kurzbeschreibung

Chipsatz: DS18B20 | Kommunikationsprotokoll: 1-Wire

9- 12Bit genaue Temperaturmessung im Meßbereich von –55°C bis +125°C

Pin-Belegung

3 S V G.png

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 ();
}