本文整理汇总了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”);
}
}
示例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
}
示例3:
float MXS1101::getTempC()
{
oneWire.reset();
_MXS1101.begin();
_MXS1101.requestTemperatures();
return _MXS1101.getTempCByIndex(0);
}
示例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);
}
}
示例5: sensorRoofTempdecic
/* Temperature Sensor */
long sensorRoofTempdecic(void)
{
long value = 0;
dallas_roof_sen.requestTemperatures();
value = dallas_roof_sen.getTempCByIndex(0);
return value;
}
示例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));
}
示例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();
}
示例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);
}
}
示例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);
}
示例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
}
}
示例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);
}
}
}
示例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);
}
示例13: oneWire
double Sensor::getDS18B20Reading()
{
OneWire oneWire(index);
DallasTemperature sensor = DallasTemperature(&oneWire);
sensor.setResolution(12);
sensor.begin();
sensor.requestTemperatures();
return sensor.getTempCByIndex(0);
}
示例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
}
示例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]);
}