Ground Issue with Photocell

Hi. I'm new to the Arduino/Electronics world and have a small problem that I can't figure out.

I have created a relay controlled electrical outlet that I can turn off and on easily with the Arduino. I then created a simple circuit board that contains a Photocell and battery supply with an single input wire back to the analog port of the Arduino. I'm doing this so I can place my photocell anywhere in the room away from the controlled relay. Here lies my problem. when I have the photocell board powered with my battery back and the input wire run back to the analog port of the Arduino my relay starts turning off and on very quickly and the serial print shows the reading jumping from 0 to 1000 rapidly over and over. When I take a ground wire and run it from the ground of the circuit board back to the ground of the Arduino the sensors and relays function correctly. Is there a way I can make this work so that I will not need to use the ground of the Arduino and go just use the single input wire?

You need a return circuit for your photocell connection, current flows in complete circuits.
One wire and no return for the current back to the sensor is not a complete circuit.

You can get pairs of wire that are bonded together to make your circuit.

Tom... :slight_smile:

I do have a completed circuit as I'm supplying my board with the photocell a separate battery supply. So this circuit board has power and a completed circuit. On my circuit board I have 2 input terminals for battery which I use 2 AA batteries and another terminal for my input wire back to the Arduino which is connected to the ground side of the photocell. When I connect to volt meter everything appears fine with the board but when I connect the input wire to the Arduino is when it goes crazy. The only way I can make it function is the additional ground back to the Arduino from the separate board.

Draw a circuit diagram of your setup. You sound to be confused about how circuits work and how grounds work and why is their not a resistor in the setup?

Drawing of my circuit


You MUST connect the microcontroller ground and the external circuit ground.

Connect the Arduino ADC input to the junction between the 10K resistor and the photocell, and connect the battery negative to Arduino ground.

Ok.. thanks.. That was how I made everything work by adding another ground from the controller to the external board. Just wasn't sure why it was required. I guess as long as it works it doesn't matter why. :slight_smile:

It matters to people who want to learn something about circuitry.

That's not what I meant. I do care that is why I started the post to begin with. I don't understand why I need the extra ground. I figured out on my own to add the extra ground back to the controller just would like to know why it is needed.

The battery and photoresistor and 10k form one current loop.
The other loop is to get your middle point voltage to the Arduino AnalogInput via the gnd connection.
Circuit (2)rdit.jpg
If you had no gnd to the Arduino you would have no loop and so the voltage on the Arduino would have no reference for the Arduino to read it against.

Tom... :slight_smile: