I'm helping with a chemistry lab at my university that has students fabricating mini solar panels. Each panel can generate around 1-3 V and 0.1 mA. I tried to read the voltage from a panel using an analog input on a pro mini to be used a speed controller for a small motor powered by an L298N driver and external 12V, but couldn't get it to work. It worked fine with a 1.5V AA battery. Are the panels generating enough current or should I try to track down a different problem?
If you measure the solar panel before and after you hook it to arduino analog input, do you read different voltages? What do you mean by not working?
The panel has the same voltage and current characteristics, as measured by a digital voltmeter, before and after hooking it up to the arduino.
Sorry, by "not working," I mean that I have programmed the arduino to map an input voltage on an analog pin into a PWM output on a different set of pins. I set a lowest threshold voltage of 1.2V, which the panels exceeded when tested with the DVM, but when I hook up the panels to the arduino it does not detect the input voltage as having exceeded the threshold, i.e. the motor doesn't spin. I tested the connections while they were hooked up and they were good.
Try just reading the panel voltage with analogread() and printing out the result. The negative lead of the panel must be connected to the Arduino ground, and the positive lead to the analog input.
Granted I did not print the analogread() output with the solar panels attached (no computer readily available), but the way the code is written any value less than 50 (~.2V) will not switch the motor on, so I am fairly certain the pin is simply not registering the input voltage of the cell. I connected a AA and 9V battery to the same terminals with the proper polarity and the motor worked as expected. The panels can provide 0.05-0.1 mA current, is this enough for the ADC on a pro mini? Is there something about the panels themselves that prevent them from providing sufficient signal?
I connected a AA and 9V battery to the same terminals with the proper polarity and the motor worked as expected.
You connected a 9V battery to an analogue input?
chemicalcraig:
Granted I did not print the analogread() output with the solar panels attached (no computer readily available),
You are just wasting your own time. Get an Arduino and a PC that can talk to each other and use that to check the raw data.
...R
chemicalcraig:
no computer readily available
Pack your bag and go home.
If you connected a 9V battery to your analog input, you may have damaged the input already. When asked, always try to do it. Printing out analog input isn't too difficult to do. It saves a lot of our time of thinking what was going on if we see results. Also try a different input channel and a 1.5V battery. How are you hooking up the panel to arduino? Are the grounds connected together?
To clarify, I did not connect a 9V directly to an input pin, it went through a step down converter adjusted to 5V. I examined the output of analogRead() while designing the circuit and testing at home with several different voltage sources and it worked as expected. I was able to reproduce the same behavior repeatably in the lab with every voltage source (1xAA, 2xAA, stepped down 9V) but the panels. Here is a picture of the circuit and the code. Robot is a class I wrote for something else, but the function used simply moves four motors forward. The PWM pins are set to OUTPUT in the robot constructor. In testing the correct values of 0 to 255 are printed to the serial monitor, depending on the voltage of the battery I used. The panel is connected to the circuit via alligator clips and a solid electrical connection was made, as tested with a DVM. My question is does anyone know of any reason a panel with the specs in my first post would not work with this circuit?
#include <Robot.h>
int solarPin = A0;
Robot robot(6,3,9,5);
void setup () {
Serial.begin(9600);
}
void loop() {
//Read the analog pin
int speed = analogRead(solarPin);
//Maps from .2V to 3V
speed = map(speed,50,613,0,255);
speed = constrain(speed,0,255);
//Move the motors forward for 100 ms using analogWrite(speed)
robot.moveForwardSpeed(100,speed);
//Print the value of speed
Serial.println(speed);
}
My question is does anyone know of any reason a panel with the specs in my first post would not work with this circuit?
To answer that question, we would need to know the actual value for the inappropriately named variable "speed", that is returned by analogread(). You may find that printing it on the serial monitor, before modification, is a useful and instructive approach.
jremington:
To answer that question, we would need to know the actual value for the inappropriately named variable "speed", that is returned by analogread(). You may find that printing it on the serial monitor, before modification, is a useful and instructive approach.
I'll be sure to bring my laptop to the lab this evening and report back, thanks.
You have a resistor on your breadboard. I can't read its value. Your diagram is way too small. Try exporting in larger size. What value do you have? Why do you need this resistor between analog input and ground?
Hi, check your protoboard tracks, the long ones down the side that you use for supply rails, some boards break the track halfway down the board.
That is they are not continuous from one end to the other.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf? Not a fritzing please.
Can you please post a picture of your project.
Tom.... ![]()
Thanks for your time and ideas, everyone. It turns out it was a problem with the panels. We are making perovskite-based cells and their properties depend on the crystallization of the material. The crystallization improves overnight, to the point where they were able to drive the car today. We are making an instructional video of the lab (featuring the car) and can post it when finished if anyone is interested. Thanks again.
liudr:
You have a resistor on your breadboard. I can't read its value. Your diagram is way too small. Try exporting in larger size. What value do you have? Why do you need this resistor between analog input and ground?
Sorry about the size, I'll know for next time. It is a 4k7 pulldown resistor. I ended up using the analog pin as INPUT_PULLUP and making the appropriate changes in the code. Thanks for your time.
Yes, you can use that feature if your measurement is of resistive nature, say a thermistor or maybe light-dependent resistor. I don't know why you would need pull-up or down for a solar panel that outputs a voltage. You are just passing current through the pull-up resistor that lowers the voltage of your panel, at about 0.1mA, so not a big deal.