Detect battery status with LED

can i detect the battery status with spark, like when the battery is low the RGB LED will blink red? if no what can be a replacement?

The simplest method is to use a voltage divider and feed the input to an Analog pin.

This is definitely not the best practice and precise accuracy but a simple approach i use when it’s not critical.

You will be able to change the RGB led color according to the value of the analog pin with the functions mentioned here: http://docs.spark.io/firmware/#libraries-rgb

A Lipo gauge is gonna be useful if you are using one : https://www.sparkfun.com/products/10617

1 Like

i think i’m gonna go with voltage divider but can you explain how can i work on that?

Let’s say you have a 1S Lipo Battery which gives 4.1V

The maximum voltage an Analog pin can take in is 3.3V so we need to use a simple Voltage divider to bring down the voltage.

Example:

                            A0
                            |
                            |
                            |
Battery + -----> 30K Ohm ---|----> 10K Ohm -----> Battery -

Now, the 4.1V will be divided across the 2 resistor.

The formula will be:

Voltage = Resistor/Total Resistance x Battery voltage

Referencing from Battery -, we will have:

10K/40K x 4.1V = 1.025V (maximum)

You can play around with the resistor values but just make sure the maximum voltage across the bottom resistor is no more than 3.3V.

Google for voltage resistor and there will be tons of tutorial available. :wink:

2 Likes

how about im gonna use the battery from the maker kit using the battery shield?

With the 5 volt tolerant pins, we should be able to use more voltage (5v). Is that right?

@Jack, what do you mean? The digital inputs (only and not the analog inputs) are designed for 3.3V input. Being 5V tolerant means they can handle up to 5V at most. Is this what you mean?

2 Likes