Go Down

Topic: TSL2591 light sensor using hardware interrupt (Read 2517 times) previous topic - next topic

wvmarle

Which exact phototransistor? Let's start with that. It may not be suitable for your particular application.

You want to measure extremely low levels of light, which may last very short to boot. Not an easy thing to do.

First of all you have to define in absolute terms what the actual level is you want to detect. No doubt there are detectors out there that can count single photons, that'd be "the faintest amount of light", taken to the extreme. Not going to be cheap, such a sensor.

Common detectors include indeed photodiodes and phototransistors. At least the photodiode can work in two ways: photovoltaic and photoconductive. A phototransistor only has the second option. Wikipedia says that both perform about the same for low light situations, with the photodiode the faster of the two.

In any case noise is probably going to be the main issue you have to deal with. The circuit as given in the link of #13 mentions 500 µV/lux as output, that's no doubt a far too low voltage for your application. You want to go well below 1 lux, I suppose you will want to get an output of 5V at 1 lux, or at even lower light levels.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

jremington

#16
May 20, 2020, 04:47 pm Last Edit: May 20, 2020, 04:49 pm by jremington
If you want to get serious about this project, you will have to define "even a faint amount of light" in quantitative terms.

I think this will be difficult for you, as detection of very low light levels requires considerable electronics expertise, carefully selected components and circuit design, and special PCB construction techniques. Absolutely NO MOISTURE can be allowed to get into a high impedance circuit.

It should be obvious that there is no point in building and placing a detector that cannot detect the light levels of interest.

wvmarle

Quote
Absolutely NO MOISTURE can be allowed to get into a high impedance circuit.
Major challenge in a cave (100% humidity at all times) and a circuit that's in sleep mode most of the time (no self-heating whatsoever). This probably requires potting.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

bgee11

Replying to several people at once here ...

The exact phototransistor I bought is a TEPT4400.  The link on eBay is https://www.ebay.com/itm/5PCS-TEPT4400-AMBIENT-LIGHT-SENSOR-3MM-570NM-LOT-OF-5-UK-COMPANY-SINCE1983/202841326238  I tried it in several dark situations to see how it works.  It seems quite sensitive.  Hooked in series with a one megohm resistor and using a 3.6 volt supply (3xAAA NiMH in series), I put it inside a 6 quart cooler.  It registered a voltage drop of about 80 mv.  When I put a heavy jacket over the cooler, the voltage drop was less than 1mv which is the limit of my voltmeter.  Raising a corner of the jacket and shining a flashlight on the outside of the cooler caused a drop of about 17mv.  Based on that, the pull-up resistor should probably be in the range of 3 to 5 megohms.  I have ordered a resistor assortment which includes those values.

Quantifying the light level to be measured ... We don't have an exact number.  In general terms - As low as possible, but greater than zero.

Yes, the cave environment will make things difficult in some ways.  At least the temperature is stable!  The relative humidity is 100%, but it is almost never condensing because there is no temperature variation.  Our idea is to put the entire device - Arduino, battery, sensors - inside a clear plastic jar.  An empty peanut butter jar or mayo jar would work.  A Nalgene bottle would be even better, but they are not as transparent.

At this point the whole thing is an idea.  It is something to test.  We don't know if it can be made to work.  Photo transistor vs. TSL2591 is part of the testing and development effort.  The use of interrupts seems to be about the only way to get enough battery life to make it practical.

One of my inspirations is a project to build water depth data loggers for use in caves.  The project is documented at https://thecavepearlproject.org/  He pots the pressure sensor, but the rest of the circuit is in a fairly ordinary plastic container.

There are many challenges to my project.  The most immediate challenge has nothing to do with the sensors!  My main workstation will no longer open the serial monitor.  I posted a question about that in another part of this forum.  It is all for naught if I cannot get the sketch onto the Arduino.

Bill Gee

wvmarle

With resistors over about 1 MΩ you have to seriously start to worry about noise.

You're in the mV range, no chance there to get an interrupt, either. You have to poll the analog input - where a single unit in the reading represents about 1 mV when using the 1V internal reference. Probably not good enough for you.

