Issue measuring battery current consumption on PySense + LoPy4

  • Hi !
    As the title says, I am trying to characterize energy use for a device based on LoPy4 + PySense, powered from a SR674361P 2000mAh 3.7V battery.
    I have tried setting up an ammeter in serial between the positive lead of the battery and the pysense but the voltage drop in creates is enough for the PySense to not power on at all.
    I have tried using a very small 10 ohm resistor instead of the ammeter to see if it had any impact and while the direct battery connexion powers the PySense, the same setup with a tiny 10 ohm resistor in serial does not, even though the voltage drop is completely insignificant (~3.7V at the PySense connector). In this setup, an LED hooked to 3V3_Pymodule on the pysense flashes about 4 times per second so I assume the board is being powered on and off rapidly.
    Am I doing something wrong here ? I don't get why adding such a tiny resistor would prevent the PySense from powering on even though it has an appropriate voltage supplied by the battery?
    Any tips for measuring current consumption with this setup ?

    Thanks in advance !


  • @jcaron Thanks, I will keep that in mind !

  • @IAmTheAlchemist there have been quite a few graphs and measurements posted on the forum a while ago, but it’s always a good thing to do it for your exact setup. Hardware of course has an influence, but even firmware releases or different settings in your code can make a big difference (either in the levels or the durations), so always retest after any change, it can result in significantly altered battery life.

    Remember that even external parameters can have a huge impact: in the case of LoRaWAN, a long RX delay, or a change in data rate, can easily double your power consumption because the LoPy needs to stay awake longer.

  • No problem! Good luck with the measurements!
    Best, Gijs

  • Thanks for your help @Gijs and @jcaron ! I tried using a 1 ohm resistor and plugging it into an oscilloscope, there is quite a bit of activity indeed and some heavy current draw spikes during boot. I will try to export the values and integrate the curve to obtain the total current draw over a cycle of the program.
    Thanks again !

  • @jcaron Thank you for the tip and your explanations, I will try this straight away :)

  • @Gijs Thanks again for your detailed reply :)

    I have already disabled wifi on boot so it should help a bit with that.
    Thanks for the clarification about the capacitor, I will try this way and @jcaron 's tip with the 1 ohm resistor.

    The case with the ammeter is pretty weird, I have two good ones, one on the mA setting and the other one on µA and the mA one simply does nothing (?) and the µA one creates a pretty big voltage drop for some reason, the base voltage i was reffering to is the "stable" voltage between drops and it was definitely under 3V...

    I will keep you updated, thanks again !

  • @IAmTheAlchemist try using a smaller resistor, 1 ohm would be ideal (it has also the advantage of making readings easier, as the value of the voltage measured is exactly the same as that of the current, no conversion needed).

    There are several big current spikes during the boot process, a bit over 200 mA if I remember correctly (depends on the exact xxPy module and firmware version).

    200 mA over a 10 ohm resistor means a 2V drop, which is way too much. Replace that with a 1 ohm resistor and you’re down to 0.2V and all should be well.

  • @IAmTheAlchemist said in Issue measuring battery current consumption on PySense + LoPy4:

    h the ammeter plugged instead of the resistor but this time the LED does not flash, and the measured base voltage is already under 3V, definitely weird...
    How should I plug this capacitor to prevents peaks in current ?
    Thanks in advance !

    Great to hear. Enabling WiFi or other radios will consume a lot of power, causing the high current. Also there are some background processes that will activate intermittently. You can use an electrolytic capacitor between the Vin and GND pins (make sure you get the polarity correct!) This should help with the voltage drops.

    I am not exactly sure what happens in the second case with the ammeter plugged in. What kind of meter are you using? What is the base voltage you are refering to?

    Let me know!

  • @Gijs Hi !
    Thank you for the quick and complete anwser :)
    I have hooked a 10 ohm resistor in series with the battery and measuring the tension on the Pysense input with an oscilloscope and indeed there is a peak where the voltage drops from ~4V to just above 2V every 200ms or so, which I assume is the time needed for some energy-intensive process to happen during boot which explains the flickering at about 5Hz on the 3V3_Pymodule pin !
    The same happens every ~65ms with the ammeter plugged instead of the resistor but this time the LED does not flash, and the measured base voltage is already under 3V, definitely weird...
    How should I plug this capacitor to prevents peaks in current ?
    Thanks in advance !

  • Hi,
    To measure power consumption to your Pycom board, you should be able to use an ammeter. Make sure to set the range correctly (mA and uA generally have larger series resistances, check your meter's manual for this. A quick Google search gives 10mOhm for mA range, and 10 Ohm for uA range, but your results may vary).

    I believe the problem with adding resistance in series (like 10 Ohms) is that the voltage drop increases as the current increases. When the controller needs more power for processing, it will draw more current (As the voltage should stay constant). Now when drawing more current, the voltage drop over the resistor will increase, causing there to be less power delivered and so on..

    You could add a capacitor 1-100uF (does not matter that much) to the board to charge up some energy, preventing the current spikes from reaching the resistance and dropping the voltage.

    Now your measurement techniques are fine otherwise, the problem is that the spikes are probably too fast to measure on a regular multimeter and you would need to check with an oscilloscope.


    80mA peak current draw over 10 Ohms
    = 0.8V drop
    3.7-0.8 = 2.9V (not enough)

    Also, make sure you secure the connections as shorting a Li-ion battery will give sparks :)

    Let me know!

Pycom on Twitter