Detect smartphone camera flash …

Dear community,

for my studies project I need to detect a photographing smartphone via its flash.

I tried it with a LDR, but that doesn’t really work well. I can detect a flash, but also other changes in the light are detected, like when a person walks by the LDR.

I could probably work around this by using two LDRs, but maybe there’s a simpler approach. Maybe something like a phototransistor, but I don’t know how they work.

In my opinion, I don’t really need to measure a difference in lighting during a time, but maybe the amount of photons which enter the sensor or something like that?

Thanks in advance for your advice!

In my opinion, I don't really need to measure a difference in lighting during a time,

You can add some kind of timing :smiley: Flash durations are very short (roughly between 1/1000s and 1/20000s). It's not very likely that moving objects can allow light on the LDR and 1/1000s later block it.

So my approach would be to wait till the light hits the LDR and store the time when that happens (micros()); next wait till the light is gone and compare the time (micros() again) when this happens with the time when the light did hit the sensor. If the difference is smaller that 1/1000s, it's a flash, else it's something else.

Basic code, not tested

void loop()
{
  static unsigned long starttime = 0;
  int LDRreading = analogRead(A0);
  if(LDRreading > threshold && starttime == 0)
  {
    starttime = micros();
  }
  if(LDRreading < threshold && starttime != 0)
  {
    unsigned long duration = micros() - starttime;
    starttime = 0;
    if(duration <= 1000)
      Serial.println("Flash detected");
  }
}

You might want to do a bit of calibration (measuring) on the duration of the flash as the numbers that I gave are not for cell phone cameras but for flashes that attach to dSLRs and the likes.

Note that micros() rolls over after about 70 minutes; see micros() reference. If that happens while the starttime was set, you can get a false negative.

Thank you, sterretje, that’s a nice solution. I will try it out!

I feel like there also could be a solution with interrupts—I mean, so the flash triggers the interrupt, via it’s rhythm or it’s light intensity or something like that. What do you think?

I tried it with a LDR, but that doesn't really work well.

You won't achieve your goals using an LDR. They are slow to respond. You need a phototransistor which is orders of magnitude faster.

Could I use this one? SFH 203 P: Silizium-PIN-Fotodiode, 400...1100nm, 150°, 5 mm bei reichelt elektronik

75 degree angle, 400–1100 nm wavelenght.

It has a working voltage of 50 V, so probably that’s a problem for the Arduino …

It has a working voltage of 50 V, so probably that's a problem for the Arduino …

According to the datasheet, that is the maximum voltage that can be passed through them. The specs show the characteristics at 5V.

Hey PaulS,

mh it seems I can’t quite figure the behaviour at 5 V out. I’m still very new to electronics. Could you please clarify, how it will work at 5 V?

The forward voltage seems to be 1.3 V. The open circuit voltage is 350 mV.

sterretje:
You can add some kind of timing :smiley: Flash durations are very short (roughly between 1/1000s and 1/20000s).

Cell phone "flash" are just white LEDs. The flash duration is never that short. The LEDs don't have enough intensity for that.

aarg:
Cell phone "flash" are just white LEDs. The flash duration is never that short. The LEDs don't have enough intensity for that.

I should actually have realized that. Time to do some measurements first before using the suggestef approach. Unfortunately I don't have a very smart phone.

So it’s generally more problematic to discover a smartphone flash than a real camera flash, because the light intensity is smaller and the flashing time/burning rate is greater?