Pages: [1]   Go Down
Author Topic: Measuring sunlight intensity with BPW34 pin diode and Arduino UNO?  (Read 2868 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So first of all, I have limited experience with Arduino, electronics and the C++ language.

I want to be able to measure sunlight intensity with the miniature solar cellBPW34 https://www.sparkfun.com/products/9541, but I can't find any simple circuits or code to measure this with the Arduino Uno.

This is the closest we found to a circuit http://dptnt.com/wp/wp-content/uploads/2010/02/Arduino_Smart_Flash_Trigger.png, I would like to know if we can only use the part of the circuit (on the left side) connected to BPW34 (R1, R2, C1, D1).

Thanks for your help.
Logged

Canada
Offline Offline
God Member
*****
Karma: 7
Posts: 600
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That circuit is more than you need and will not work for steady state situations.  Just use the diode and the 10K resistor (R1) and connect from the diode/resistor point (where C1 is now) to the Arduino ADC pin.

Edit:  I'd be tempted to replace that 10K resistor with a 20K trimpot.
« Last Edit: March 02, 2013, 02:10:58 pm by BillO » Logged

Facts just don't care if you ignore them.

Lost Wages
Offline Offline
Full Member
***
Karma: 11
Posts: 103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is a simple circuit that would read the voltage across the PiN.
BillO's trimpot idea has merit.  These components don't generate much power and 10k might load it down.
I added a 0.01uF capacitor to stabilize the voltage a little.  Try it with and without to see if it helps.


* pin-diode_schem.jpg (25.74 KB, 312x381 - viewed 382 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for all your replies.

I'm also limited in parts, I don't have a 20k trimpot but I do have a 10k trimpot and a pack with a wide range of smaller resistors. https://www.sparkfun.com/products/9806? and http://www.thesource.ca/estore/product.aspx?language=en-ca&catalog=online&category=Resistors&product=2719018. I also don't have a 0.01uF capacitor, the smallest I have is just 1uF, would these parts still work?

I can always order online, but that just means more money spent and I'm running behind on schedule.

And would this code work? http://arduino.cc/en/Tutorial/ReadAnalogVoltage, if I just don't add the potentiometer and have the GND, 5v and A0 directly connected on the board?

I don't need the results to be super precise, I'm using for a project just to know if the sun's up and it's intensity.

Thanks again
Logged

Lost Wages
Offline Offline
Full Member
***
Karma: 11
Posts: 103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are nearer than you think.  Use a 10k resistor in series with the trimpot.  When the trimpot is adjusted to 0 ohms, you have 10k total. When the trimpot is adjusted to 10k, you have 20k. I really don't think that the trimpot will be needed, but it might. smiley

The 1uF cap is a little large, but might do. Again, the cap is probably not needed either.  Make sure that, if the capacitor is polarized, you place the negative side to ground.

The ReadAnalogVoltage reads A0 and should work.  I'll review the code to see if it needs a tweek. The PiN diode won't generate much voltage at full light.

Attached is a new schematic with the trimpot and resistor in series, and a polarized cap. Again, the trimpot and cap may not help much.


* pin-diode2_schem.jpg (26.71 KB, 306x381 - viewed 226 times.)
Logged

Lost Wages
Offline Offline
Full Member
***
Karma: 11
Posts: 103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The ReadAnalogVoltage code should work out of the box, methinks.

The only caveat is that the A0 pin will read an A2D value between 0 and 1024, with 1024 being 5V.  The PiN diode with no load might go up to 350mV, so your circuit's highest possible digital value is 72.  So be prepared for low readings.

A last thought:  the PiN diode's strength is its sensitivity and fast reaction time -- neither needed in your project. A LDR is probably a better sensor for the project.

Attach a picture when you are done...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok everything is working now  smiley-lol. Attached is a picture of my setup if it's not clear enough: the solar cell is on (positive side) d11 and (negative side) d13, the 10k resistor is connecting the 5V to a11, the 1uf capacitor is connecting the GND to b11, and the yellow jumper wire is connecting the A0 and c11 and the white jumper wire is connecting the GND to a13.

I tried the 10k trimpot but it didn't make any difference. However if I remove the capacitor the serial monitor reads nothing. The code works fine and automatically converts the numbers to Volts. With one cell I got 0.85V from a lamp, I have 3 others and with all 4 together I got 2.00V. The 2V also dropped to 1.6V when I turned the lamp off, which is enough for my project.

Thanks again, I might get a 0.01uF cap just to try it out, If I do I'll post the results and changes.


* IMG_2523.JPG (481.01 KB, 2048x1536 - viewed 237 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

would you have the code to this?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Heres the code I use:



Code:
/*
  ReadAnalogVoltage
  Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
 
 This example code is in the public domain.
 */

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  // print out the value you read:
  Serial.println(voltage);
  delay(1000);
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have the complete circuit used?

Thanks!
Logged

Pages: [1]   Go Up
Jump to: