Low battery indicator

Discussion about other hardware (including other Pi-like boards)
User avatar
winnetouch
Posts: 158
Joined: Mon Jul 11, 2016 10:56 am
Has thanked: 2 times
Been thanked: 30 times

Re: Low battery indicator

Post by winnetouch » Sun Nov 20, 2016 3:06 am

sotasystems wrote: Image
Sorry, I don't mean to rush but I borrowed that multimeter that I have to return in a couple of days :P. As I said in the post before this one, everything is wired as it should be, the only problem I have is with the arduino script.

User avatar
Camble
Posts: 885
Joined: Thu May 05, 2016 2:31 am
Location: Scotland
Has thanked: 269 times
Been thanked: 488 times

Re: Low battery indicator

Post by Camble » Sun Nov 20, 2016 7:04 am

I should point out that with an Arduino, you can read the battery voltage using one of the analog pins. You don't need a reference voltage with a divider and a "battery low" flag. You can have a reading of the actual voltage and make your decisions based on that.

User avatar
winnetouch
Posts: 158
Joined: Mon Jul 11, 2016 10:56 am
Has thanked: 2 times
Been thanked: 30 times

Re: Low battery indicator

Post by winnetouch » Mon Nov 21, 2016 12:31 am

Camble wrote:I should point out that with an Arduino, you can read the battery voltage using one of the analog pins. You don't need a reference voltage with a divider and a "battery low" flag. You can have a reading of the actual voltage and make your decisions based on that.
I'll be honest... I have no clue what that means :P.

Also, I entered sotasystems' code in to my sparkfun pro micro anyway and all I get from the leonardo serial monitor are 0 (zeros).

Also:
Charge your battery up until it is completely full and then read the voltage with a multimeter AND your leonardo at the same time.
I get where to check the voltage with the multimeter, but how do I check the voltage with the arduino?

User avatar
Camble
Posts: 885
Joined: Thu May 05, 2016 2:31 am
Location: Scotland
Has thanked: 269 times
Been thanked: 488 times

Re: Low battery indicator

Post by Camble » Mon Nov 21, 2016 3:07 am

winnetouch wrote: I get where to check the voltage with the multimeter, but how do I check the voltage with the arduino?
You'd need to do a bit of reading

https://www.arduino.cc/en/Reference/AnalogRead

User avatar
winnetouch
Posts: 158
Joined: Mon Jul 11, 2016 10:56 am
Has thanked: 2 times
Been thanked: 30 times

Re: Low battery indicator

Post by winnetouch » Mon Nov 21, 2016 1:34 pm

Camble wrote:
winnetouch wrote: I get where to check the voltage with the multimeter, but how do I check the voltage with the arduino?
You'd need to do a bit of reading

https://www.arduino.cc/en/Reference/AnalogRead
I read up what you posted. Didn't understand much so I looked up a video by Paul McWhorter. I sort of get what I have to do BUT... The problem is the code I'm using for the controller. My pin 15 and A1 are determined to be keypresses. So whenever I try to upload the script all I get is a blinking red light and the arduino continually sending out a command for a button press. I tried to make sense of the code I use (I didn't write it myself and it's posted 2 or 3 posts ago) but I can't see a way to skip those 2 pins. As far as I understand the script uses an equation to determine pin numbers and corresponding commands they send. But I don't know how to skip any specific pin. Should I be using a different code altogether?

I'm sorry if I'm a pain but I don't know how to program. I try to learn as I go but sometimes I really need baby steps to get thing that seem self explanitory to other people :P.

User avatar
sotasystems
Posts: 160
Joined: Sun Oct 09, 2016 4:56 am
Location: Germany, 127.0.0.1
Has thanked: 95 times
Been thanked: 93 times
Contact:

Re: Low battery indicator

Post by sotasystems » Tue Nov 22, 2016 1:32 am

It is no problem to use other pins to do the reading and lighting the LED. But I see that the problem is getting your readings (you just get "0" for some reason). First, use this code in a new sketch to see if you get something else than 0, and if you don't, then you can get your readings. (don't use your controller code just yet, we will modify it later):

Code: Select all

int ReadVoltage = 0;

void setup() {
  analogReference(INTERNAL);
  pinMode(A1, INPUT);
  Serial.begin(9600);
}

void loop() {
  ReadVoltage = analogRead(A1);
  Serial.println(ReadVoltage);
  delay(1000);
}
Ladies and gentlemen, I would like to inform you that I am currently moving very far away, and therefore I am very busy.

UPDATE: I am still alive! My ISP is setting up my internet on the 19th of January at my new place, explaining my offline-ness.

