本文整理汇总了C++中DallasTemperature::setResolution方法的典型用法代码示例。如果您正苦于以下问题:C++ DallasTemperature::setResolution方法的具体用法?C++ DallasTemperature::setResolution怎么用?C++ DallasTemperature::setResolution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DallasTemperature
的用法示例。
在下文中一共展示了DallasTemperature::setResolution方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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
}
示例3: setup
void setup()
{
Serial.begin(9600);
Serial.print("Initializing SD card...");
pinMode(10, OUTPUT);
sensors.begin();
sensors.setResolution(outsideThermometer, 10);
sensors.setResolution(insideThermometer, 10);
// bmp085Calibration();
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
return;
}
Serial.println("card initialized.");
}
示例4: tempSenosrsInit
/**
* \brief Initializes the temperature sensors with a given resolution
*/
void tempSenosrsInit(const uint8_t resolution){
sensors.begin();
if(resolution >= 9 && resolution <=12){
sensors.setResolution(resolution);
Serial.println(F("Setting resolution to ")); Serial.print(resolution); Serial.println(F(" bit"));
}
else{
//default is 10-bit
Serial.println(F("Setting default resolution of temperature sensors"));
sensors.setResolution(DEFAULT_RESOLUTION);
}
Serial.println(F("Create address table for OneWire sensors..."));
createAddressTable();
Serial.print(F("Temperature Sensors initialized @ pin ")); Serial.println(ONE_WIRE_BUS_PIN);
}
示例5: 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);
}
示例6: 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();
}
示例7: begin
void Thermometer::begin() {
if (!initialized) {
// Start up the library
sensors.begin();
sensors.setResolution(thermometerAddress, RESOLUTION);
initialized = true;
}
}
示例8: oneWire
double Sensor::getDS18B20Reading()
{
OneWire oneWire(index);
DallasTemperature sensor = DallasTemperature(&oneWire);
sensor.setResolution(12);
sensor.begin();
sensor.requestTemperatures();
return sensor.getTempCByIndex(0);
}
示例9: 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");
}
}
}
示例10: 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();
}
示例11: Hardware_Initialize
void Hardware_Initialize()
{
// DS18B20 initialization
sensors.begin();
sensors.setResolution(inSoilThermometer, TEMPERATURE_PRECISION);
pinMode(WSPEED, INPUT_PULLUP); // input from wind meters windspeed sensor
pinMode(RAIN, INPUT_PULLUP); // input from wind meters rain gauge sensor
pinMode(SOIL_MOIST_POWER, OUTPUT); // power control for soil moisture
digitalWrite(SOIL_MOIST_POWER, LOW); // Leave off by defualt
// Setup status LED
pinMode(STATUS_LED, OUTPUT);
digitalWrite(STATUS_LED, LOW);
Serial.begin(9600); // open serial over USB
// Initialize the I2C sensors and ping them
sensor.begin();
//
// You can only receive acurate barrometric readings or acurate altitiude
// readings at a given time, not both at the same time. The following two lines
// tell the sensor what mode to use. You could easily write a function that
// takes a reading in one made and then switches to the other mode to grab that
// reading, resulting in data that contains both acurate altitude and barrometric
// readings. For this example, we will only be using the barometer mode. Be sure
// to only uncomment one line at a time.
//
sensor.setModeBarometer(); // Set to Barometer Mode
//baro.setModeAltimeter(); // Set to altimeter Mode
// These are additional MPL3115A2 functions the MUST be called for the sensor to work.
sensor.setOversampleRate(7); // Set Oversample rate
//
// Call with a rate from 0 to 7. See page 33 for table of ratios.
// Sets the over sample rate. Datasheet calls for 128 but you can set it
// from 1 to 128 samples. The higher the oversample rate the greater
// the time between data samples.
//
sensor.enableEventFlags(); // Necessary register calls to enble temp, baro ansd alt
return;
}
示例12: init
void init()
{
Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
Serial.systemDebugOutput(true); // Allow debug output to serial
sensors.begin(); // It's required for one-wire initialization!
sensors.setResolution(12);
WifiStation.config(WIFI_SSID, WIFI_PWD);
WifiStation.enable(true);
WifiAccessPoint.enable(false);
// Run our method when station was connected to AP (or not connected)
WifiStation.waitConnection(connectOk, 20, connectFail); // We recommend 20+ seconds for connection timeout at start
procTimer2.initializeMs(3000, readData).start();
}