Measuring the power consumption by a system remotely

I am trying to measure the power consumption for any microcontroller remotely. Right now, I am using a current sensor, but they come with restrictions of their own as they require a certain power supply and not every microcontroller is equipped with a 5V supply. Before that, I used a resistor, but that idea also failed.
All this led me to explore other options for it, other than using a current sensor or a resistor, like BJT or CMOS or any other electronic equipment. Please let me know if you have tried anything or have any valuable advice; I really appreciate your input on the matter.

Very unlikley you will ever be able to 'calculate' the power consumption.

Measure it.

Which Arduino are you using ?

I am using Arduino Uno, along with NodeMCU

You didn't post any details of any of your hardware circuits.

From which one do want to measure the current?

Are you measuring the power consumed by the microcontroller(s) or using the microcontrollers to measure say power consumed be AC mains powered devices or what ?

The hardware circuit consists of a NodeMCU with multiple sensors attached. The basic idea is to measure the power required by the whole circuit. I was first doing this using an ammeter. But as I mentioned, the power needs to be measured remotely.

I am measuring the power consumed by the microcontroller which has various sensors attached to it.

It's still not clear whether your question is about measuring the current, or transmitting it to a host or server.

The normal case of a remote measurement is to measure the battery voltage and send that back for maintenance purposes i.e. battery replacement. A remote measurement of the devices own current consumption sounds odd .

Both actually. The requirement is measuring the current consumed by the microcontroller (attached to various sensors), measuring the power consumption of the whole circuit using that current value, and sending it to the client via WiFi.
Basically, designing a system that tells battery percentage. That can be done by calculating the power consumed and alerting the client when it falls below a predefined percentage. I hope this is clear now.

I've tried measuring power to monitor my solar powered system what I found is that the components that are required to measure current wastes battery power.

I found by measuring the Vbat, transmitting the Vbatt once a minute, and plotting Vbatt was the most effective way to monitor the battery conditions.


I've shown one battery being monitored once a minute and the average of 60 minutes graphs.

By using a mosfet to prevent current flow through the resistor divider network when not reading Vbatt, power is saved.

The plot starts with from the left to right after 4 days of rain, the charge is low, then the weather clears up, the charge goes higher, then a night of no charge, then the next day the charge goes even higher than the previous day.

The plot on the left holds 36 hours of data, the plot on the right holds 7 days of data. The plot on the left contains 36 hours of info the plot on the left contains 7 days of info.

Did you consider ready-made module with INA219 or similar ?

Could you elaborate on how did you measure the Vbat?

void fReadBattery( void * parameter )
{
  const float r1 = 50500.0f; // R1 in ohm, 50K
  const float r2 = 10000.0f; // R2 in ohm, 10k potentiometer
  const TickType_t xFrequency = 1000; //delay for mS
  float    adcValue = 0.0f;
  float    Vbatt = 0.0f;
  int      printCount = 0;
  float    vRefScale = (3.3f / 4096.0f) * ((r1 + r2) / r2);
  uint64_t TimePastKalman  = esp_timer_get_time(); // used by the Kalman filter UpdateProcessNoise, time since last kalman calculation
  SimpleKalmanFilter KF_ADC_b( 1.0f, 1.0f, .01f );
  TickType_t xLastWakeTime = xTaskGetTickCount();
  for (;;)
  {
    adc1_get_raw(ADC1_CHANNEL_0); //read and discard
    adcValue = float( adc1_get_raw(ADC1_CHANNEL_0) ); //take a raw ADC reading
    KF_ADC_b.setProcessNoise( (esp_timer_get_time() - TimePastKalman) / 1000000.0f ); //get time, in microsecods, since last readings
    adcValue = KF_ADC_b.updateEstimate( adcValue ); // apply simple Kalman filter
    Vbatt = adcValue * vRefScale;
    xSemaphoreTake( sema_CalculatedVoltage, portMAX_DELAY );
    CalculatedVoltage = Vbatt;
    xSemaphoreGive( sema_CalculatedVoltage );
    
      printCount++;
      if ( printCount == 3 )
      {
      //log_i( "Vbatt %f", Vbatt );
      printCount = 0;
      }
    
    TimePastKalman = esp_timer_get_time(); // time of update complete
    xLastWakeTime = xTaskGetTickCount();
    vTaskDelayUntil( &xLastWakeTime, xFrequency );
    //log_i( "fReadBattery %d",  uxTaskGetStackHighWaterMark( NULL ) );
  }
  vTaskDelete( NULL );
}

I did, but the operating voltage range is 3.3V to 5V. I am looking for a current sensor with an operating voltage of 3V (See the start of the thread).

If going solar remember the Isense must allow for 2 way Iflow.

1 Like

This is MCU specific. The ESP8266 has no ADC worth speaking of. For the Uno, Google for "Arduino secret voltmeter"

Thank you for this. How did you measure the Isense then? What device or sensor did you use?

I do not measure Isense now. I only measure V's now. Isense was a waste of time and power. I used an off the self Isense module. Just do a search for "arduino current sensor module" and you'll find one.