Posts with «light sensor» label

BH1750 Sensor: Measuring Lux with Arduino and the GY-302

The BH1750 sensor converts light intensity into a digital value and makes it available on the I2C bus. Its measurement range goes from 1 to 65,535 lux. On the GY-302 breakout the sensor comes ready to use with Arduino, ESP32 and other boards. AdriRobot tried it with an Arduino UNO and writes about it on his blog.

What the BH1750 sensor measures

The lux is the unit of measurement for illuminance: it corresponds to one lumen per square metre. It therefore describes the light falling on a surface, evaluated as the human eye perceives it. For reference, light reflected by a full Moon is about 1 lx, a bright office is about 400 lx, and sunlight ranges between 32,000 and 100,000 lx.

Measurement modes and resolution

The BH1750 works in six modes, divided into two groups: continuous measurement and single measurement. In continuous mode the sensor detects light without stopping. In single mode it takes one measurement and then shuts down, so it must be reconfigured before the next reading. The library used in the article does this automatically.

Each mode offers three levels of precision:

  • low resolution: 4 lx precision and 16 ms measurement time;
  • high resolution: 1 lx and 120 ms;
  • high resolution 2: 0.5 lx and 120 ms.

By default the library selects continuous high resolution. In low and high resolution modes the maximum value is 54,612.5 lx, while in high resolution 2 it stops at 27,306.25 lx. In practice the sensor returns a 16-bit integer, which the library converts into lux by dividing it by 1.2. A result of -1 means no valid data arrived, while -2 signals an unconfigured device.

You can also change the time interval in which the sensor counts light, through the MTreg register. The value ranges from 32 to 254 and the default is 69.

The GY-302 module: power, pinout and address

The GY-302 breakout with the BH1750 sensor and the pins to be soldered (photo: AdriRobot)

On the GY-302 the sensor is joined by a 3.3 V LDO regulator, marked 662K, and its capacitors. The module therefore accepts Arduino’s 5 V on the VCC pin. The regulator supplies up to 250 mA and withstands a maximum of 6.5 V at its input. On the SCL and SDA lines there are also two 4.7 kΩ pull-up resistors. The breakout is sold as a light intensity sensor.

The connector has five pins: VCC, GND, SCL, SDA and ADDR. The last one is used to choose the I2C address and comes into play when several BH1750 sensors share the same bus. With ADDR at a low level the address is 0x23, with ADDR high it becomes 0x5C. On the module tested the pin is tied to ground through a 4.7 kΩ resistor, so the sensor responds at 0x23.

  • measurement range: from 1 to 65,535 lux;
  • supply voltage: from 3 to 5 V;
  • operating temperature: from -40 to +85 °C;
  • dimensions: 18.5 × 13.9 × 2.5 mm, connectors excluded.

Connecting it to an Arduino UNO and an OLED display

Basic connection between Arduino UNO and GY-302 (diagram: AdriRobot)

For the first test you only need an Arduino UNO board, the GY-302 module and a few male-to-female jumper wires. VCC and GND go to the power supply, while SDA and SCL connect to Arduino’s I2C pins. Before uploading the sketch it is worth running the IDE’s i2c_scanner example: if the wiring is correct, the serial monitor reports a device at address 0x23.

The reading uses Christopher Laws’ BH1750 library, which is installed from the Library Manager together with the Wire library, already included in the IDE. The sketch reads the value every second and also writes it to the serial monitor.

The project is then completed with a 0.96-inch OLED display, 128×64 pixels, SSD1306 driver and I2C interface. The display responds at address 0x3C, so it shares the same bus as the sensor. The Adafruit SSD1306 and Adafruit GFX libraries are needed, and the lux meter shows the lux directly on the screen.

The lux meter with GY-302 and OLED display during the measurement (photo: AdriRobot)

Anyone who wants to see the BH1750 at work in a larger project can read the ESP32 weather station with a live web dashboard, which pairs it with a DHT22 and a BMP280.

Source: the original AdriRobot article also contains the complete schematic, the sketches and the test video.

Related products

The post BH1750 Sensor: Measuring Lux with Arduino and the GY-302 appeared first on Open Electronics.

Fire Fighting Robot

Primary image

What does it do?

Navigate a Maze, extinguish a flame, track position

I'm currently a sophomore at Worcester Polytechnic Institute studying Robotics Engineering. The third course in the series, RBE 2002, focusing on sensors. In a group of 4 students, we built a robot that could autonomously navigate a maze, locate a flame, put it out and report its X,Y, and Z position relative to its starting position. The robot was required to use an IMU and a flame sensor provided to us. All other sensors and parts are up to the group to use to complete the challenge.

Cost to build

Embedded video

Finished project

Complete

Number

Time to build

Type

URL to more information

Weight

read more

Fire Fighting Robot

Primary image

What does it do?

Navigate a Maze, extinguish a flame, track position

