1 Reply Latest reply on May 25, 2015 11:11 AM by Intel_Alvarado

    use intel galileo to operate the DS18b20 and the temperature is -127℃

    pxj878

      I put a 5K resistance between power and data line .use the DallasTemperature library to get the temperature ,the result is always -127 .that's why?

       

       

       

      #include <DallasTemperature.h>

       

       

      #include <OneWire.h>

      #include <DallasTemperature.h>

       

      // 定义DS18B20数据口连接arduino的2号IO上

      #define ONE_WIRE_BUS 8

       

      // 初始连接在单总线上的单总线设备

      OneWire oneWire(ONE_WIRE_BUS);

      DallasTemperature sensors(&oneWire);

       

      void setup(void)

      {

        pinMode(9,OUTPUT);

      //  pinMode(8,OUTPUT);

       

        digitalWrite(9,LOW);

        //digitalWrite(10,LOW);

        // 设置串口通信波特率

        Serial.begin(9600);

        Serial.println("Dallas Temperature IC Control Library Demo");

       

        // 初始库

        sensors.begin();

      }

       

      void loop(void)

      {

        Serial.print("Requesting temperatures...");

        sensors.requestTemperatures(); // 发送命令获取温度

        Serial.println("DONE");

        

        Serial.print("Temperature for the device 1 (index 0) is: ");

        Serial.println(sensors.getTempCByIndex(0)); 

      }