Sensors won't deliver data

Hi everyone. So my problem today is involving some connecting with sensors. I've done numerous tests with temp and mainly light sensors. I'm currently using a light sensor at the moment, and keep running into the same issue. For some reason, when sensors are connected to the arduino, and a basic read and display data program is given to the arduino, the sensor doesn't respond. The program seems to run fine, and everything does what its supposed to do, however, when a simple test is done on the light sensor, or any other sensor, nothing changes in serial. It's as if the sensor is broken, but this isn't the case, as the sensors have been checked numerous times. Here's a very simplified version of the code i'm currently using for the light sensor:

int lightSensor = 0;

void setup() { Serial.begin(9600); }

void loop() { Serial.println(analogRead(lightSensor)); delay(1000); } At this point, I'm convinced that something isn't being added into the program, but I digress. Any help on this issue would be greatly appreciated. Thanks in advance!

int lightSensor = 0;

I could be mistaken but I believe pin 0 is used for serial communications. Try using a different pin.

Hmm...sorry, Coding, but that doesn't seem to change anything...the serial communication isn't changing values at all despite what I try to change in terms of hardware..i've got the circuit all plugged directly into an arduino, and it's reading voltage values from 0-5 and reading 0-1023, as normal. However, despite how I try to change the light sensor, it stays at 1023 constantly..it's like the sensor/resistor isn't really even there...is there perhaps something up with programming?

Did you move the sensor to a different pin? Pins 0 and 1 are for Serial communication, and won’t work when you have Serial enabled…

[edit]Just noticed you’re doing an Analog Read not digitalRead. My bad :P[/edit]

and it's reading voltage values from 0-5 and reading 0-1023, as normal. However, despite how I try to change the light sensor, it stays at 1023 constantly..it's like the sensor/resistor isn't really even there...is there perhaps something up with programming?

Most likely a wiring or component value problem. Easiest thing is to measure the analoginput pin's voltage with a meter and tell us it's reading. If it's +5vdc or higher then you will get a saturated reading of 1023. Do you have a drawing of the circuit?

Lefty

Hmm..thanks, Retro..I checked the voltage and it's reading a normal ~5+ Volts...as for pics, I've taken a couple of the circuit, but am now unable to post them on the topic..any idea how to get them on there? haha, completely diff. issue now -_-.

Do we take it you solved your original problem? If so can you share the solution.

To post pictures put them on a picture sharing sight like Flicker (or similar), copy the URL and paste it between the brackets you get when you click the picture icon in the reply box (third from the top left).

No no, Mike. I’m merely new to this, and for some reason, the post wouldn’t let me simply attach the files…newho, here’s the pictures of the circuit i’ve taken…anyone see any problems? everything’s hooked up fine, i’ve checked the connection numerous times…and the voltage is also reading normal. Also, the ground pin towards the right has been moved just for visibility purposes, it’s normally hooked right below the pin of the light sensor.

Imgur
Imgur

and the voltage is also reading normal.

Not sure what normal is? What does a voltmeter read at the Arduino analog input pin, when exposed to full light and when covered?

Might be useful to know the value of the resistor and a link to the LDR sensor specifications.

Lefty

By normal, I mean the usual 5V...the voltage doesn't change at all when the sensor's covered or not... the serial just shows a consistent "1023" in the serial monitor, for some reason, the program runs as if the light sensor/resistor isn't there. The sensor's been checked, and its resistance values are fine...does the problem seem more hardware or software-based? :-?

the voltage doesn't change at all when the sensor's covered or not

That makes it a hardware problem. Your Arduino program doesn't see a change and your voltmeter doesn't see a change, hence the voltage isn't changing with light intensity.

Lefty

Assuming your light sensor is an LDR, it should be wired as a voltage divider with a fixed resistor on the ground side of the voltage divider. Its not very clear but it looks to me like the analog pin is connected to the 5V line and ground is connected nowhere, in which case its working correctly for the wiring.

Theres no specs for the sensor, but it looks like an over sized LDR (light dependent resistor).

Assuming it has a nominal resistance of 10k it should be wired in series with a 10k resistor across 5v and Gnd, with the connection to the analog pin between them.

5v---LDR---X---10k---Gnd

X is where you connect the analog pin to.

As this is a learning experience for me too, could someone elaborate on Voltage Dividers? Don't they do something along the lines of making sensors easier to use by making them constant current instead of constant voltage? Like if the Voltage is constant (just plugging an analog sensor into an analog pin and powering it), then you will always read 5 volts (1023) regardless of the temperature, light, etc. (depending on what sensor you're using), but if you add that resistor, then the current remains constant and the voltage changes? Am I correct? :P

When in doubt: http://en.wikipedia.org/wiki/Voltage_divider

Yeah I checked out the wikipedia page before I originally posted, but didn't really get it still :P. I know that makes me sound a bit dull, but I don't know...there's just something about wikipedia that doesn't get through to me :P.

I reread it a few times, and it sounds like I was right, but I couldn't find the phrase "constant current" or anything like that in my skim through it :P.

It calls it "producing an output voltage that is a fraction of its input voltage", which just makes it sound like it's changing the input voltage a set amount (which may be the case if you're using two resistors?).

Ah well, I'm too tired for higher brain functions ;D.

It calls it "producing an output voltage that is a fraction of its input voltage

Bingo! It even gives you the equation for the fraction. Amazing. (Don't forget the assumed infinite impedance of the measuring instrument, otherwise you might think you could use one to power a 3.3V device form a 5V supply))

Bingo! It even gives you the equation for the fraction. Amazing.

Maybe it's coming across wrong through the internet, but it sounds like you're being condescending. If that's the case, I don't appreciate that at all. If you can't help out without being rude, please don't.

Anyways, that still doesn't solve the constant current question, which, by the way, was pretty much the entire point of the question.

That is what a voltage divider does. Since the LDR is effectively a variable resistor (that varies with light level) and the 10 k one is fixed, the voltage will change as the light level changes. I've implemented several of these things and all are currently working. Heres a live graph of 2 of them :

Ok, well thanks for the help, guys.

Any chance of what's going on at the electron level? :P I don't know if anyone understands that (I realize there are still a lot of electrical mysteries), but I'm curious :P.

I'm sorry, and really not trying to appear rude (challenging yes, rude no), but an equation with an addition, a division and only two terms?