Ambient 2 Click Board on Arduino101

Ambient 2 Click Board on Arduino101 © GPL3+

A short article about testing MikroElektronika Ambient 2 click board on the Arduino 101 microcontroller.

  • 861 views
  • 5 comments
  • 6 respects

Components and supplies

About this project

Introduction

This is a simple example of the Ambient 2 click board from MikroElektronika. The application is running on the Arduino 101 (Intel Curie).

Ambient 2 click board

Ambient 2 click carries TI’s OPT3001 Ambient Light sensor. It’s a small (2mm x 2mm) single-chip lux meter that measures only the visible part of the light spectrum from any kind of source (mimicking the way humans see light). It does so by filtering out 99% of infrared light. The measurement range of Ambient 2 click is from 0.01 lux to 83k lux, and a 23-bit resolution. Communication with the target MCU is done through mikroBUS I2C pins, with an additional INT pin which can be used for triggering wake-up events (offloading the MCU).

Code

Ambient2.inoArduino
#include <Wire.h>

#define OPT3001_ADDRESS 0x44


typedef union {
  uint16_t rawData;
  struct {
    uint16_t Result : 12;
    uint8_t Exponent : 4;
  };
} OPT3001_ER;

OPT3001_ER er;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("ClosedCube OPT3001 Arduino Test");
  Wire.begin();
  Wire.beginTransmission(OPT3001_ADDRESS);
  Wire.write(0x01); // Registar 01 je konfiguracioni
  Wire.endTransmission();
  Wire.beginTransmission(OPT3001_ADDRESS);
  Wire.write(0xC6);
  Wire.endTransmission();

}

void loop() {
  // put your main code here, to run repeatedly:
  Wire.beginTransmission(OPT3001_ADDRESS);
  Wire.write(0x00);
  Wire.endTransmission(); 
  readData(&er.rawData);
  int lux = 0.01*pow(2, er.Exponent)*er.Result;
  Serial.println(lux);
  delay(500);
}

void readData(uint16_t* data) {
    uint8_t buf[2];

  Wire.requestFrom(OPT3001_ADDRESS, 2);

  int counter = 0;
  while (Wire.available() < 2)
  {
    counter++;
    delay(10);
    if (counter > 250)
      return;
  }

  Wire.readBytes(buf, 2);
  *data = (buf[0] << 8) | buf[1];

  return;
}

Schematics

Stack Arduino/Shield/Sensor
Arduino ambient2 ljpvdp1uih

Comments

Similar projects you might like

Arduino101 Bluetooth Interfacing

Project tutorial by Tom Moxon

  • 2,074 views
  • 0 comments
  • 13 respects

Arduino101 Bluetooth Intertial Measurement Unit (IMU)

Project tutorial by Tom Moxon

  • 1,378 views
  • 0 comments
  • 5 respects

Arduino101 BLE Autonomous Rover

Project tutorial by 4 developers

  • 14,625 views
  • 2 comments
  • 32 respects

Arduino101 / tinyTILE BLE: Match-Making Sunglasses

Project tutorial by Kitty Yeung

  • 11,335 views
  • 2 comments
  • 35 respects

The Arduino101 way of Caregiving!

Project tutorial by Aitor Gamarra

  • 1,053 views
  • 1 comment
  • 4 respects
Add projectSign up / Login