If you write me a PM, I will very likely take some time to respond.

Also, my 2nd build will soon go on, so if you've been following it, please stay tuned! :)

Many thanks for your understanding!

User avatar
winnetouch
Posts: 158
Joined: Mon Jul 11, 2016 10:56 am
Has thanked: 2 times
Been thanked: 30 times

Re: Low battery indicator

Post by winnetouch » Tue Nov 22, 2016 11:48 pm

sotasystems wrote:It is no problem to use other pins to do the reading and lighting the LED. But I see that the problem is getting your readings (you just get "0" for some reason). First, use this code in a new sketch to see if you get something else than 0, and if you don't, then you can get your readings. (don't use your controller code just yet, we will modify it later):
Did what you said and as long as the GB0 is turrned off I get al zeros. When I turn it on I get values around 767-781, then when the GB0 booted up it started dropping to around 740-760 and stayed there for the time I was observing.

User avatar
sotasystems
Posts: 160
Joined: Sun Oct 09, 2016 4:56 am
Location: Germany, 127.0.0.1
Has thanked: 95 times
Been thanked: 93 times
Contact:

Re: Low battery indicator

Post by sotasystems » Thu Nov 24, 2016 6:57 am

winnetouch wrote:
sotasystems wrote:It is no problem to use other pins to do the reading and lighting the LED. But I see that the problem is getting your readings (you just get "0" for some reason). First, use this code in a new sketch to see if you get something else than 0, and if you don't, then you can get your readings. (don't use your controller code just yet, we will modify it later):
Did what you said and as long as the GB0 is turrned off I get al zeros. When I turn it on I get values around 767-781, then when the GB0 booted up it started dropping to around 740-760 and stayed there for the time I was observing.
Sounds about right. Now do as I said in page one:
sotasystems wrote:To get the baseline readings, you do the following:

Charge your battery up until it is completely full and then read the voltage with a multimeter AND your leonardo at the same time. Then turn your gameboy on. Then open the Arduino Serial monitor on your computer, and note the approx. value you get there and the voltage you read with the multimeter. Now either play a game or just let a game run on your gameboy to make use of the battery and note the approximate readings you get from the serial monitor and the multimeter like every 10 minutes until the battery is depleted, but don't go below 3.20 Volt. Please also write the exact time! If you don't even get to 3.20 Volt, please tell at which voltage it started to cut off. If you have all your readings, please report back.
Ladies and gentlemen, I would like to inform you that I am currently moving very far away, and therefore I am very busy.

UPDATE: I am still alive! My ISP is setting up my internet on the 19th of January at my new place, explaining my offline-ness.

If you write me a PM, I will very likely take some time to respond.

Also, my 2nd build will soon go on, so if you've been following it, please stay tuned! :)

Many thanks for your understanding!

User avatar
winnetouch
Posts: 158
Joined: Mon Jul 11, 2016 10:56 am
Has thanked: 2 times
Been thanked: 30 times

Re: Low battery indicator

Post by winnetouch » Thu Nov 24, 2016 10:49 am

sotasystems wrote: Sounds about right. Now do as I said in page one.
Here is a screenshot of the values. As instructed I did not go under 3,20 volts. The arduino values are a bit wonky since they kept fluctuating all the time.
Screen Shot 2016-11-24 at 18.45.37.png
Screen Shot 2016-11-24 at 18.45.37.png (43.29 KiB) Viewed 10507 times

User avatar
sotasystems
Posts: 160
Joined: Sun Oct 09, 2016 4:56 am
Location: Germany, 127.0.0.1
Has thanked: 95 times
Been thanked: 93 times
Contact:

Re: Low battery indicator

Post by sotasystems » Thu Nov 24, 2016 11:02 am

winnetouch wrote: Here is a screenshot of the values. As instructed I did not go under 3,20 volts.
Very well. :) Going below 2.90 - 2.80 volts could potentialy permanently damage the battery. 3.20 Volts is a "safe" range to stay on with Li-Po batteries.
winnetouch wrote:The arduino values are a bit wonky since they kept fluctuating all the time.
Pretty usual.

Now there is a last thing I would like to know from you:

When do you want your battery low LED to come on (Voltage value)? I would recommend 10-15 minutes before reaching 3.20 Volts, but it's up to you.
Ladies and gentlemen, I would like to inform you that I am currently moving very far away, and therefore I am very busy.

UPDATE: I am still alive! My ISP is setting up my internet on the 19th of January at my new place, explaining my offline-ness.

If you write me a PM, I will very likely take some time to respond.

Also, my 2nd build will soon go on, so if you've been following it, please stay tuned! :)

Many thanks for your understanding!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest