当前位置: 首页>>代码示例>>C++>>正文


C++ DallasTemperature::getTempCByIndex方法代码示例

本文整理汇总了C++中DallasTemperature::getTempCByIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ DallasTemperature::getTempCByIndex方法的具体用法?C++ DallasTemperature::getTempCByIndex怎么用?C++ DallasTemperature::getTempCByIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DallasTemperature的用法示例。


在下文中一共展示了DallasTemperature::getTempCByIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LogTemps

void LogTemps(){
   if (!file.open(root, filename, O_CREAT | O_APPEND | O_WRITE)) {
     //error(“open”);
   }
   
// write values to the file

          sensorsa.requestTemperatures(); 
          sensorsb.requestTemperatures(); 
          sensorsc.requestTemperatures(); 
          sensorsd.requestTemperatures(); 
          

file.print(now() );
file.print("|");
file.print(sensorsa.getTempCByIndex(0));
file.print("|");
file.print(sensorsb.getTempCByIndex(0));
file.print("|");
file.print(sensorsc.getTempCByIndex(0));
file.print("|");
file.print(sensorsd.getTempCByIndex(0));
file.print("\n");

if (!file.close() || file.writeError){
 // error(“close/write”);
}
  
}
开发者ID:edboel,项目名称:projects,代码行数:29,代码来源:logtemps.c

示例2: sensorRoofTempdecic

/* Temperature Sensor */
long sensorRoofTempdecic(void)      
{
    long value =  0;
    dallas_roof_sen.requestTemperatures();
    value = dallas_roof_sen.getTempCByIndex(0);
    return value;
}
开发者ID:aobatake,项目名称:TeamRocket,代码行数:8,代码来源:sensor.cpp

示例3:

float MXS1101::getTempC()
{
	oneWire.reset();
	_MXS1101.begin();
	_MXS1101.requestTemperatures();
	return _MXS1101.getTempCByIndex(0);
}
开发者ID:ckt1010,项目名称:ArduinoLib-SMeshlink,代码行数:7,代码来源:MXS1101.cpp

示例4: setTemperature

bool setTemperature(unsigned long iTemp){
	//Serial.println("Req temp");
	sensors.requestTemperatures(); // Send the command to get temperatures
	//Serial.println("Requested");
	float tempr =  sensors.getTempCByIndex(0);
	//Serial.println("Temp res");
	//displayData("Temp res");
	char buffer[256];
	displayData(itoa(tempr, buffer, 10));
	displayData(",");
	displayData(itoa(iTemp, buffer, 10));
	displayData(",");
	//Serial.println("params");
//	Serial.println("thi:" + iTenHighMax);
//	Serial.println("tlo:" + iTenLowMax);
	if ((tempr <= iTemp) && (iTenHigh < iTenHighMax)){
		digitalWrite(TEN_WIRE, HIGH);
		displayData("H");
		iTenHigh++;
		iTenLow = 0;
	}else{
		digitalWrite(TEN_WIRE, LOW);
		displayData("L");
		iTenLow++;
		if(iTenLow >= iTenLowMax)
			iTenHigh = 0;
	}
	displayData("\r\n");

	return (tempr >= (iTemp - 1)) and (tempr <= (iTemp + 10));
}
开发者ID:geosk,项目名称:brewery,代码行数:31,代码来源:main.cpp

示例5: readTempHumid

