本文整理汇总了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”);
}
}
示例2: sensorRoofTempdecic
/* Temperature Sensor */
long sensorRoofTempdecic(void)
{
long value = 0;
dallas_roof_sen.requestTemperatures();
value = dallas_roof_sen.getTempCByIndex(0);
return value;
}
示例3:
float MXS1101::getTempC()
{
oneWire.reset();
_MXS1101.begin();
_MXS1101.requestTemperatures();
return _MXS1101.getTempCByIndex(0);
}
示例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));
}
示例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);
}
}
示例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
}
示例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);
}
示例8: oneWire
double Sensor::getDS18B20Reading()
{
OneWire oneWire(index);
DallasTemperature sensor = DallasTemperature(&oneWire);
sensor.setResolution(12);
sensor.begin();
sensor.requestTemperatures();
return sensor.getTempCByIndex(0);
}
示例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
}
示例10: readSoilTemperature
float OpenGardenClass::readSoilTemperature() {
sensors.requestTemperatures(); // Send the command to get temperatures
return sensors.getTempCByIndex(0);
}
示例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();
}
示例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);
}
示例13:
uint16_t ds18b20_read_value(uint8_t index)
{
sensors.requestTemperatures();
uint16_t value = ((uint16_t)(sensors.getTempCByIndex(index) * 100) + 5500);
return value;
}
示例14: GetTempValue
float Aquarium::GetTempValue() {
temp = dallastemp.getTempCByIndex(0);
return temp;
}
示例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();
}
}