bool DallasTemperature::isConversionAvailable(const uint8_t* deviceAddress)
{
    // Check if the clock has been raised indicating the conversion is complete
    ScratchPad scratchPad;
    readScratchPad(deviceAddress, scratchPad);
    return scratchPad[0];
}
Ejemplo n.º 2
0
void DallasTemperature::begin(void) {
    DeviceAddress deviceAddress;

    _wire->reset_search();

    devices = 0; // Reset the number of devices when we enumerate wire devices

    while (_wire->search(deviceAddress)) {
        if (validAddress(deviceAddress)) {
#if REQUIRESPARASITEPOWERAVAILABLE
            if (!parasite && readPowerSupply(deviceAddress)) parasite = true;
#endif			

            ScratchPad scratchPad;
            readScratchPad(deviceAddress, scratchPad);

#if REQUIRESONLY12BITCONVERSION			
            setResolution(deviceAddress, 12);
#else
            //bitResolution = max(bitResolution, getResolution(deviceAddress));
            uint8_t newResolution = getResolution(deviceAddress);
            if (newResolution > bitResolution) { // the max macro may call getResultion multiple times. 
                bitResolution = newResolution;
            }
#endif
            devices++;
        }
    }
}
bool DallasTemperature::readScratchPadCRC(const uint8_t* deviceAddress, uint8_t* scratchPad) {
    for (uint8_t i = 0; i < DALLAS_CRC_RETRIES; i++) {
        readScratchPad(deviceAddress, scratchPad);
        bool crcMatch = _wire->crc8(scratchPad, 8) == scratchPad[SCRATCHPAD_CRC];
        if (crcMatch) {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 4
0
// returns the current resolution, 9-12
uint8_t DallasTemperature::getResolution(uint8_t* deviceAddress)
{
  if (deviceAddress[0] == DS18S20MODEL) return 9; // this model has a fixed resolution

  ScratchPad scratchPad;
  readScratchPad(deviceAddress, scratchPad);
  switch (scratchPad[CONFIGURATION])
  {
    case TEMP_12_BIT:
      return 12;
      break;
    case TEMP_11_BIT:
      return 11;
      break;
    case TEMP_10_BIT:
      return 10;
      break;
    case TEMP_9_BIT:
      return 9;
      break;
  }
}
Ejemplo n.º 5
0
// initialize the bus
void DallasTemperature::begin(void)
{
  DeviceAddress deviceAddress;

  _wire->reset_search();
  devices = 0; // Reset the number of devices when we enumerate wire devices

  while (_wire->search(deviceAddress))
  {
    if (validAddress(deviceAddress))
    {
      if (!parasite && readPowerSupply(deviceAddress)) parasite = true;

      ScratchPad scratchPad;

      readScratchPad(deviceAddress, scratchPad);

	  bitResolution = max(bitResolution, getResolution(deviceAddress));

      devices++;
    }
  }
}
Ejemplo n.º 6
0
// initialize the bus
void DallasTemperature::begin(void)
{
  DeviceAddress deviceAddress;

  _wire->reset_search();

  while (_wire->search(deviceAddress))
  {
    if (validAddress(deviceAddress))
    {      
      if (!parasite && readPowerSupply(deviceAddress)) parasite = true;

      ScratchPad scratchPad;

      readScratchPad(deviceAddress, scratchPad);

      if (deviceAddress[0] == DS18S20MODEL) conversionDelay = TEMP_12_BIT; // 750 ms
      else if (scratchPad[CONFIGURATION] > conversionDelay) conversionDelay = scratchPad[CONFIGURATION];

      devices++;
    }
  }
}
Ejemplo n.º 7
0
// attempt to determine if the device at the given address is connected to the bus
// also allows for updating the read scratchpad
bool DallasTemperature::isConnected(uint8_t* deviceAddress, uint8_t* scratchPad)
{
  readScratchPad(deviceAddress, scratchPad);
  return (_wire->crc8(scratchPad, 8) == scratchPad[SCRATCHPAD_CRC]);
}