Ejemplo n.º 1
0
float HTU21D::readFourthTemperature(void)
{
	SoftI2CMaster i2c4 = SoftI2CMaster( sdaPin4, sclPin4 );
	byte tLow, tHigh, checkSum;
	
	//Request the temperature
	i2c4.beginTransmission(HTU21D_ADDR);
	i2c4.send(TRIGGER_TEMP_MEASURE_NOHOLD);

	//Hang out while measurement is taken. 50ms max, page 4 of datasheet.
	delay(55);

	//Comes back in three bytes, data(MSB) / data(LSB) / Checksum
	i2c4.requestFrom(HTU21D_ADDR);

	//Receive msb, lsb and checksum
	tHigh=i2c4.receive(false);
	tLow=i2c4.receive(false);
	checkSum=i2c4.receive(true);
	i2c4.endTransmission();
  
	unsigned int rawTemp = ((unsigned int) tHigh <<8) | (unsigned int) tLow;
	rawTemp &= 0xFFFC;
	
	//Given the raw tempuerature data, calculate the actual relative tempuerature
	float temp = rawTemp/(float)65536;
	float realTemp = -46.85 + (175.72 * temp);
  
	return realTemp;
}
Ejemplo n.º 2
0
TCS34725::TCS34725(tcs34725IntegrationTime_t it, tcs34725Gain_t gain, uint8_t sdaPin, uint8_t sclPin)
{
  _tcs34725Initialised = false;
  _tcs34725IntegrationTime = it;
  _tcs34725Gain = gain;
  _sdaPin = sdaPin;
  _sclPin = sclPin;
  _i2c = SoftI2CMaster(sdaPin, sclPin);
}
Ejemplo n.º 3
0
float HTU21D::readSecondHumidity(void)
{
	SoftI2CMaster i2c2 = SoftI2CMaster( sdaPin2, sclPin2 );
	byte hLow, hHigh, checkSum;

	//Request a humidity reading
	i2c2.beginTransmission(HTU21D_ADDR);
	i2c2.send(TRIGGER_HUMD_MEASURE_NOHOLD);	////Measure humidity with no bus holding

	//Hang out while measurement is taken. Delay 50ms min, page 4 of datasheet.
	delay(55);

	//Comes back in three bytes, data(MSB) / data(LSB) / Checksum
	i2c2.requestFrom(HTU21D_ADDR);

	//Receive msb, lsb and checksum
	hHigh=i2c2.receive(false);
	hLow=i2c2.receive(false);
	checkSum=i2c2.receive(true);
	i2c2.endTransmission();
  
	unsigned int rawHumidity = ((unsigned int) hHigh << 8) | (unsigned int) hLow;
	rawHumidity &= 0xFFFC; //Zero out the status bits but keep them in place
  
	//Given the raw humidity data, calculate the actual relative humidity
	float tempRH = rawHumidity / (float)65536; //2^16 = 65536
	float rh = -6 + (125 * tempRH); //From page 14

	if(rh>100)
		rh=100;

	if(rh<0)
		rh=0;
  
	return rh;
}
Ejemplo n.º 4
0
*/

#include <inttypes.h>
#include <Wire.h>
#include "Arduino.h"
#include "SHT2x.h"  

// #define SOFTI2C

#ifdef SOFTI2C
  #include "SoftI2CMaster.h" //matt
  #define I2C i2c //Matt (Choose between "Wire" and "SoftI2C" )

  const byte sdaPin = 4;
  const byte sclPin = 5;
  SoftI2CMaster i2c = SoftI2CMaster( sdaPin,sclPin );

#else
  #define I2C Wire
#endif

/******************************************************************************
 * Global Functions
 ******************************************************************************/

/**********************************************************
 * GetHumidity
 *  Gets the current humidity from the sensor.
 *
 * @return float - The relative humidity in %RH
 **********************************************************/
  please support Adafruit andopen-source hardware by purchasing products
  from Adafruit!

  Written by Kevin Townsend for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ***************************************************************************/
#if ARDUINO >= 100
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

#include <SoftI2CMaster.h>
#include <limits.h>
#include <math.h>
SoftI2CMaster i2c = SoftI2CMaster();
#include "Adafruit_10DOF_SOFT.h"

#define PI  (3.14159265F);

/***************************************************************************
 PRIVATE FUNCTIONS
 ***************************************************************************/


/***************************************************************************
 CONSTRUCTOR
 ***************************************************************************/
 
/**************************************************************************/
/*!