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


C++ DallasTemperature类代码示例

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


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

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

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

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

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

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

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

示例7:

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

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

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

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

/**
 * @brief arduino setup function
 */
void setup() {
  Serial.begin(9600);

  Display::Init();

  if (RTC.get() == 0) {
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.set(hhmmss());
  }

  setSyncProvider(RTC.get); // the function to get the time from the RTC

  // Transmitter is connected to Arduino Pin #10
  mySwitch.enableTransmit(7);

  dallastemp.begin(); // Inizialisieren der Dallas Temperature library
  dallastemp.setWaitForConversion(false);

  aqua.begin();

  pinMode(BUTTON_PIN_1, INPUT_PULLUP);
  pinMode(BUTTON_PIN_2, INPUT_PULLUP);
//  pinMode(BUTTON_PIN_3, INPUT_PULLUP);
//  pinMode(BUTTON_PIN_4, INPUT_PULLUP);
}
开发者ID:djtulan,项目名称:Arduino-Aquarium,代码行数:28,代码来源:aquarium.cpp

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

示例13: createAddressTable

/**
*	\brief Creates a table with all sensors which are connected via OneWire.
*		
*		The table is created on the basis of a previous table which is stored
*		in the EEPROM. This helps to have a consistent assignment of the sensor ID
*		to the connected sensor. Otherwise this can change after a reset or if a 
*		sensor is removed.	
*/
error_t createAddressTable(void){
	uint8_t address[8];
	tempSensorTable.size=0;
	uint8_t index=0;
	tempSensorTable_t eepromTable;
	
	memset(&tempSensorTable,0,sizeof(tempSensorTable_t));
	
	int8_t deviceCount=sensors.getDeviceCount();
	for(int i=0; i<deviceCount; i++){
		if(sensors.getAddress(address, i)){
			memcpy(tempSensorTable.tableEntry[index].address,address,sizeof(address));
			tempSensorTable.tableEntry[index].tempSensorID=i;
			tempSensorTable.tableEntry[index].enabled=1;		//default: send temp sensor value
			++index;	
		}
	}
	tempSensorTable.size=index;
	
	if(!loadAddressTableFromEEPROM(&eepromTable)){
		//table found in EEPROM
		mergeTables(&eepromTable, &tempSensorTable);
	}
	
	writeAddressTableToEEPROM(&tempSensorTable);
	
	return ERR_NO_ERR;
}
开发者ID:basaf,项目名称:MQTT_Module,代码行数:36,代码来源:TempSensor.cpp

示例14: sensor_setup

void sensor_setup(){  
  temp_sensor.begin();//initialize one wire sensor
  temp_sensor.setResolution(insideThermometer, 9);  //configure sensor parameters 
  
   
#ifdef DEBUG_SENS
  // report on finding the devices on the bus or not
  if (!temp_sensor.getAddress(insideThermometer, 0)) softdebug.println("Unable to find address for Device 0");
  else{  
    
    // report parasite power requirements
    softdebug.print("Parasite power is: "); 
    if (temp_sensor.isParasitePowerMode()) softdebug.println("ON");
    else softdebug.println("OFF");
    
    sensors_temperature(); //print temperature for debugging
    
  }
  
  //print voltage sensor value for debugging
  softdebug.print("Vin=");
  softdebug.println(sensors_vin());
  
#endif //DEBUG_SENS
}
开发者ID:Balua,项目名称:Balua_AIO_Tracker_V1_0_Code,代码行数:25,代码来源:sensors_avr.cpp

示例15: begin

void Thermometer::begin() {
   if (!initialized) {
      // Start up the library
      sensors.begin();
      sensors.setResolution(thermometerAddress, RESOLUTION);

      initialized = true;
   }
}
开发者ID:slobrewer,项目名称:FermbotPrototype,代码行数:9,代码来源:Thermometer.cpp


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