Go Down

Topic: Bh1750 lux sensor question (Read 3 times) previous topic - next topic


The loop() function in your arduino is going to run many times a second.

If you try and take a photo whenever the light level is greater than 35000 lux,  your
camera won't be able to keep up.

You need to be clearer about your intention for when,  and how often,  you want
to take a photo.   


Its something that look like this :

when the laser point directly at the sensor, the reading value is=o (too many lux sensor overlimit?) what i can do is point it a little offset so the reading is something like 55000
I will need in order, when the laser beam is cut by a object to
-turn the laser off (laser is connected to a 5v pin in arduino)
-trigger the flash (set a digital pin to high, then low, flash is connected to a optoisolator)
-trigger the camera shutter (set a digital pin to high, the low, shutter is connected to a optoisolator)
-then wait couple of milliseconds
-then turn the laser on again
-wait couple of millisecond
then the whole process can loop again, until memory card is full......

that make sense?


Yeah, that makes sense.    Not sure how the light level comes into it, though.

You seem to have pretty much sorted out the logic flowchart for it,  now just implement that
in code.

You might need to experiement to find out how often you can trigger the camera.   Start with
a big delay.   As in,  if you just took a photo,   don't try taking another photo until at least a
second later.   Then try making that time smaller,  after you get it to work.

The simplest way to do this,  is to define a variable, external to the loop function.  Each time
you take a photo,   save the current millis()  time into that variable.    Each time you go
through the loop,    if your criteria for taking a photo are met,  check the current time,
and if it is isn't at least 1000 milliseconds since the last photo,   then don't take another one.


Hi here is the code i wrote :

Code: [Select]
#include <Wire.h> //BH1750 IIC Mode
#include <math.h>
int laserPin =31;
int shutterPin= 39;
int flashPin =49;
int BH1750address = 0x23; //setting i2c address
uint16_t val=0;

byte buff[2];
void setup()
  pinMode(laserPin, OUTPUT);
  pinMode(shutterPin, OUTPUT);
  pinMode(flashPin, OUTPUT);
  Serial.begin(57600);//init Serail band rate

void loop()
  digitalWrite(laserPin, HIGH); // start with laser on
  digitalWrite (shutterPin, LOW); // shutter trigger on a high
  digitalWrite(flashPin,LOW); // shutter trigger on a high
  int i;

    if (val>25000)
      digitalWrite (laserPin,LOW); // shut off laser
      digitalWrite (shutterPin, HIGH); // trigger shutter ( I triggered the shutter before the flash because it have a slower reaction time)
      digitalWrite(flashPin,HIGH); // trigger flash
      delay (100);
    Serial.println("taking picture!");     


int BH1750_Read(int address) //
  int i=0;
  Wire.requestFrom(address, 2);
  while(Wire.available()) //
    buff[i] = Wire.read();  // receive one byte
  return i;

void BH1750_Init(int address)
  Wire.write(0x10);//1lx reolution 120ms

I have to put a delay of 300ms between the trigger and the flash for synchonisation. The shutter take 300ms longer than the flash to trigger.
Thats a problem with high speed photography, if I want to take a photo of a lighting, I'll have to reduce that delay.
Any idea where it come from?

It may come from the camera hardware
It may come from the arduino code
It may come from the photoresistor (ilq74) wich is medium speed i think.....

I have no power to speed up camera hardware, but I can play with the arduino code and interfacing electronique to mayb gain couple of ms, you have an idea to speed things up?

Thank you.


Mayb instead of using photoisolator for shutter I can use a NPN transistor to short circuit the 2 wires for trigger, but is it safe ? will it be faster?

Go Up