AmbiSense Extension Module

Type: Digital Sensor
Measures: Visible light, infrared light, humidity, temperature
Inventory: 8 units, 1 prototype
Pins: SDA, SCL, optional interrupt pins D8, D9, D10

The AmbiSense Extension allows you to measure light, temperature and humidity. It is equipped with two different sensors. The TSL2561 ambient light sensor (datasheet) and the HIH6130 temperature/humidity sensor (datasheet). Both are digital sensors and can be read via the I₂C bus (Pins SDA and SCL).

Light Sensor

The TSL2561 is a light-to-digital converters that transforms light intensity to a digital signal output capable of direct I2C. Each device combines one broadband photodiode (visible plus infrared) and one infrared-responding photodiode on a single CMOS integrated circuit capable of providing a near-photopic response over an effective 20-bit dynamic range (16-bit resolution). Two integrating ADCs convert the photodiode currents to a digital output that represents the irradiance measured on each channel. This digital output can be input to a microprocessor where illuminance (ambient light level) in lux is derived using an empirical formula to approximate the human eye response.
(TSL2561 Datasheet)

Hardware Details

The sensor communicates with the BRIX₂ Base Module via I²C using SDA and SCL. It has a programmable interrupt pin (see Datasheet) which can be connected to pin D8 of the BRIX₂ Base Module by populating R3 with a 0R 0402 resistor. The I²C address can be set to three different values using a solder jumper on the bottom of the board. By default, it is configured as floating (0x39). (Attention: The single prototype board is wired to 0x29!).

Firmware

Adafruit has everything you need to know. Please feel free to read everything over at the Adafruit page, it has more pictures. Just in case something gets lost, here's a local mirror of the informations on that site:

The TSL2561 luminosity sensor is an advanced digital light sensor, ideal for use in a wide range of light situations. Compared to low cost CdS cells, this sensor is more precise, allowing for exact Lux calculations and can be configured for different gain/timing ranges to detect light ranges from up to 0.1 - 40,000+ Lux on the fly. The best part of this sensor is that it contains both infrared and full spectrum diodes! That means you can seperately measure infrared, full-spectrum or human-visible light. Most sensors can only detect one or the other, which does not accurately represent what human eyes see (since we cannot perceive the IR light that is detected by most photo diodes).

The sensor has a digital (i2c) interface. You can select one of three addresses so you can have up to three sensors on one board - each with a different i2c address. The built in ADC means you can use this with any microcontroller, even if it doesn't have analog inputs. The current draw is extremely low, so its great for low power data-logging systems. about 0.5mA when actively sensing, and less than 15 uA when in powerdown mode.

Some Stats
Approximates Human eye Response
Precisely Measures Illuminance in Diverse Lighting Conditions
Temperature range: -30 to 80 *C
Dynamic range (Lux): 0.1 to 40,000 Lux
Voltage range: 2.7-3.6V
Interface: I2C

Adafruit also offers an Arduino library which we also recommend to use: https://github.com/adafruit/TSL2561-Arduino-Library/archive/master.zip

See also: How to install Arduino libraries

Example for Light Sensor

Please have a look at the example codes provided with the Adafruit library.

Temperature/Humidity Sensor

Honeywell HumidIcon™ Digital Humidity/Temperature Sensors: HIH-6130/6131 Series, is a digital output-type relative humidity (RH) and temperature sensor combined in the same package.
(HIH6130 Datasheet)

Hardware Details

The sensor communicates with the BRIX₂ Base Module via I²C using SDA and SCL. It has a programmable alarm feature which sets the alarm pins if a preprogrammed threshold is exceeded. There are two alarm pins which can be connected to pin D9 and D10 of the BRIX₂ Base Module by populating R1 and R2 with a 0R 0402 resistor. By default, the pins are disconnected.
The I²C address of the sensor is 0x27 and can be changed by entering the sensor's command mode. Please refer to the datasheet.

Firmware

Taken from http://www.phanderson.com/arduino/hih6130.html