I'm currently a sophomore at Worcester Polytechnic Institute studying Robotics Engineering. The third course in the series, RBE 2002, focusing on sensors. In a group of 4 students, we built a robot that could autonomously navigate a maze, locate a flame, put it out and report its X,Y, and Z position relative to its starting position. The robot was required to use an IMU and a flame sensor provided to us. All other sensors and parts are up to the group to use to complete the challenge.

Cost to build

Embedded video

Finished project

Complete

Number

Time to build

Type

URL to more information

Weight

read more

DIY I2C Devices with ATtiny85

[Pawel] has a weather station, and its nerve-center is a Raspberry Pi. He wanted to include a light sensor but the problem is, the Pi doesn’t have a built-in ADC to read the voltage off the light-dependent resistor that he (presumably) had in his junk box. You can, of course, buy I2C ADC chips and modules, but when you’ve already got a microcontroller that has ADC peripherals on board, why bother?

[Pawel] wired up a tremendously simple circuit, downloaded some I2C slave-mode code, and added an LED for good measure. It’s all up on GitHub if you’re interested.

Bright by Day, Dark by Night!

We’re covering this because we rarely see people coding for I2C slave devices. Everyone and their mom uses I2C to connect to sensors, for which the Arduino “Wire” library or “i2c-tools” on the Pi do just fine. But what do you do when you want to make the I2C device? [Pawel]’s project makes use of TinyWireS, a slave-mode SPI and I2C library for AVR ATtiny Arduino projects.

Here, [Pawel] just wanted a light sensor. But if you’re building your own devices, the sky is the limit. What’s the most esoteric I2C sensor that you can imagine? (And is it really the case that we haven’t seen an I2C slave device hack since 2010?)


Filed under: ATtiny Hacks
Hack a Day 07 Nov 09:00

The Newest Graphing Calculator Game

Certainly everyone remembers passing time in a boring high school class playing games on a graphing calculator. Whether it was a Mario-esque game, Tetris, or BlockDude, there are plenty of games out there for pretty much all of the graphing calculators that exist. [Christopher], [Tim], and their colleagues from Cemetech took their calculator game a little bit farther than we did, and built something that’ll almost surely disrupt whatever class you’re attempting to pay attention in: They built a graphing calculator whac-a-mole game.

This game isn’t the standard whac-a-mole game, though, and it isn’t played on the calculator’s screen. Instead of phyiscal “moles” the game uses LEDs and light sensors enclosed in a box to emulate the function of the moles. In order to whack a mole, the player only needs to interrupt the light beam which can be done with any physical object. The team made extensive use of the ArTICL library which allows graphing calculators to interface with microcontrollers like the MSP432 that they used, and drove the whole thing with a classic TI-84.

This project is a fun way to show what can be done with a graphing calculator and embedded electronics, and it was a big hit at this past year’s World Maker Faire. Calculators are versatile in other ways as well. We’ve seen them built with open hardware and free software, And we’ve even seen them get their own Wi-Fi.


Filed under: handhelds hacks

Trying to use a light sensor to control a stepper motor

Am trying to control a stepper motor with a light sensor, when high do this and when low do that. But it dn't seem to be working please help.

read more

Liquidware team crafts laser tripwire that tweets intruder alerts, keeps fake sharks at bay (video)

Laser tripwire security systems can be expensive propositions that don't always work as planned -- just ask Raytheon, which saw its $100 million Perimeter Intrusion Detection System for JFK International Airport undermined by one wayward jet skier. Taking that as a form of dare, Justin Huynh and teammates at Liquidware have devised a much cheaper (if also much smaller) tripwire of their own. Any interruption of a laser pointer's beam is caught by an Arduino light sensor that promptly sends the alert to an Android-running BeagleBoard xM; if a toy like Bruce the shark dares cross the line, the BeagleBoard sends a Twitter message to let the authorities, or at least Huynh, clamp down on the trespasser. The invention won't replace Raytheon's handiwork anytime soon, although Huynh notes that additional or more powerful sensors could theoretically catch real, muscle-bound sharks and not just their plastic counterparts. The supply checklist and source code are waiting on the company's project page below, so those who'd like to ward off miniature invasions can get started today.

Continue reading Liquidware team crafts laser tripwire that tweets intruder alerts, keeps fake sharks at bay (video)

Filed under: Misc. Gadgets

Liquidware team crafts laser tripwire that tweets intruder alerts, keeps fake sharks at bay (video) originally appeared on Engadget on Mon, 20 Aug 2012 19:17:00 EST. Please see our terms for use of feeds.

Permalink | Email this | Comments

Led as light sensor [Arduino]

If you connect led in the opposit way he can act as light sensor:

positive leg to analog pin

negative leg to 5V

You can use that for some things, but he not sensetive as LDR,

ןf you use a for example a green led he not "see" well red light

If you use charlieplexing method you can control one led to light and as a light sensor.

The idea is like this:

Two wires connect the led to two analog pins.

To light the led you set the two analog pins as digital output and one high one low. 

read more