Hello, I have Arduino mega 2560 and I tried to connect a solar panel to the arduino and so read the electric current which is an indication of light level.
This is the setup I did, I connected the positive wire of the panel to PIN 8 and the negative one to GND.
And that was the code:
int a = 0;
void setup() {
Serial.begin(9600);
pinMode(8, INPUT);
}
void loop() {
a = analogRead(8);
Serial.println(a);
}
The debug was incorrect, it started from 320 ish and went down to 318 and stopped, the current callouts was unresponsive to the flashlight that I used to light on the solar panel.
What is wrong with my setup/code?
What solar panel? How does measuring voltage "read the electric current"? You need a shunt
resistor load to measure current.
Solar panels need even illumination to work properly, and a lot of light (sunlight is thousands of
times brighter than a flashlight (unless you have a crazy powerful one)).
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
With the panel in sunlight but not connected to anything, what voltage do you measure at its output terminals?
How big is big?
Some dimensions or a picture or a spec sheet or where did you buy it or do you have a part number would be nice.
Does it have any information printed near its terminals.
Thanks... Tom...
Hello, the solar panel is 11 x 4 cm I didn't found any part number and I just found it.
As I said it was about 2-3 volts at sunlight and there is the circuit drawing.
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
It will also show you how to post images.
OPs pics.
Why are you trying to analogRead from a digital pin?
Pins A0 to A8 are the analog input pins on a mega.
2-3V is very low for a solar panel when held in sunlight - which may mean it's broken. Normally solar panels are at least 5V, to be able to charge USB devices. Larger panels (yours is a small one) commonly put out 18V.
This way you're measuring voltage. An analog reading of 320 is 1.56V (5V full scale) which is lower than I'd expect based on the 2-3V you say your multimeter gives you.
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
It will also show you how to post images.
OPs pics.
Why are you trying to analogRead from a digital pin?
Pins A0 to A8 are the analog input pins on a mega.