void readTempHumid()
{
	temperatureSensor.requestTemperatures();
	double tempCelcius = temperatureSensor.getTempCByIndex(0);
	String toDrawTemp = doubleToString(tempCelcius, 2);
	
	
	double humidityVoltage = (double) analogRead(5) / 1024 * REFERENCE_VOLTAGE;
	double humidityPercentage = (humidityVoltage / REFERENCE_VOLTAGE - 0.16) / 0.0062;
	double relativeHumidity = humidityPercentage / (1.0546 - 0.00216 * tempCelcius);
	
	if(relativeHumidity > 100)
		relativeHumidity = 100;
	else if(relativeHumidity < 0)
		relativeHumidity = 0;
		
	String toDrawHumid = doubleToString(relativeHumidity, 2);
	if(deviceStatus == TEMP_VIEW)
	{
		LCD.rectangle(81, 0, 320, 240, BLACK);
		LCD.tText(7, 6, WHITE, "Temp(C): " + toDrawTemp + "C");
		LCD.tText(7, 7, WHITE, "RH%: " + toDrawHumid + "%");
	}
	
	if(writeToSD)
	{
		String toWrite = toDrawTemp + "\t" + toDrawHumid + "\n";
		LCD.appendString2File("Data", toWrite);
	}
}
开发者ID:albertchen408,项目名称:ArduinoNanoSensor,代码行数:30,代码来源:Mega+Pump.cpp

示例6: sprintf

    void DS18B20_sample(){
        #ifdef DEBUG_DS18B20_POLLER
            DEBUG_1("Starting");
        #endif
        #ifdef DEBUG_DS18B20_POLLER
            DEBUG_5("Requesting Temperatures");
        #endif
        char buf[25];
        ds_sensors.requestTemperatures();
        for (int i=0; i < ds_count; i++){
            #ifdef DEBUG_DS18B20_POLLER
                DEBUG_5("Logging DSB Pin");
            #endif
            sprintf(buf, "DS18B20.%d", i);
            logMessage(buf, ds_sensors.getTempCByIndex(i), "Degrees/C");
            #ifdef DEBUG_DS18B20_POLLER
                DEBUG_5("Logged DSB Pin");
            #endif
        }
        #ifdef DEBUG_DS18B20_POLLER
            DEBUG_2("Requested Temperatures");
        #endif


        #ifdef DEBUG_DS18B20_POLLER
            DEBUG_1("Finished");
        #endif
    }
开发者ID:Tambralinga,项目名称:loguino,代码行数:28,代码来源:code.c

示例7: doTout

void doTout() {
  String vStr;
  memset(tmpChr,0,sizeof(tmpChr));
  if (hasTpwr>0) {
    digitalWrite(hasTpwr, HIGH); // ow on
    delay(5); // wait for powerup
  }

  ds18b20.requestTemperatures();
  byte retry = 20;
  float temp=0.0;
  do {
    temp = ds18b20.getTempCByIndex(0);
    retry--;
    delay(2);
  } while (retry > 0 && (temp == 85.0 || temp == (-127.0)));

  if (hasTpwr>0) {
    digitalWrite(hasTpwr, LOW); // ow off
  }


  vStr = String("temp=") + String(temp,3);
  vStr.toCharArray(tmpChr, vStr.length()+1);
}
开发者ID:gordonthree,项目名称:multiswitch,代码行数:25,代码来源:multiswitch.cpp

示例8: oneWire

double Sensor::getDS18B20Reading()
{
    OneWire oneWire(index);
    DallasTemperature sensor = DallasTemperature(&oneWire);
    sensor.setResolution(12);
    sensor.begin();
    sensor.requestTemperatures();
    return sensor.getTempCByIndex(0);
}
开发者ID:Urokhtor,项目名称:Naga-Automation-Suite,代码行数:9,代码来源:Sensor.cpp

示例9: readData

void readData()
{
	Serial.print("Requesting temperatures...");
	sensors.requestTemperatures(); // Send the command to get temperatures
	Serial.println("DONE");

	temp = sensors.getTempCByIndex(0);
	Serial.print("Temperature for Device 1 is: ");
	Serial.print(temp); // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire
}
开发者ID:TheokieZA,项目名称:Sming,代码行数:10,代码来源:application.cpp

示例10: readSoilTemperature

float OpenGardenClass::readSoilTemperature() {
  sensors.requestTemperatures(); // Send the command to get temperatures
  return sensors.getTempCByIndex(0);
}
开发者ID:thaussma,项目名称:OpenGarden,代码行数:4,代码来源:OpenGarden.cpp

