Skip to content

Latest commit

 

History

History
127 lines (96 loc) · 2.75 KB

217_brick_i2c_ambientlight.md

File metadata and controls

127 lines (96 loc) · 2.75 KB

#217 Ambient Light I2C Brick

![](/img/200_i2c/product/217.jpg)

Overview

照度センサーを使ったBrickです。

I2Cで明るさを取得することができます。

Connecting

I2Cコネクタへ接続します。

Support

Arduino RaspberryPI IchigoJam

ISL29034 Datasheet

Document
ISL29034 Datasheet

Register

Slave Address
0x44

Schematic

Library

for Arduino

for RapberryPI

  • pipからインストール
pip install FaBoAmbientLight_ISL29034

Sample Code

for Arduino

上記のArduino Libraryをインストールし、スケッチの例、「FaBo 217 Ambient Light ISL29034」からお選びください。

for RapberryPI

上記のRapberryPI Python Libraryをインストールしてからご使用ください。

# coding: utf-8
## @package FaBoRTC_PCF2129
#  This is a library for the FaBo Ambient Light I2C Brick.
#
#  http://fabo.io/217.html
#
#  Released under APACHE LICENSE, VERSION 2.0
#
#  http://www.apache.org/licenses/
#
#  FaBo <[email protected]>

import FaBoAmbientLight_ISL29034
import time
import sys

light = FaBoAmbientLight_ISL29034.ISL29034()

try:
    while True:

        lux  = light.read()

        print "Lux = ", lux
        time.sleep(0.5)

except KeyboardInterrupt:
    sys.exit()

for Ichigojam

I2Cコネクタに接続したAmbient Light I2C Brickより明るさを取得し、画面上に表示します。

10 'FaBo Brick Sample
20 '#217 Ambient Light I2C Brick
30 CLS

100 'slave address
110 D=#44

200 'address set
230 POKE #800,#00,#A0,#01,1,#02

300 'init
310 A=I2CW(D,#800,1,#801,1)
320 A=I2CR(D,#802,1,#810,1)
330 ' Range #02:1600 ,Resolution #04:12bit
340 POKE #811,(PEEK(#810)&#F0)|#02|#04
350 A=I2CW(D,#802,1,#811,1)

400 'read
430 A=I2CR(D,#804,1,#820,2)
440 L=PEEK(#821)<<8+PEEK(#820)

500 'output
501 LOCATE 0,3
' range:(1600) / 12bit count :(4095) = 0.39072...
520 ?"Lux:";L/100*39+L%100*39/100;"  "

600 'loop
610 WAIT 5
620 GOTO 430

Parts

  • Intersil ISL29034

GitHub