[SOLV]floating voltage at the output of a light sensor (with arduino Uno rev 3.)

Solved: it was a soldering issue.

Hi everyone,

I'm working on a photocell project and having some trouble with a sensor.
I'm using this sensor: AMBI Light Sensor – Modern Device to catch visible light.
The fact is that the output that I read from the analog connected to the output of the sensor seems insensitive to the variation of light.
It remains almost constant even with sharp changes (from total dark to light).
Since I'm a newbie in electronics, I think I'm doing something wrong in this issue.

Another problem is that the magnitude of the value may change whenever I move the entire system: sometimes around 600, sometime around 400.

Could it depend on the fact that i didn't soldered the sensor with the header pins provided in the package?
I mean: I used the pins provided in the package but didn't soldered them (thanks to Bill0 who made me notice that the previous sentence was not clear)

However I think that, once I keep the system stuck on a surface,the output should significantly change when I change the lighting.
Moreover the header pins themselves shake at the minimum touch.

Below the correspondence between the pins of the sensor and the analog pins of the arduino:

Sensor ----- Arduino analog
Ground ----- 5
+5V ----- 4
V0 ----- 3

The code that I'm using is the following:

void setup() {
Serial.begin(9600);
pinMode(18, OUTPUT);
pinMode(19, OUTPUT);
digitalWrite(18, HIGH);
digitalWrite(19, LOW);
}
void loop() {
int Light = analogRead(3);
Serial.println(Light);
delay(250);
}

I also tried the code with the aliases of the sensor numbers A3, A4 and A5.
Moreover I measured the voltage at the pins: ground and power (+5V) look ok, even if at pin 4 I measured a Voltage of about 4.70V (little bit less than the nominal "HIGH" value 5V).
Can't understand if the issue is a different scale of voltage between the sensor and the arduino board.

Everything seems ok, at least in the configuration. Any idea on how to solve this problem?

Elina

You need a pull up or a pull down resistor to create a proper voltage divider.

Hi James C4S,

thanks for your quick reply.

I'm not using a photocell sensor like the one shown in the link.
Is your answer still valid for the sensor that I showed in the post AMBI Light Sensor – Modern Device ?

(I'm quite slow in understanding answer, please be patient :slight_smile: )

Elina

Your code looks like it should work given the information you have presented However, I am not sure what you mean by the following:

Could it depend on the fact that i didn't soldered the sensor with the header pins provided in the package?

and

Moreover the header pins themselves shake at the minimum touch

Does this mean you used the supplied headers, but did not solder them? Or does it mean that you used headers that do not fit properly?

Can you show you a clear photograph of your set up?

Elina:
Is your answer still valid for the sensor that I showed in the post AMBI Light Sensor – Modern Device ?

It appears that module has the divider built into it already.

BillO:
Does this mean you used the supplied headers, but did not solder them?

Exactly!
They fit properly, but if they are accidentally touched they may exit the slots on the arduino board in which they are inserted.

Can you show you a clear photograph of your set up?

At the moment I can't. I'll provide it as soon as possible.

Thank you!

Elina

Elina:
Exactly!
They fit properly, but if they are accidentally touched they may exit the slots on the arduino board in which they are inserted.

Yeah, I would point to that as the primary problem.

I agree. He is assuming (I guess) plated through holes which may not be the case. Solder those header pins to the module.

Lefty

Pictures needed!

I agree. He is assuming (I guess) plated through holes which may not be the case. Solder those header pins to the module.

Lefty

The pictures are taken from modern device website, however I think they should be clear.
I have a sensor and a three-header pin as shown in picture 1_STARTING_CONFIG.png (and, of course, an Arduino Uno rev. 3 board)
Should i solder the pins and the sensor as shown in picture 2_SOLDERED.png?
And then obtain something like what shown in 3_MOUNTED_ON_ARDUINO_BOARD.png? (even if the pictures shows an arduino 2009?)
At the moment I use the three header inserting their longer part in the holes of the sensor and then fitting them into the pins of the arduino each time I need it.

Thanks.

Elina

Yes, for sure. Solder the short end of the pins into the sensor board, then you can plug it into the Arduino properly as the longer end of the pin will make better contact with the Arduino socket.

Thanks to everyone. Now that I know the issue, I would like to ask if there are specific advices on soldering pins on boards of such a small size (around 1 cm^2) or if I can follow common guidelines found on the web. I have 4 sensor and would like to save each of them :slight_smile:

Thanks!

Elina

I can follow common guidelines found on the web

Sure. Soldering through-hole with 0.1" (2.5mm) spacing should not be a problem with a small iron and solder.

Should i solder the pins and the sensor as shown in picture 2_SOLDERED.png?

If you achieve to get something similar, you're perfect. You'll probably have more solder around the pins :wink:

The usual web guidelines are rather about more difficult stuff like SMD soldering.

BTW: You are aware that you "abuse" two Analog Pins as GND and +5V supply; which is no problem with this sensor, if you do not need those analog pins for anything else.

Hi,

michael_x:
BTW: You are aware that you "abuse" two Analog Pins as GND and +5V supply; which is no problem with this sensor, if you do not need those analog pins for anything else.

Actually I didn't consider this aspect, however for my project I need only that sensor on my board. Just in case of a "pin -demanding" :wink: project could I use an external power supply, connecting, for instance, the arduino to a demo board?

Thanks for previous advice!

Elina

You can use the Arduino 5V, of course, just put your 3 pin sensor on a breadboard ( or wherever you have the other demanding hardware),
and connect the 3 pins individually to GND, 5V, and any Analog Pin.

I think a general guide line would be to always properly solder the appropriate connectors to any size board. The only time connections should not be soldered is when proper connectors, sockets or solderless breadboard are being used.