element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Safe and Sound
  • Challenges & Projects
  • Design Challenges
  • Safe and Sound
  • More
  • Cancel
Safe and Sound
Blog Safe&Sound: Wearable Tracking Device for Miners - 09: Interfacing OPT3001 Light sensor
  • Blog
  • Forum
  • Documents
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: sunnyiut
  • Date Created: 6 Jul 2017 7:43 AM Date Created
  • Views 172 views
  • Likes 2 likes
  • Comments 2 comments
  • msp432_launchpad
  • boostxl-sensors
  • safe and sound design challenge
  • msp432p401r
  • tft
  • opt3001
  • mikroplot
Related
Recommended

Safe&Sound: Wearable Tracking Device for Miners - 09: Interfacing OPT3001 Light sensor

sunnyiut
sunnyiut
6 Jul 2017

Title: Wearable Tracking Device for Miners

By: sunnyiut                         

Previous Blogs
01: Introduction02: The Kit
03: Review_MSP432P401R04: Review_430BOOST-SHARP96
05: Review_BOOSTXL-SENSORS06: Review_DLP7970ABP
07: Project proposal update08: TFT interfacing

 

Design Challenge: Safe and Sound Wearables

Blog number: 09

 

 

Intro:

This blog is based on MSP432P401r and OPT3001 Light sensor interface.

 

 

Objective:

 

The OPT3001 Light Sensor will provide the ambient light intensity measurement.

 

According to my project proposal I have to design a wearable device mounted on the wrist of the Miners.

This wearable device consists of several sensors to collect environmental information.

 

In this blog post, I'll focus on

     - the interfacing of the OPT3001 and the MSP432P401r MCU

     - display the ambient light intensity on TFT

     - send data to PC UART for graphical representation

 

Components:

  • Sensors Boosterpack
  • MSP432 Launchpad
  • TFT Proto
  • mikroplot [UART PC GUI]

 

Compiler:

MikroC pro for ARM - from MikroElektronika

 

Firmware:

Full source code and circuit diagram can be found in LIBSTOCK.

dependencies -

    • OPT3001.c [ambient 2 click]
    • mikroplot UART.c [mplot]

libraries -

    • TFT
    • TFT def

 

OPT3001 [BOOSTXL-SENSORS]:

 

TI’s OPT3001 is an ambient light sensor. It’s a single-chip lux meter with infrared rejection. That measures only the visible

part of the light spectrum (mimicking the human eye’s response to light).

The sensor comes with BOSXL-SENSORS [sensors boosterpack] and  communicates with the MSP432 Launchpad using I2C.

     - operates at 3.3v

     - can produce hardware interrupt

 

OPT3001 I2C address = 0x47 (ADD pin is connected to SCL) [default in booasterpack]

OPT3001 I2C address = 0x44 (ADD pin is connected to GROUND)

 

 

Interfacing:

 

#define OPT3001_I2C_ADDR   0x47
// ADD pin is connected to SCL)


char tmp_data[3];

/*******************************************************************************
 configuring OPT3001 Ambient Light sensor
*******************************************************************************/
void OPT3001_Configuration(){
  tmp_data[0] = 0x01;                                                       
// Configuration register
  tmp_data[1] = 0xC6;                                                       
// Set Mode of conversion operation field as
  tmp_data[2] = 0x10;                                                       
// 11 - Continuous conversions


  I2C1_Write(OPT3001_I2C_ADDR,tmp_data,3,END_MODE_STOP);                    
// Send 3 bytes (tmp_data)

}

/*******************************************************************************
 reading ambient light data from OPT3001 sensor
*******************************************************************************/
float Get_OPT3001_Data() {
  unsigned int DataSum;
  float Ambient_Data;

  tmp_data[0] = 0x00;                                                       
// Ambient Light Result register address


  I2C1_Write(OPT3001_I2C_ADDR,tmp_data,1,END_MODE_RESTART);                 
// Send byte (tmp_data[0])
  I2C1_Read(OPT3001_I2C_ADDR,tmp_data,2,END_MODE_STOP);                     
// Read light data and store it in tmp_data


  DataSum = ((tmp_data[0] << 8) | tmp_data[1]);                             
// Justify Ambient values
  tmp_data[0] = tmp_data[0] >> 4;                                           
// Justify exponent data
  DataSum = DataSum << 4;                                                   
// Justify fractional results

  DataSum = DataSum >> 4;
  
  Ambient_Data = 0.01 * (2 << tmp_data[0]) * DataSum;                       
// Lux equation

  
  if (Ambient_Data >= 5000.0)                                               
// The most useful ALS range is in the 1 to 1,000 lux range

Ambient_data = 5000.0;


  //Ambient_Data  /= 10;                                                    
// Lux to percents conversion

  
  return Ambient_Data;                                                      
// Return ambient data

}

 

Circuit Diagram:

 

          MSP432P401r with OPT3001                                             TFT display connection

 

OUTPUT :

 

 

When tested in my room it gives a reading of about 163 LUX.

     Initialization screen               indoor ambient light intensity

 

I have used "mikroplot" to graphically present the data over a time period. The MSP432 Launchpad communicates with the PC GUI through UART @ 57600 BAUD.

graph maintains ~163 LUX at indoor room light                            reading falls down to ~40 LUX with a transparent plastic placed on the sensor

 

I have checked the response of the sensor with a smart phone flash light placed beside [horizontally] it. Reading goes up to ~2000 LUX.

 

variation of reading while moving the light source front and back -

That's the end of this blogpost. In my next blog, I'll interface the BME280 sensor and display the output data on TFT.

Anonymous

Top Comments

  • DAB
    DAB over 5 years ago +1

    Nice update.

     

    I am curious about what value you think having the light sensor on board will provide?

     

    Granted, knowing the lighting conditions of the working environment could be useful, especially if the…

  • sunnyiut
    sunnyiut over 5 years ago in reply to DAB +1

    also, the brightness of the display can be changed automatically ... though i've not included it in the firmware.

  • sunnyiut
    sunnyiut over 5 years ago in reply to DAB

    also, the brightness of the display can be changed automatically ... though i've not included it in the firmware.

    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
  • DAB
    DAB over 5 years ago

    Nice update.

     

    I am curious about what value you think having the light sensor on board will provide?

     

    Granted, knowing the lighting conditions of the working environment could be useful, especially if the miners use visual cues for decision making.

     

    DAB

    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube