The powertrace output is printed in timer ticks.
tx
- the number of ticks the radio has been in transmit mode (ENERGEST_TYPE_TRANSMIT
)
rx
- the number of ticks the radio has been in receive mode (ENERGEST_TYPE_LISTEN
)
cpu
- the number of ticks the CPU has been in active mode (ENERGEST_TYPE_CPU
)
cpu_idle
- the number of ticks the CPU has been in idle mode (ENERGEST_TYPE_LPM
)
The elements of the pair tx
and rx
are exclusive, as are cpu
and idle
- the system can never be in both modes at the same time. However, other combinations are possible: it can be in cpu
and in tx
at the same time, for example. The sum of cpu
and idle
is the total uptime of the system.
The duration of timer a tick is platform-dependent and defined as the RTIMER_ARCH_SECOND
constant. 32768 ticks per second is a typical value of this constant - that's where the number in your equation comes from. For example:
ticks_in_tx_mode = energest_type_time(ENERGEST_TYPE_TRANSMIT);
seconds_in_tx_mode = ticks_in_tx_mode / RTIMER_ARCH_SECOND;
To compute the average current consumption (in milliamperes, mA), multiply each of tx
, rx
, cpu
, cpu_idle
with the respective current consumption in that mode in mA (obtain the values from the datasheet of the node), sum them up, and divide by RTIMER_ARCH_SECOND
:
current = (tx * current_tx_mode + rx * current_rx_mode + \
cpu * current_cpu + cpu_idle * current_idle) / RTIMER_ARCH_SECOND
To compute the charge (in millicoulumbs, mC), multiply the average current consumption with the duration of the measurement (node's uptime) in seconds:
charge = current * (cpu + cpu_idle) / RTIMER_ARCH_SECOND
To compute the power (in milliwats, mW) multiply the average current consumption with the voltage of the system, for exampe, 3 volts if powered from a pair of AA batteries:
power = current * voltage
Finally, to compute the energy consumption (in millijoules, mJ), multiply the power with the duration in seconds or multiply the charge with the voltage of the system:
energy = charge * voltage
The first formula above computes the energy consumption for communications; the second one: for computation.
This site might be helpful to break down the numbers.