Measure Battery Level

HI everyone.

I would like to measure the battery level in a new widget. Is that something possible? Has anyone tried this? If yes, can anybody help me?

Thank you in advance

Comments

  • wjcroftwjcroft Mount Shasta, CA
    edited May 2019
    Laercio, hi.

    There is no access to battery level in either Ganglion or Cyton -- that is built into the hardware. However if you have Cyton, you could wire up something using an Aux channel operating in Analog mode. You want to measure the raw battery voltage, which can vary from around 4.2V to 3.2V with LiPo. The ADC pins for the Aux measurement should not go above 3.3V, the power supply voltage. So I'd suggest a voltage divider, to get into the range say, battery voltage divided by 2. Or divide by 4 if you are using the AA cells.

    Have you considered just purchasing 2 LiPo cells and having one charge while using the other? That way you always have a fresh cell ready.

    Yet another way to go are the Adafruit PowerBoost chargers,


    Regards,

    William

  • Thank you @wjcroft for your answer.

    I already have 4 batteries and I use this strategy of charging them when they are not in use.

    My
    idea is to check my supply energy in a widget at the same time I check
    EEG signals for example. In this case, I don't want to have an
    electronic device to do it, but a widget and check supply energy
    information on my screen.

    When you told that there isn't access to battery level, does it mean that I can't reach this information by programming?
  • wjcroftwjcroft Mount Shasta, CA
    re: "I already have 4 batteries"

    can you clarify, you rotate through 4 different LiPo cells?

    re: "I don't want to have an electronic device to do it"

    I outlined how the hookup would work. There is no built in hardware, you just need two resistors. Do you know what a voltage divider is?


    The divider converts the battery raw voltage, (which might go above the 3.3V maximum), into a range that is acceptable to the Aux inputs. This is done by dividing the raw battery voltage by 2 or 4, depending on what type of battery you have.

    There is no software widget for battery. However there is a widget to read the Aux channel values out numerically.

    re: "does it mean that I can't reach this information by programming?"

    Correct, but wiring up two resistors would take 5 minutes of your time.
  • re: "can you clarify, you rotate through 4 different LiPo cells?"

    Yes, I have 4 different LiPo cells.

    re: "I outlined how the hookup would work. There is no built in hardware, you just need two resistors. Do you know what a voltage divider is?"

    Yes, I know what it is.  

    re: "Correct, but wiring up two resistors would take 5 minutes of your time."

    I know that it would be something really easy to do, but my original idea is to develop this idea with no external electronic devices, just by software.

    I have found this website about reading internal voltage in a Arduino device:


    Is it a code useful for cyton?
  • wjcroftwjcroft Mount Shasta, CA
    No.

    The raw battery voltage does not touch any pins of the Cyton chipKIT / PIC32 microcontroller. Thus, how can it possibly access this information from firmware / software? The microcontroller only sees the regulated 3.3V power supply.
  • Thank you so much for your explanation. This is something that I didn't know.

    In this case I'll try your idea about voltage divider
  • wjcroftwjcroft Mount Shasta, CA
    The resistor divider works only on ratio, so any resistor values can be used. However, to not drain your battery while measuring it, you might want to use two 1 megohm resistors. That way the drain when your Cyton is sitting in the closet for days or weeks is negligible. 
  • wjcroftwjcroft Mount Shasta, CA
    Rather than messing with the surface mount soldering joints, you can use these two stub cables to make an (shrink tubed) adapter containing your resistors, and a separate wire going to the analog input pin used by the Aux channel.


    So the wiring is just as you would expect, red to red and black to black. Then the two 1 meg resistors in series between red and black. Your single wire (say blue color), taps at the junction between the two resistors, and is routed to the header connector for the Aux channel.

    Adafruit also sells jumper cables you could cut off one connector to use for your blue wire.

  • retiututretiutut Louisiana, USA
    edited May 2019
    Thanks for the info @wjcroft!

    Based on this info, I have an idea! What about a middleware device that connects to the battery to display battery level? Like a fancy battery charger even. Does this exist already? Sounds like it could be made.
  • retiututretiutut Louisiana, USA
    edited May 2019
    Neat! I would say have a device that makes a noise to alert to low battery, but this might seriously disrupt the peace and quiet of the session.
  • wjcroftwjcroft Mount Shasta, CA
    You just need to check it before a session, since the LiPo cells have quite a large capacity.

  • wjcroftwjcroft Mount Shasta, CA
    A significant DIS-advantage to the LED battery indicator above, is that it is not designed to be connected to the battery circuit all the time. It is intended to only be switched on during the time your device is in use. Then switched off with the device power. This is fine if you can design your circuit to accommodate that switching function.

    With the 2 megohm resistors (voltage divider idea outlined previously), those can be left in the battery circuit, requiring no switching.
  • wjcroftwjcroft Mount Shasta, CA
    And... just found this other tiny board which DOES have an integrated switch. So it appears the LEDs only light and are powered when Test button is pressed.


Sign In or Register to comment.