示例11: ds18b20

void ds18b20() {

  DS18B201.requestTemperatures();
  DS18B202.requestTemperatures();
  DS18B203.requestTemperatures();
  DS18B204.requestTemperatures();

  int i1 = 0;
  int i2 = 0;
  int i3 = 0;
  int i4 = 0;
  temp11 = DS18B201.getTempCByIndex(0);
  while ((temp11 == 85) && (i1 < 5))
  {
    delay (1000);
    DS18B201.requestTemperatures();
    temp11 = DS18B201.getTempCByIndex(0);
    i1++;
  }

  temp22 = DS18B202.getTempCByIndex(0);
  while ((temp22 == 85) && (i2 < 5))
  {
    delay (1000);
    DS18B202.requestTemperatures();
    temp22 = DS18B202.getTempCByIndex(0);
    i2++;
  }

  temp33 = DS18B203.getTempCByIndex(0);
  while ((temp33 == 85) && (i3 < 5))
  {
    delay (1000);
    DS18B203.requestTemperatures();
    temp33 = DS18B203.getTempCByIndex(0);
    i3++;
  }

  temp44 = DS18B204.getTempCByIndex(0);
  while ((temp44 == 85) && (i4 < 5))
  {
    delay (1000);
    DS18B204.requestTemperatures();
    temp44 = DS18B204.getTempCByIndex(0);
    i4++;
  }


  EEPROM.begin(512);
  delay(10);
  String temp1k = "";
  String temp2k = "";
  String temp3k = "";
  String temp4k = "";
  for (int i = 110; i < 115; i++)
  {
    temp1k += char(EEPROM.read(i));
  }
  for (int i = 115; i < 120; i++)
  {
    temp2k += char(EEPROM.read(i));
  }
  for (int i = 120; i < 125; i++)
  {
    temp3k += char(EEPROM.read(i));
  }
  for (int i = 125; i < 130; i++)
  {
    temp4k += char(EEPROM.read(i));
  }
  EEPROM.end();
  Serial.println("Kalibrierung T1: " + temp1k);
  Serial.println("Kalibrierung T2: " + temp2k);
  Serial.println("Kalibrierung T3: " + temp3k);
  Serial.println("Kalibrierung T4: " + temp4k);


  temp1 = temp11 + temp1k.toInt();
  temp2 = temp22 + temp2k.toInt();
  temp3 = temp33 + temp3k.toInt();
  temp4 = temp44 + temp4k.toInt();
  //String tempC = dtostrf(temp, 4, 1, buffer);//handled in sendTemp()
  Serial.print(String(sent) + " Temperature_neu1: ");
  Serial.println(temp1);
  Serial.println("Temperature_neu2: ");
  Serial.println(temp2);
  Serial.println("Temperature_neu3: ");
  Serial.println(temp3);
  Serial.println("Temperature_neu4: ");
  Serial.println(temp4);

  NTP();
}
开发者ID:TobiasN82,项目名称:SMASE,代码行数:93,代码来源:main.cpp

示例12: loop

