Exemplo n.º 1
0
void DallasClass::Init(MySensor *mySensorGw, int childId, int pin)
{
	this->mySensorGw = mySensorGw;
	this->childId = childId;
	this->pin = pin;
	
	this->oneWire = OneWire(this->pin);
	this->sensors = DallasTemperature(&this->oneWire);

	this->sensors.begin();
}
Exemplo n.º 2
0
DS18B20::DS18B20(uint8_t pin) : oneWire(OneWire(pin)) {
    resetSearch();
    sendCommand(SKIP_ROM, READ_POWER_SUPPLY);
    globalPowerMode = oneWire.read_bit();

    while (selectNext()) {
        uint8_t resolution = getResolution();

        if (resolution > globalResolution) {
            globalResolution = resolution;
        }

        numberOfDevices++;
    }
}
Exemplo n.º 3
0
void CDs18b20Sensor::set_pin(int pin) 
{
    CDevice::set_pin(pin); 

    m_one_wire = OneWire(pin); 

    m_dt.setOneWire(&m_one_wire);
    m_dt.begin();

    m_device_cnt = m_dt.getDeviceCount();
    if (m_device_cnt > MAX_PROBES)
    {
        m_device_cnt = MAX_PROBES;
    }

    for (uint8_t i = 0; i < m_device_cnt; i++)
    {
        if (!m_dt.getAddress(m_addrs[i], i))
        {
            DS18B20_DBGMSG("Failed to get address!")
        }
    }
}
Exemplo n.º 4
0
void AquaTemperatureHelper::setup(uint8_t tempSensorPinNum)
{
	pinMode(tempSensorPinNum, INPUT);
	oneWire = OneWire(tempSensorPinNum);
	
}
Exemplo n.º 5
0
//~D6 (PD6) LCD D6
// D7 (PD7) LCD D7
// D8 (PB0) LCD RS
//~D9 (PB1) LCD E
//~D10(PB2) LCD Backlight ctr
//~D11(PB3) PWM for heat lamp
// D12(PB4) Power ON sensor
// D13(PB5) Alarm buzzer
// A0 (PC0) Keys sensor
// A1 (PC1) Light sensor
// A2 (PC2) Debug LED
// A3 (PC3)
// A4 (PC4) RTC SDA
// A5 (PC5) RTC SCL

OneWire oneWire = OneWire(2); // D2
DS1307 RTC = DS1307();
LCD4Bit_mod LCD = LCD4Bit_mod();
KeyPad KEYS = KeyPad(A0);
Alarm ALARM = Alarm();
TempManager TEMP = TempManager(oneWire);
UIManager UI = UIManager();
System SYSTEM = System();
EpromManager EEPROM = EpromManager();

//////////////////////////////////////////////////////////////////////////

byte range_cycle(byte min, byte max, byte val)
{
  if(val > max) return min;
  if(val < min) return max;
Exemplo n.º 6
0
/* readSerialID() - reads the Waspmote unique serial identifier
 *
 * It reads the Waspmote unique serial identifier
 */
unsigned long WaspUtils::readSerialID()
{
	Utils.setLED(LED0,LED_OFF);
	Utils.setLED(LED1,LED_OFF);
	
	WaspOneWire OneWire(LED1);
	
	int data[64];
	int aux_48[48];
	unsigned long id = 0;
	unsigned long ID_ERROR = 0xFFFFFFFF;
	unsigned long seed = 1;
	
	// Powering the serial ID chip
	pinMode(LED0, OUTPUT);
	digitalWrite(LED0,HIGH);
	
	// reset DS2411 chip
	OneWire.resetSerialID();
	
	// REVISAR ESTO: con unas placas funciona asi
	// con otras hay que comentar las dos siguientes lineas
	// para que funcione
	Utils.setLED(LED1,LED_ON);
	delay(10);
  
    // ask the ID number
	OneWire.write(0x33,0);
	delay(50);
	
	// read the ID number
	for (int i = 63; i >= 0;i--)
	{
		data[i] = OneWire.read_bit();
		delay(1);
	}

	for (int i = 8;i < 56;i++)
	{
		aux_48[i-8]=data[i];
	}
	
	// convert from the array to integer
	for(int i=(48-1);i>=0;i--)
	{
		if(aux_48[i] == 1)
		{
			id += seed;
		}
		seed = seed * 2;
	}			
	
	if (id == ID_ERROR) 
	{
		id = 0;
	}
				
    digitalWrite(LED0,LOW);
    Utils.setLED(LED0,LED_OFF);
	Utils.setLED(LED1,LED_OFF);
	
	return id;
}
Exemplo n.º 7
0
/* readSerialChip() - reads the Waspmote unique serial identifier chip several 
 * times and compare if always is equal
 *  
 */
unsigned long WaspUtils::readSerialChip()
{	
	int data[64];
	int aux_48[48];
	unsigned long id = 0;
	int attempts = 2;
	unsigned long id_array[attempts];	
	unsigned long ID_ERROR = 0xFFFFFFFF;
	unsigned long seed = 1;
		
	for(int index = 0; index < attempts; index++)
	{
		// init seed
		seed = 1;
		
		WaspOneWire OneWire(LED1);
	
		Utils.setLED(LED0,LED_OFF);
		Utils.setLED(LED1,LED_OFF);
		
		// init variable
		id_array[index] = 0;	
		
		// Powering the serial ID chip
		pinMode(LED0, OUTPUT);
		digitalWrite(LED0,HIGH);
	
		// reset DS2411 chip
		OneWire.resetSerialID();	
		
		Utils.setLED(LED1,LED_ON);
		delay(10);
	  
		// ask the ID number
		OneWire.write(0x33,0);
		delay(50);
		
		// read the ID number
		for (int i = 63; i >= 0;i--)
		{
			data[i] = OneWire.read_bit();
			delay(1);
		}

		for (int i = 8;i < 56;i++)
		{
			aux_48[i-8]=data[i];
		}
		
		// convert from the array to integer
		for(int i=(48-1);i>=0;i--)
		{
			if(aux_48[i] == 1)
			{
				id_array[index] += seed;
			}
			seed = seed * 2;
		}			
		
		if (id_array[index] == ID_ERROR) 
		{
			id_array[index] = 0;
		}
		
		// Powering off the serial ID chip
		digitalWrite(LED0,LOW);
		Utils.setLED(LED0,LED_OFF);
		Utils.setLED(LED1,LED_OFF);
	}		
	
	for(int index = 0; index < attempts-1; index++)
	{
		if( id_array[index] != id_array[index+1] )
		{
			return 0;
		}
	}
	
	// give value
	id = id_array[0];
	
	return id;
}