last day (15 days later) » 

12:38
-1
Q: Using internal voltage reference for sensor

electro_nooobbbbi 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 ...

Why do you mix direct accesses to the ADC with functions of the Arduino library? And would you mind to clarify which voltages are at what input pin?
Oh, and your source urgently needs a code style, concerning indentation and white space. As simple as it is, it is hard to read.
@thebusybee Hi, Good to see you here! I have posted my circuit layout above , you may check.
Are you aware that you have a reference of 1,1V and try to measure a solar module with 5V? Why don't you divide that voltage, too? -- Oh, BTW, why is there some unused led in your code? Please make it a habit to provide minimal reproducible code, as any unrelated statements make it harder to understand.
What does your multimeter say about the solar module's voltage in "night" and "day"?
1) The absolute max current an ATMega328 GPIO can take is 40mA, your Solar Panel is capable of deliver 5V with 45mA, it is over the limit. 2) Instead of using a Solar panel as a light sensor, would it be better to use it to charge the battery? 3) You should consider to put your Arduino to deep sleep whenever it is ideal instead of only by night.
@hcheung The current is the maximum the module can deliver, if it is asked for. If the load does not want so much current, it does not source it. Simple electronics.
12:38
@hcheung Yes, you are right, i am not using it as a light sensor it will be charging the battery but it has to detect day and night as mentioned in my post. if voltage goes below a certain level it should detect night or it goes above that level it should detect day and go to deep sleep mode, later on, i will connect solar to battery for charging
@thebusybee The multimetre reads about 1v under my room ceiling light but the serial monitor shows max value. i believe the code needs some editing.
@thebusybee whatever you said to hcheung is 100% right and makes sense.
Sorry my bad on the max current part. You can't measure voltage higher than your Vref which is 1.1V when you using analogReference(INTERNAL). If you want to keep the Vref with INTERNAL, you need a voltage divider same as you used in the battery setup.
@hcheung Yes,right but i am able to read abnormal levels (179.40) constant under my ceiling light.
@thebusybee & hcheung DO you see any issue with the code?
@thebusybee If i use resistors with my solar panel, i believe my current consumption would increase, when using 1K resistor the current consumption increases to 5mA which is not suitable for my system. Yes, my bad i would remove led from the code. Yes, i am aware that i am using 1.1v internal Vref
@thebusybee I have added serial monitor output as well.
@thebusybee something is wrong, if i used the command analogReference (INTERNAL); I read const battery voltage but the solar voltage maxes out under little light but if i use ADMUX |= B11000000; I can read any high/low solar value but batVoltage changes too.
PLEASE add important information by editing your question. I will drop your question if I have to assemble each bread crumb in the comments. -- So you are saying that analogReference(INTERNAL) gives other results than ADMUX |= B11000000;. Would you mind to tell us what Serial.println(ADMUX, HEX); prints after analogReference(INTERNAL)? -- And please add output of the Serial Monitor as text. Yes, you can copy it from the window. The screenshots are barely readable.
To divide the voltage, you can use quite big resistors. For example 470kOhm and 100kOhm, together with an uncritical capacitor (nF to low µF) will draw just some µA.
@thebusybee Good point voltage division. I will be using 47k and 10k resistor which will draw only 65uA. [3.7/(47k+10k)]= 65uA
@thebusybee Yes, now just an update even these two commands did not help much. Please check my last and second last code on the top side.
@thebusybee Please check above
@thebusybee Even the voltage levels are fluctuating
@thebusybee don't worry, i would make sure that you don't have to assemble bread crumps for me :)

last day (15 days later) »