// HIH_6130_1  - Arduino
// 
// Arduino                HIH-6130
// SCL (Analog 5) ------- SCL (term 3)
// SDA (Analog 4) ------- SDA (term 4)
//
// Note 2.2K pullups to 5 VDC on both SDA and SCL
//
// Pin4 ----------------- Vdd (term 8) 
//
// Illustrates how to measure relative humidity and temperature.
//
// copyright, Peter H Anderson, Baltimore, MD, Nov, '11
// You may use it, but please give credit.  

#include <Wire.h> //I2C library

byte fetch_humidity_temperature(unsigned int *p_Humidity, unsigned int *p_Temperature);
void print_float(float f, int num_digits);

#define TRUE 1
#define FALSE 0

void setup(void)
{
   Serial.begin(9600);
   Wire.begin();
   pinMode(4, OUTPUT);
   digitalWrite(4, HIGH); // this turns on the HIH3610
   delay(5000);
   Serial.println(">>>>>>>>>>>>>>>>>>>>>>>>");  // just to be sure things are working
}

void loop(void)
{
   byte _status;
   unsigned int H_dat, T_dat;
   float RH, T_C;

   while(1)
   {
      _status = fetch_humidity_temperature(&H_dat, &T_dat);

      switch(_status)
      {
          case 0:  Serial.println("Normal.");
                   break;
          case 1:  Serial.println("Stale Data.");
                   break;
          case 2:  Serial.println("In command mode.");
                   break;
          default: Serial.println("Diagnostic."); 
                   break; 
      }       

      RH = (float) H_dat * 6.10e-3;
      T_C = (float) T_dat * 1.007e-2 - 40.0;

      print_float(RH, 1);
      Serial.print("  ");
      print_float(T_C, 2);
      Serial.println();
      delay(1000);
   }
}

byte fetch_humidity_temperature(unsigned int *p_H_dat, unsigned int *p_T_dat)
{
      byte address, Hum_H, Hum_L, Temp_H, Temp_L, _status;
      unsigned int H_dat, T_dat;
      address = 0x27;;
      Wire.beginTransmission(address); 
      Wire.endTransmission();
      delay(100);

      Wire.requestFrom((int)address, (int) 4);
      Hum_H = Wire.read();
      Hum_L = Wire.read();
      Temp_H = Wire.read();
      Temp_L = Wire.read();
      Wire.endTransmission();

      _status = (Hum_H >> 6) & 0x03;
      Hum_H = Hum_H & 0x3f;
      H_dat = (((unsigned int)Hum_H) << 8) | Hum_L;
      T_dat = (((unsigned int)Temp_H) << 8) | Temp_L;
      T_dat = T_dat / 4;
      *p_H_dat = H_dat;
      *p_T_dat = T_dat;
      return(_status);
}

void print_float(float f, int num_digits)
{
    int f_int;
    int pows_of_ten[4] = {1, 10, 100, 1000};
    int multiplier, whole, fract, d, n;

    multiplier = pows_of_ten[num_digits];
    if (f < 0.0)
    {
        f = -f;
        Serial.print("-");
    }
    whole = (int) f;
    fract = (int) (multiplier * (f - (float)whole));

    Serial.print(whole);
    Serial.print(".");

    for (n=num_digits-1; n>=0; n--) // print each digit with no leading zero suppression
    {
         d = fract / pows_of_ten[n];
         Serial.print(d);
         fract = fract % pows_of_ten[n];
    }
} 

Developer Informations

This extension features a Honeywell HIH6130 temperature/humidity sensor and a TSL2561 ambient light sensor. Both are connected via I²C and feature optional interrupt pins.

Possible improvement: http://www.conrad.de/ce/de/product/180381/RGB-Farblichtsensor-KPS-5130PD7C-Kingbright-KPS-5130PD7C-Gehaeuseart-SMD-/?ref=detview1&rt=detview1&rb=1

Status: Tested, Working

ext_ambisense.jpg (328.265 KB) Sebastian Zehe, 2014-06-09 15:47