-3

i am using 3.7~4.2V lithium battery. I am using internal voltage reference to read constant battery voltage as we know that the battery voltage level depletes overtime. The problem is that my sensor (mini solar panel) reads max value under little light and does not go beyond that level no matter how much light falls onto it in the later stage.

1
  • Comments have been moved to chat; please do not continue the discussion here. Before posting a comment below this one, please review the purposes of comments. Comments that do not request clarification or suggest improvements usually belong as an answer, on Arduino Meta, or in Arduino Chat. Comments continuing discussion may be removed.
    – Juraj
    Feb 23, 2023 at 12:38

1 Answer 1

2

The problem is that my sensor (mini solar panel) reads max value under little light and does not go beyond that level no matter how much light falls onto it in the later stage.

Open voltage is not a good way to read the light level hitting a solar panel in this situation. Much better is to measure the current generated by the solar cell by adding a resistor across it here...

enter image description here

The value of the resistor can be found using...

V=IR

... where ...

V=1.1 volts

I=the maximum current the solar cell can generate in full light

If you do this, then you can read the A1 pin using the 1.1V ref and you will be able to measure the full range of light conditions using the solar cell with simple Arduino code like this..

analogReference(INTERNAL);  // a built-in reference, equal to 1.1 volts 
int v=analogRead(A1);       // Returns value 0-1023 representing light level

PS: Note if you measure the battery voltage with a divider as shown, you will be drawing current (about 0.8 milliamps when the battery reaches its minimum voltage) ALL THE TIME - even when the circuit is off. You do not want to do this with a lithium battery since under-voltaging it can potentially cause permanent damage to it. You really should heed my answer to your other question here.

PPS: It is usually best to ask your real question directly rather than asking a bunch of questions that are synthetic and reflect problems you think you have rather than the problems you actually do have. Your supplied code and drawings should match the thing you are asking and the thing you are actually working on (and each other!). It is often the case that the problem is not where you think it is, and so showing code and drawings that do not reflect what is really going on just wastes people's effort and does not ultimately help you solve your real problem. :)

5
  • "Then how do i reduce my battery voltage to Vref?" The best way to measure the voltage of your power source is by measuring the 1.1V ref against Vcc as suggested in my answer to your other question and the article linked there.
    – bigjosh
    Feb 22, 2023 at 9:05
  • " If i connect resistor on the solar end, the current drawn would increase and it would result into slow battery charging which again is not a suitable option for the specific project. " You question is about using a solar cell as a sensor to measure the light level. This answer tells you a good way to do that. If you are using the solar cell to charge the battery, then this is not represented in the question, in the code, or in the drawing so it is hard for us to help you with that! :) And note that charging a battery is a very different thing than using it as a light sensor.
    – bigjosh
    Feb 22, 2023 at 9:08
  • 1
    These are all very different things that what is asked in this question and your others. Do note that charging a lithium battery is non-trivial and is not as easy as just connecting a solar cell to it. Check out batteryuniversity.com/article/bu-409-charging-lithium-ion for some info.
    – bigjosh
    Feb 22, 2023 at 9:22
  • 1
    Your code above has many problems and does not compile. Best way to solve this problem (or any problem) is to find the minimum code and circuit that reproduces the problem and post that, along with (1) what you want to have happen, (2) what actually happens with the supplied code and circuit. For me, very often just systematically following these steps will actually end up with me solving the problem myself - but if not then at least you make it easy for other people to help you when you post it.
    – bigjosh
    Feb 22, 2023 at 19:24
  • For example, in printVolts(), you use the variable val even though it does not exist here. My guess is that in your code you are unintentionally switching between the 5V and 1.1V references because you are sometimes using the Arduino functions sometimes changing the registers directly. Also note that with your current resistor values that you can not measure the battery voltage with the 1.1V ref because the output voltage can be higher than 1.1V even at the lowest possible battery voltage.
    – bigjosh
    Feb 23, 2023 at 3:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.