You will have to boost this tiny voltage. I'd be looking at making your phototransistor part of a Wheatstone bridge, and amplify the signal with e.g. a HX711 instrumentation amplifier - those things are typically used for load cells, which are also measured using a Wheatstone bridge. To get your interrupt the output of the HX711 could then be further amplified with an OpAmp and/or be fed to a comparator which in turn can produce the voltage for the interrupt. A separate connection to the analog input would allow you to measure the actual light level upon interrupt; assuming the signal lasts long enough (a very short flash may have extinguished by the time the Arduino has woken and taken an analog reading).
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

gerrikoio

For this application, maybe you should look at alternative microcontrollers that allow you to work off 1.8V or even lower (for the transistor case). For a start you should at least use a 3.3V Arduino @ 8MHz as 5V @16MHz brings no benefit for low power operation.

As a suggestion, I used one of these 8051 MCU's the other day from Silicon labs and rather liked it. Pretty versatile and the IDE is not that intimidating so fairly quick to get going.

https://www.silabs.com/mcu/8-bit/efm8-sleepy-bee

wvmarle

Save a few exceptions the Atmel controllers, including the ATmega328P as used in the Pro Mini, can operate at 1.8V.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

gerrikoio

Not disagreeing (can operate at 1.8V). I was merely going by the ATmega328P datasheet which tells me Operating voltage is 2.7V to 5.5V

jremington

#23
May 22, 2020, 06:23 pm Last Edit: May 22, 2020, 06:26 pm by jremington
Quote
the ATmega328P datasheet which tells me Operating voltage is 2.7V to 5.5V
Where are you looking?

The cover page of the ATmega328P data sheet, titled "Features", looks like this:


gerrikoio

As said, I was not in disagreement. I had simply clicked on the first link that came up on my search list. For some reason this datasheet differs... see page 2

http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf

wvmarle

Automotive... that's the difference. Will also be rated for a larger temperature range.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

gerrikoio

Quote
Automotive... that's the difference.
Good to know. Thanks.

Anyhow, the point I was trying to get across, was to work off as low a voltage as is practicable and the suggestion was to use an operating voltage of 1.8V (or thereabouts). This way I'm assuming that you should be able use those phototransistors with a sub 1M ohm resistor (less noise) to trigger an interrupt on the Arudino @ 1.8V.

wvmarle

1.8V is not really practical, no common batteries produce that voltage. Also you have to make sure you stay above that voltage for guaranteed operation.

3V is probably more practical: 2x alkaline batteries. D cells have a capacity of up to 18,000 mAh. That's nominal, when the batteries are fresh you're at about 3.2V but the project will work until they're seriously depleted and voltage drops to 2V or so.

To run for two years, say you can safely use 10,000 mAh in that period. That should give enough margin for error. That gives you an average current budget of 0.5 mA.

Nonetheless to get an interrupt working you will need more components than just a single resistor with that phototransistor.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

bgee11

Thanks you everyone for comments and suggestions.  We got a bit off-topic here ...  My original question was asking for sample code that uses the hardware interrupt of the TSL2591 to wake an Arduino from deep sleep.  Photo transistors are a digression from that.

I considered running the ProMini at less than the rated 3.3 volts, but never tried it.  Two concerns:  First, is that enough voltage to run the other boards - SD card, RTC and TSL2591?  And second, as someone else pointed out, getting that voltage from any kind of unregulated battery is a problem.

Electromagnetic interference in a cave should be a small problem.  Radios do not work in a cave except for line-of-sight.  Signals from radio towers - even close and powerful - do not reach into a cave.  The most likely source of electromagnetic interference would be from cosmic rays.  Static electricity should also not be a problem since the relative humidity level is 100%. 

I still need to get my computer working with the IDE serial monitor and program download.  All else is rather useless if I cannot get code onto the Arduino.

Bill Gee

jremington

#29
May 24, 2020, 10:14 pm Last Edit: May 24, 2020, 10:25 pm by jremington
Quote
The most likely source of electromagnetic interference would be from cosmic rays.
Cosmic rays are particles. At the Earth's surface they are mostly muons, and about 1 per minute per square cm arrives. Few penetrate far into the Earth. So no worries there!

Once you get your computer and Arduino working, let us know if the TSL2591 can generate an interrupt while in power down mode.

Go Up