void loop()
{	
	msgStatus.voltage = (12 * analogRead(pin_voltage) + 4*prev_voltage)/16;
	prev_voltage = msgStatus.voltage;
	msgStatus.voltage *= 30;
	msgStatus.current = (12 * analogRead(pin_current) + 4*prev_current)/16;
	prev_current = msgStatus.current;
	msgStatus.current = 333*(msgStatus.current - 501);
    
	if(abs(msgStatus.current) <= 1000 )
	{
		// Current is less than 1 amp in either direction,
		// Batteries are (probably?) disconnected.
		batteryState = ERROR;
	}
    else if(msgStatus.voltage < 20000)
    {
        batteryState = ERROR;
        stateOfCharge = 0;
    }
	else if(msgStatus.current > 0)
	{
		// If current is positive, we are charging
		stateOfCharge = 100;
		if (msgStatus.current < 3000)
			batteryState = TRICKLE_CHARGING;
		else
			batteryState = CHARGING;
	} else {
		// Otherwise, we are discharging.
		stateOfCharge = msgStatus.voltage/25 - 900;
		if (stateOfCharge > 100)
			stateOfCharge = 100;
		if (stateOfCharge < 20)
			batteryState = DISCHARGING_CRITICAL;
		else
			batteryState = DISCHARGING;
	}
	msgStatus.battery_state = batteryState;
	msgStatus.charge = stateOfCharge;
	updateBatteryDisplay();
	
	msgStatus.temperature_1 = temperatureTop.getTempCByIndex(0);
	msgStatus.temperature_2 = temperatureBot.getTempCByIndex(0);
	temperatureTop.requestTemperatures();
	temperatureBot.requestTemperatures();
	
	msgStatus.cutter_1 = (digitalRead(pin_leftCutterCheck) ? FALSE : TRUE);
	msgStatus.cutter_2 = (digitalRead(pin_rightCutterCheck) ? FALSE : TRUE);
	
	if(leftCutterState && !msgStatus.cutter_1)
	{
		digitalWrite(pin_leftCutterControl, LOW);
		leftCutterState = LOW;
		msgStatus.cutter_1 = FALSE;
	}
	if(rightCutterState && !msgStatus.cutter_2)
	{
		digitalWrite(pin_rightCutterControl, LOW);
		rightCutterState = LOW;
		msgStatus.cutter_2 = FALSE;
	}
	
	status_pub.publish( &msgStatus );
	nh.spinOnce();
	delay(400);
}
开发者ID:Auburn-Automow,项目名称:au_automow_drivers,代码行数:67,代码来源:power_control.cpp

示例13:

uint16_t ds18b20_read_value(uint8_t index)
{
  sensors.requestTemperatures();
  uint16_t value = ((uint16_t)(sensors.getTempCByIndex(index) * 100) + 5500);
  return value;
}
开发者ID:Shanjiv,项目名称:1st-IOT-Project,代码行数:6,代码来源:ds18b20.cpp

示例14: GetTempValue

float Aquarium::GetTempValue() {
  temp = dallastemp.getTempCByIndex(0);
  return temp;
}
开发者ID:djtulan,项目名称:Arduino-Aquarium,代码行数:4,代码来源:aquarium.cpp

示例15: loop

void loop()
{
  Client client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so we can send a reply
        if (c == '\n' && current_line_is_blank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();

          // print all the files, use a helper to keep it clean
          //ListFiles(client, 0);
          client.println("<h2>Temperature:</h2>");
          
          sensorsa.requestTemperatures(); 
          sensorsb.requestTemperatures(); 
          sensorsc.requestTemperatures(); 
          sensorsd.requestTemperatures(); 
          client.println(sensorsa.getTempCByIndex(0));
           client.println("<br>");
           client.println(sensorsb.getTempCByIndex(1));
           client.println("<br>");
           client.println(sensorsc.getTempCByIndex(2));
           client.println("<br>");
           client.println(sensorsd.getTempCByIndex(3));
           client.println("<br><br>..");
          //ListFiles(client, 0);

          break;
        }
        if (c == '\n') {
          // we're starting a new line
          current_line_is_blank = true;
        } 
        else if (c != '\r') {
          // we've gotten a character on the current line
          current_line_is_blank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    client.stop();
  }
  

  if(now() > time33mins + (33 * SECS_PER_MIN) )
  {
    //Serial.println("33 minutes has elapsed");
   
    time33mins = now();    
     LogTemps();
  }
  if(now() > time60mins + (60 * SECS_PER_MIN) )
  {
    //Serial.println("one hour has elapsed");
    time60mins = now(); 
    LogTemps();   
  }

}
开发者ID:edboel,项目名称:projects,代码行数:69,代码来源:logtemps.c


注:本文中的DallasTemperature::getTempCByIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。