本文整理汇总了C++中DallasTemperature::getTempF方法的典型用法代码示例。如果您正苦于以下问题:C++ DallasTemperature::getTempF方法的具体用法?C++ DallasTemperature::getTempF怎么用?C++ DallasTemperature::getTempF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DallasTemperature
的用法示例。
在下文中一共展示了DallasTemperature::getTempF方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: sendData
void sendData()
{
//float temp = sensors.getTempC(thermometer);
float temp = sensors.getTempF(thermometer);
Serial.print("Temp=");
Serial.println(temp);
Serial.println("connecting...");
if (client.connect())
{
Serial.println("connected");
client.print(
"PUT /store/fluffy/arduinoTempA/" );
client.print(" HTTP/1.1" CRLF
"User-Agent: Fluffy Arduino Ver 0.01" CRLF
"Host: www.fluffyhome.com" CRLF
"Accept: */" "*" CRLF // need to fix this
"Content-Length: 5" CRLF
"Content-Type: application/x-www-form-urlencoded" CRLF
CRLF );
client.println(temp);
unsigned long reqTime = millis();
// wait for a response and disconnect
while ( millis() < reqTime + 10000) // wait 10 seconds for response
{
if (client.available())
{
char c = client.read();
Serial.print(c);
}
if (!client.connected())
{
Serial.println();
Serial.println("server disconnected");
break;
}
}
Serial.println("client disconnecting");
Serial.println("");
client.stop();
}
else
{
Serial.println("connection failed");
}
}
示例3: oDispatch
char *getTemp(int tempIndex) {
static char retbuf[64];
//sensor.requestTemperatures(); // I am getting the tempratures each time in the loop, try moving this up to the fuction prior to the loop
// Maybe this is bad, to do it this way, I am resetting the index each time.
//sensor.getAddress(deviceIndexArray[tempIndex], tempIndex); //Why do I need to get the address here?
//temperature=sensor.getTempC(deviceIndexArray[tempIndex]);
temperature=sensor.getTempF(deviceIndexArray[tempIndex]);
//temperature=sensor.getTempCByIndex( tempIndex );// moved off of get address by index to get it by address
//sprintf(retbuf, "{\"value\":%.4f}", temperature*1.8 + 32);
String s = "{\"value\": ";
s.concat(String(temperature));
s.concat("}");
s.toCharArray(retbuf, 64);
oDispatch(tempIndex, temperature, deviceIndexArray[tempIndex]);
return retbuf;
}