2

I would like to know if there is a programmatic way of measuring the energy consumption of a sketch or at least if this is possible via external devices.

My aim is to compare the energy consumption of two devices, connected to usb, running slightly modified versions of the same sketch e.g., one using crypto and one without using crypto.

dr.doom
  • 121
  • 1
  • 1
    Are you only interested in that, or do you really want to reduce power ? For example with a battery operated Arduino ? For a ATmega328P as a bare-bone Arduino, the actual code does not make the difference, but the sleep mode (there are a number of different sleep modes) does and of course how long the Arduino is busy between sleeping is important, and also the clock speed. Without sleep mode, it does not matter what code the Arduino is running. – Jot Jul 26 '17 at 22:08
  • use something like this one with time counters, or the simpler and cheaper spot-reading USB meters – dandavis Jul 27 '17 at 03:17
  • @user35247 Not a duplicate. Your link is about using an Arduino to measure the consumption of other things, this is about measuring the consumption of an Arduino. Though as already pointed out, there's not much variation to measure until the software starts playing with hardware features beyond merely running code. – Chris Stratton Jul 29 '17 at 05:52

1 Answers1

0

programmatic way of measuring t

Not sure what you meant by that but typically you can use a high side current sense amplifier to get a measurement of the current. Then adv a known voltage to get vcc. That known voltage could be the internal reference, if available

In some cases a resistor on vcc can be used to measure current, together with two dividers.

dannyf
  • 2,770
  • 10
  • 13