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 }
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(); }
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"); } } }