本文整理汇总了C++中DallasTemperature::getDeviceCount方法的典型用法代码示例。如果您正苦于以下问题:C++ DallasTemperature::getDeviceCount方法的具体用法?C++ DallasTemperature::getDeviceCount怎么用?C++ DallasTemperature::getDeviceCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DallasTemperature
的用法示例。
在下文中一共展示了DallasTemperature::getDeviceCount方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
示例2: 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;
}
示例3: setup
void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// locate devices on the bus
Serial.print("Locating devices...");
sensors.begin();
Serial.print("Found ");
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(" devices.");
// report parasite power requirements
Serial.print("Parasite power is: ");
if (sensors.isParasitePowerMode()) Serial.println("ON");
else Serial.println("OFF");
// assign address manually. the addresses below will beed to be changed
// to valid device addresses on your bus. device address can be retrieved
// by using either oneWire.search(deviceAddress) or individually via
// sensors.getAddress(deviceAddress, index)
//insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
// Method 1:
// search for devices on the bus and assign based on an index. ideally,
// you would do this to initially discover addresses on the bus and then
// use those addresses and manually assign them (see above) once you know
// the devices on your bus (and assuming they don't change).
if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
// method 2: search()
// search() looks for the next device. Returns 1 if a new address has been
// returned. A zero might mean that the bus is shorted, there are no devices,
// or you have already retrieved all of them. It might be a good idea to
// check the CRC to make sure you didn't get garbage. The order is
// deterministic. You will always get the same devices in the same order
//
// Must be called before search()
//oneWire.reset_search();
// assigns the first address found to insideThermometer
//if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
// show the addresses we found on the bus
Serial.print("Device 0 Address: ");
printAddress(insideThermometer);
Serial.println();
// set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions)
sensors.setResolution(insideThermometer, 9);
Serial.print("Device 0 Resolution: ");
Serial.print(sensors.getResolution(insideThermometer), DEC);
Serial.println();
}
示例4:
void DS18B20_init(){
#ifdef DEBUG_DS18B20_POLLER
DEBUG_1("Starting");
#endif
ds_sensors.begin();
ds_count = ds_sensors.getDeviceCount();
#ifdef DEBUG_DS18B20_POLLER
DEBUG_1("Finished");
#endif
}
示例5: setup
void setup(void)
{
// start serial port
Serial.begin(38400);
delay(1000);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
// Grab a count of devices on the wire
numberOfDevices = sensors.getDeviceCount();
// locate devices on the bus
Serial.print("Locating devices...");
Serial.print("Found ");
Serial.print(numberOfDevices, DEC);
Serial.println(" devices.");
// report parasite power requirements
Serial.print("Parasite power is: ");
if (sensors.isParasitePowerMode()) Serial.println("ON");
else Serial.println("OFF");
// Loop through each device, print out address
for(int i=0;i<numberOfDevices; i++)
{
// Search the wire for address
if(sensors.getAddress(tempDeviceAddress, i))
{
Serial.print("Found device ");
Serial.print(i, DEC);
Serial.print(" with address: ");
printAddress(tempDeviceAddress);
Serial.println();
Serial.print("Setting resolution to ");
Serial.println(TEMPERATURE_PRECISION, DEC);
// set the resolution to TEMPERATURE_PRECISION bit (Each Dallas/Maxim device is capable of several different resolutions)
sensors.setResolution(tempDeviceAddress, TEMPERATURE_PRECISION);
Serial.print("Resolution actually set to: ");
Serial.print(sensors.getResolution(tempDeviceAddress), DEC);
Serial.println();
}else{
Serial.print("Found ghost device at ");
Serial.print(i, DEC);
Serial.print(" but could not detect address. Check power and cabling");
}
}
}
示例6: setup
void setup()
{
// Note: Ethernet shield uses digitial IO pins 10,11,12, and 13
Serial.begin(9600);
Serial.println(version);
Serial.println();
// locate devices on the 1Wire bus
Serial.print("Locating devices on 1Wire bus...");
sensors.begin();
int count = sensors.getDeviceCount();
Serial.print("Found ");
Serial.print( count );
Serial.println(" devices on 1wire bus");
// select the first sensor
for ( int i=0; i<count; i++ )
{
if ( sensors.getAddress(thermometer, i) )
{
Serial.print("1wire device ");
Serial.print(i);
Serial.print(" has address: ");
printAddress(thermometer);
Serial.println();
}
else
{
Serial.print("Unable to find address for 1wire device ");
Serial.println( i );
}
}
// if you want to use a particular sensor, you can hard code it here
if (0)
{
DeviceAddress addr = { 0x10, 0xE4, 0xF1, 0xD2, 0x01, 0x08, 0x00, 0xBE };
for (uint8_t i = 0; i < 8; i++)
{
thermometer[i] = addr[i];
}
}
// show the addresses we found on the bus
Serial.print("Using 1wire device: ");
printAddress(thermometer);
Serial.println();
// set the resolution to 9 bit
sensors.setResolution(thermometer, 9);
dhcpInit();
}
示例7: oPrintTemp
void oPrintTemp(int index, float mytemp){
oled.setFontType(0);
oled.setCursor(0,0);
oled.print("devices ");
oled.print(sensor.getDeviceCount());
oled.setCursor(0,index*12+12);
oled.print("T");
oled.print(index);
oled.print(" ");
oled.print(mytemp);
oled.display();
}
示例8: sprintf
uint8_t ds18b20_initialize()
{
sensors.begin();
n_sensors = sensors.getDeviceCount();
sprintf(debug_str, "N%d", n_sensors);
debug(debug_str);
if(n_sensors > 4) n_sensors = 4;
uint8_t resolution = get_resolution(&sensors);
if(resolution > 12 || resolution < 9) {
debug("reset");
sleep_mseconds(100);
beenode_reset();
}
return n_sensors;
}
示例9: main
int main(void) {
Config32MHzClock(); // Setup the 32MHz Clock. Should really be using 2MHz...
// Setup output and input ports.
LEDPORT.DIRSET = 0xFF;
LEDPORT.OUT = 0xFF;
AD9835_PORT.DIRCLR = 0x40;
PORTC.DIRSET = 0x04;
// Start up the timer.
init_timer();
sensors.begin();
sensors.requestTemperatures();
// Wait a bit before starting the AD9835.
// It seems to take a few hundred ms to 'boot up' once power is applied.
_delay_ms(500);
// Configure the AD9835, and start in sleep mode.
AD9835_Setup();
AD9835_Sleep();
// Setup the AD9835 for our chosen datamode.
TX_Setup();
AD9835_Awake();
// Broadcast a bit of carrier.
_delay_ms(1000);
TXString("Booting up...\n"); // Kind of like debug lines.
// Start up the GPS RX UART.
init_gps();
// Turn Interrupts on.
PMIC.CTRL = PMIC_HILVLEN_bm | PMIC_LOLVLEN_bm;
sei();
sendNMEA("$PUBX,00"); // Poll the UBlox5 Chip for data.
//TXString("GPS Active, Interrupts On.\n");
int found_sensors = sensors.getDeviceCount();
//sprintf(tx_buffer,"Found %u sensors.\n",found_sensors);
// TXString(tx_buffer);
unsigned int counter = 0; // Init out TX counter.
while(1){
// Identify every few minutes
if ((counter%30 == 0)&&(data_mode != FALLBACK)) TXString("DE VK5VZI Project Horus HAB Launch - projecthorus.org \n");
// Read ADC PortA pin 0, using differential, signed input mode. Negative input comes from pin 1, which is tied to ground. Use VCC/1.6 as ref.
uint16_t temp = readADC();
float bat_voltage = (float)temp * 0.001007572056668* 8.5;
floatToString(bat_voltage,1,voltString);
// Collect GPS data
gps.f_get_position(&lat, &lon);
sats = gps.sats();
if(sats>2){LEDPORT.OUTCLR = 0x80;}
speed = gps.f_speed_kmph();
altitude = (long)gps.f_altitude();
gps.crack_datetime(0, 0, 0, &time[0], &time[1], &time[2]);
floatToString(lat, 5, latString);
floatToString(lon, 5, longString);
sensors.requestTemperatures();
_intTemp = sensors.getTempC(internal);
_extTemp = sensors.getTempC(external);
if (_intTemp!=85 && _intTemp!=127 && _intTemp!=-127 && _intTemp!=999) intTemp = _intTemp;
if (_extTemp!=85 && _extTemp!=127 && _extTemp!=-127 && _extTemp!=999) extTemp = _extTemp;
if(data_mode != FALLBACK){
// Construct our Data String
sprintf(tx_buffer,"$$DARKSIDE,%u,%02d:%02d:%02d,%s,%s,%ld,%d,%d,%d,%d,%s",counter++,time[0], time[1], time[2],latString,longString,altitude,speed,sats,intTemp,extTemp,voltString);
// Calculate the CRC-16 Checksum
char checksum[10];
snprintf(checksum, sizeof(checksum), "*%04X\n", gps_CRC16_checksum(tx_buffer));
// And copy the checksum onto the end of the string.
memcpy(tx_buffer + strlen(tx_buffer), checksum, strlen(checksum) + 1);
}else{
// If our battery is really low, we don't want to transmit much data, so limit what we TX to just an identifier, battery voltage, and our position.
sprintf(tx_buffer, "DE VK5VZI HORUS8 %s %s %s %ld", bat_voltage, latString, longString,altitude);
}
// Blinky blinky...
LEDPORT.OUTTGL = 0x20;
//.........这里部分代码省略.........
示例10: getDeviceCount
int getDeviceCount() {
sensor.begin();
deviceCount = sensor.getDeviceCount();
return deviceCount;
}