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


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

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


在下文中一共展示了DallasTemperature::requestTemperatures方法的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: 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

示例3:

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

示例4: temperatureJob

void temperatureJob() {
    float gotTemp = 0;
    Serial << "the device count is " << deviceCount << endl;
    sensor.requestTemperatures();  // get all the tempratures first to speed up, moved up from getTemp()
    for (int i =0; i < deviceCount; i++ ) {
        gotTemp = sensor.getTempF(*deviceAddressArray[i]);
        if (gotTemp < -195 ) continue;
        Serial << "gotTemp() = "  << i << " " << gotTemp << endl;
        request.body = formatTempToBody(gotTemp, i);
      //  if (mycounter % PUSHFREQ == 0  && PUSHTOUBIFLAG == 1 ) {
       if (mycounter % PUSHFREQ == 0  && PUSHTOUBIFLAG == 1) {
            String mypath = String("/api/v1.6/variables/");
            mypath.concat(ubivar[i]);
            mypath.concat("/values");
            Serial << "going to push "<< request.body << " to " << mypath << endl;
            request.path = mypath;
            http.post(request, response, headers);
            if( debug ) Serial << "http body: " << request.body << endl;

            Serial << " Did we reboot?    I hope not ";
        }
      if( debug) debugSerial(i);

    }
}
开发者ID:RobertNewkirk,项目名称:particle,代码行数:25,代码来源:endevor2.cpp

示例5: 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

示例6: 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

示例7: setup

void setup() {

  // Init display
  mySerial.begin(9600); // set up serial port for 9600 baud
  delay(500); // wait for display to boot up
  


  // Setup DS1820 temp sensor

  sensors.begin();
  sensors.setResolution(Sensor1, 11);
  sensors.setResolution(Sensor2, 11);
  sensors.setWaitForConversion(false);
  sensors.requestTemperatures();
  delayInMillis = 750 / (1 << (12 - 11)); //750 for 12bit, 400 for 11bit, 220 for 10bit, 100 for 9bit
                        // calc by   delayInMillis = 750 / (1 << (12 - resolution)); 
  lastTempRequest = millis(); 


  // Set next state i FSM
  menu_FSM = M_PAGE1;
  menu_last_state = M_PAGE1;
  system_FSM = S_IDLE;
 
 
   // **************** Set up display *******************
  DisplayClear();
  MenuShowTime = millis();
 
  
  // **************** Set up RTC ***********************
  Wire.begin();
  rtc.begin();
  //TimeDate(rtc.now(),dateTimeString,1);

  //DateTime now = rtc.now();

 // write on display
  DisplayGoto(2,0);
  mySerial.print("Version 0.9B");

  
  // **************** Set up SD card *******************
  pinMode(10, OUTPUT);
  DisplayGoto(1,0);
  mySerial.write("Init SD -> "); // clear display + legends
 
  DisplayGoto(1,11);
  // see if the card is present and can be initialized:
  if (!SD.begin())
    mySerial.write("Fail");
  else
    mySerial.write("OK");
  delay(2000);
  
  // ***************** Clear display ********************
  DisplayClear();
   
  }
开发者ID:lvesterg,项目名称:heater,代码行数:60,代码来源:heater_FSM.c

示例8: 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

示例9: 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

示例10: loop

void loop(void)
{ 
	delay(2000);
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  
  
  // Loop through each device, print out temperature data
  for(int i=0;i<numberOfDevices; i++)
  {
    // Search the wire for address
    if(sensors.getAddress(tempDeviceAddress, i))
	{
		// Output the device ID
		Serial.print("Temperature for device: ");
		Serial.println(i,DEC);
		
		// It responds almost immediately. Let's print out the data
		printTemperature(tempDeviceAddress); // Use a simple function to print out the data
	} 
	//else ghost device! Check your power requirements and cabling
	
  }
}
开发者ID:hdo,项目名称:arduino_panstamp,代码行数:27,代码来源:Tester.cpp

示例11: tempSensorsPrintInfo

/**
*	\brief Prints all connected OneWire sensors with there index
		and current temperature value. 
*/
void tempSensorsPrintInfo(void){
		uint8_t address[8];
		float temp;
		
		uint8_t deviceCount=sensors.getDeviceCount();
		Serial.print("Found devices: ");
		Serial.println(deviceCount);
		Serial.println(" ");
		
		sensors.requestTemperatures();
			
		for(int i=0; i<deviceCount; i++){
			Serial.print("Device: ");
			Serial.println(i);
			if(sensors.getAddress(address, i)){

				temp=sensors.getTempC(address);
				
				Serial.print("Temp: ");
				Serial.print(temp);
				Serial.println(" ");
				//delay(100);
				
				Serial.print("Resolution: ");
				Serial.println(sensors.getResolution(address));
				Serial.println("");
				//delay(100);
			}
		
		}
	
}
开发者ID:basaf,项目名称:MQTT_Module,代码行数:36,代码来源:TempSensor.cpp

示例12: setup

void setup()
{
    pinMode(13, OUTPUT);

    // Set up all of the Digital IO pins.
    pinMode(pin_leftCutterCheck,INPUT);
    pinMode(pin_rightCutterCheck,INPUT);
    pinMode(pin_leftCutterControl,OUTPUT);
    pinMode(pin_rightCutterControl,OUTPUT);
    // Turn off the cutters by default
    digitalWrite(pin_leftCutterControl,LOW);
    digitalWrite(pin_rightCutterControl,LOW);

	// Initialize the rear panel LED outputs
    pinMode(pin_ledHigh,OUTPUT);
    pinMode(pin_ledMid,OUTPUT);
	pinMode(pin_ledLow,OUTPUT);
	digitalWrite(pin_ledHigh, LOW);
	digitalWrite(pin_ledMid, LOW);
	digitalWrite(pin_ledLow, LOW);
	
	temperatureTop.begin();
    temperatureBot.begin();
    
    // Make sure we have temperature sensors, if not, set to something
    // unreasonable. This would be 0 in Alabama.
    if(!temperatureTop.getAddress(topAddress,0))
    {
        msgStatus.temperature_1 = 0.0;
    } else {
        temperatureTop.setResolution(topAddress,9);
        temperatureTop.setWaitForConversion(false);
        temperatureTop.requestTemperatures();
    }
    if(!temperatureBot.getAddress(botAddress,0))
    {
        msgStatus.temperature_2 = 0.0;
    } else {
        temperatureBot.setResolution(botAddress,9);
        temperatureBot.setWaitForConversion(false);
        temperatureBot.requestTemperatures();
    }
    nh.initNode(); 
	nh.advertise(status_pub);
	nh.advertiseService(cutter_srv);
}
开发者ID:Auburn-Automow,项目名称:au_automow_drivers,代码行数:46,代码来源:power_control.cpp

示例13: 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

示例14: 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

示例15: updateTemperature

void updateTemperature()
{
	sensor.requestTemperatures();
	tempInCelsius  = (int) (sensor.getTempC(devAddr)*10);    
	digitValues[0] = tempInCelsius / 100;
	digitValues[1] = (tempInCelsius % 100) / 10;
	digitValues[2] = tempInCelsius % 10;

	for (int i = 0; i < N-1; i++)
		display.writeDigit(i, digitValues[i]);
}
开发者ID:eduardomdrs,项目名称:rtc_therm_7seg,代码行数:11,代码来源:MexClk.cpp


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