Hello
I'm using Pro-Ethernet and I connect him to a battery
I need to know what is the status of the battery ?
is it possible?
I want to define the area is 15V-13.5V , and every step is 0.3V
15V-14.7V :100%
14.69-14.4:80%
14.39-14.1:60%
.
.
.
How do I connect the battery to the analog inputs in order to get this data?
You use a potential divider, sized such that the maximum voltage on the input gives you 5V at the output which you connect to the analogue in of the arduino.
I'm sorry ,
but I don't understand what I need to to now .
maybe you can explain in more easy words?
all I know is that the 15V will give my 1023 at the analog (this is the max right? )
I'd probably write a function or macro to do your conversion for you, given the values of the potential divider resistors, and let the compiler and the processor do all the hard work for you.
Then you can just write stuff like
if (voltage > convertDivider (14.7)) {
level = 100;
}
You can add refinements, but if you keep this sort of structure, you can debug more easily, because all the units are easily recognised when you print them.
Assume the reference voltage is 5 volts.
Then an increment or decrement of a single count from the analogue to digital converter represents 5.0 / 1023 volts.
If it's not a "requirement" to only have 6 distinct results only ( 100, 80, 60, 40, 20, 0 )
you can use the map function to turn the analogRead result to a convenient number.
Maybe you just get started and show where you're stuck and tell why ?
there isn't any requirement to 6
can you tell me what does the map function do , and hoe to use it?
and maybe to show me a simple example of it? to understand
depending on the actual resistor values and which voltage/(analog Reading) you define as 0 % battery capacity.
( Observe the **See also: constrain() ** hint at the end of the Map reference )
If you are concerned with accuracy, you shouldn't just map the number based on the math. First of all the value of the resistor is likely not to be exact and more importantly there will we a very small current flowing throught the arduino pin and this affects the voltage divider.
I create the divider, then hook up the arduino and perform analog read using the serial monitor. Then I compare that with a measurement of the battery with a digital multimeter.
So you then get something like analogRead(A0) = 800, while the voltmeter is reading 13.1 volts.
Then you can code the conversion like:
long calc1 = ((analogRead(A0) * 16375L) / 100000L) //which would equal 131
float voltage = (calc1 / 10) // this would equal 13.1 (volts!)
You could modify it for two decimals of precision or whatever you prefer.
Also be aware that the bigger resistors you use (the less current you run through it), the less accurate the divider is, so you have to find the right balace for your needs.
and more importantly there will we a very small current flowing throught the arduino pin and this affects the voltage divider.
No.
This is a very very small current and in practice with a 30K total resistor chain will not change the voltage by any significant ammount. The technical term is chuff all.
Look get real. We are talking about measuring a battery to see the state of it. A simple analysis and 1% resistors with a 10 bit converter is more than enough for the OPs requirements.
I did state "if you are concerned with acuracy", I wasn't suggesting it was the only way to go. I am brand new to Arduino, and I get the information I need 90% of the time by reading old threads on this forum, so I do not have to bother guys like you with simple questions, I try to save the asking for when I have little other choice. Adding my thoughts to this thread might help the OP or anyone else who may read it in the future.
This was the first time I tried to share on this forum, to try to help someone else instead of just being a mooch.
He is maping 0 - 100% in just 1.2volts, so accuracy appears to be an issue. I was just trying to help, and I still feel my approach is not "over the top". Also, 1% resistors are not the norm, 5% are, and with 5% resistors it can throw this calculation off (worst case scenario) by .5v, that's nearly 50% of the range he wants to measure. Whats the harm in measuring and knowing you are reading the actual voltage?