4
\$\begingroup\$

I want to connect a light sensor to my PC ( serial or usb ) and read the values of that sensor.

Is there a way i can do this without a microcontoller?

I am looking into the cheapest method of acheiving this functionality.I must say i am a n00b in electronics so i would be grateful for any detailed explanation.

Thanks.

\$\endgroup\$
6
  • \$\begingroup\$ a microcontroller with a serial port that reads an analog signal representing the light level is doable. \$\endgroup\$
    – kenny
    Commented Feb 3, 2012 at 15:14
  • \$\begingroup\$ @kenny i am looking into the cheapest method. \$\endgroup\$
    – opc0de
    Commented Feb 3, 2012 at 15:18
  • 1
    \$\begingroup\$ a $1 PIC can do that \$\endgroup\$
    – kenny
    Commented Feb 3, 2012 at 15:21
  • 1
    \$\begingroup\$ The uC will be the less expensive and probably simplest solution...no, the simplest would be to buy a DAQ card and measure directly the resistance, but it's quite expensive (>200$) \$\endgroup\$
    – clabacchio
    Commented Feb 3, 2012 at 15:36
  • 1
    \$\begingroup\$ back when PCs had analog joystick ports, it would have been dirt simple. oh well. \$\endgroup\$
    – JustJeff
    Commented Feb 4, 2012 at 0:28

5 Answers 5

1
\$\begingroup\$

Cheap and simple is achieved with a "555" light to frequency converter.
Set to low frequency and drive a line on eg RS232 input or RS232 to USB converter

One possible 555 circuit

enter image description here

From here.
TLC555 here.
Increase C1 to lower frequency.

Or use 555 and eg LDR in place of R1 or R2 here.
From here not much other info.

enter image description here


Legion 555 / frequency / RS 232 / ...


TSL23x series light to frequency converter ICs

TSL235 datasheet here

Very low frequency at very low light. Cover with translucent "filter" eg paper) to reduce level to get eg 1 Hz.

Sparkfun TSL235R
Kevin Vermeer was here 2 years ago :-)
Another datasheet

You Tube TSL230 ...

TSL23x suppliers via FindChips

\$\endgroup\$
3
\$\begingroup\$

Easiest (but not cheapest!) way is probably to use a webcam and integrate the pixel values. I don't know how much error there is in this process, but I'm quite certain it could be made to work.

[edit: expanding on Oli Glaser's comment] I didn't notice before that serial was an option. The dirt-cheapest way would be to use a CdS photocell and a capacitor and measure the time constant using the serial control lines. This will cost about $1.50 for a DE9 connector, photocell and capacitor in single quantities.

The catch is that unless you're doing this in DOS, you will have to write a kernel driver to do the reading. Windows has enough going on that you are not going to get millisecond-level latency. An alternative is to use a very high value capacitor (say around 1000uF or so). My experiments with NT and XP show that 50 millisecond latency is not unreasonable. By using a 1,000uF capacitor, if we assume that the average resistance of the CdS cell in the range you are reading is about 25kohms (I wrote code to do just this on an AVR a month ago and I think the light in an "average" room translated to about 25k), then the time constant is 25 seconds. That should give you plenty of resolution even if reading the serial port has 100 millisecond imprecision.

Now you've piqued my interest :-) I'm going to have to try coding this up. Wonder if .NET is up to it?

\$\endgroup\$
1
  • \$\begingroup\$ Totally forgot about this. Based on this request, I went ahead and implemented this: cedarlakeinstruments.com/blog/archives/10 It uses Windows to measure the rise time of a CdS photocell - capacitor circuit. It is surprisingly repeatable. \$\endgroup\$
    – lyndon
    Commented Nov 9, 2013 at 20:01
3
\$\begingroup\$

You may want to try this:

http://www.yoctopuce.com/EN/products/usb-sensors/yocto-light

It's not the cheapest, but it's one of the easiest. USB, tiny, no driver required, quite a lot of OS and programming languages supported. And it features a data-logger...

\$\endgroup\$
1
\$\begingroup\$

If you want to read a range of values from your light sensor (as opposed to on/off) then you will need more than just the sensor itself.
As Kenny says, a $1 uC can achieve this quite easily. The code could be written in minutes.
Serial port (or USB/serial cable) would be easier than USB, though obviously not as "up to date". If it's not a commercial project then this may not be an issue.
Even with USB there are plenty of sample projects for PICs/Atmel/etc that could be adapted quickly.

If you just want an on/off (i.e. light/no light) sensor, then you could probably use one of the serial control lines (DSR or CTS maybe - see 9-pin serial pinout) to interface directly. You could use one of the output control lines (RTS, DTR) to power the sensor and a transistor with resistor/LDR divider to switch the input control line.

\$\endgroup\$
1
\$\begingroup\$

Consider also this: with a specific analog circuit, or anyway a discrete circuit, you are forced to a certain behavior, and you can customize it only to a certain point.

If you use a uC, there are several advantages:

  • Built-in UART (or even USB)
  • Nearly limitless configurability
  • Relatively high time to get it working
  • Possibility to add many features

And, if you use something like FTDI chips, the effort is almost none, just use one analog input (almost).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.