Drone Power module Read current and voltage holybro PM02 V2

Friends I am using holybro PM02 Analog powermodule to extract current and voltage of a brushless motor running on 12S. That is 50Volts and max current is 50A. This analog Power module has output wires like 5V, Current, Voltage and Ground. I connected the analog cables to A0 and A1 to arduino Uno and 5V and Ground. Values started to showup on serial monitor all looks nice. But as soon as I start the motor the serial monitor freezes. I need to close the serial monitor and open again. Since 2 weeks i am struggling on this. Appreciate if any one can put some light on this. Below is the code

// Define the analog pins
const int voltagePin = A0;
const int currentPin = A1;

// Define constants for the PM02D V2
const float voltageDividerRatio = 19.0; // Voltage divider ratio
const float currentSensorSensitivity = 0.0366; // Sensitivity for current sensor in V/A (assuming 36.6 mV/A)

// Reference voltage of the Arduino (usually 5V for most boards)
const float referenceVoltage = 5.0;

// Number of samples to average
const int numSamples = 10;

void setup() {
  Serial.begin(115200);
}

void loop() {
  // Arrays to store the samples
  int voltageSamples[numSamples];
  int currentSamples[numSamples];
  
  // Take multiple samples and average them
  for (int i = 0; i < numSamples; i++) {
    voltageSamples[i] = analogRead(voltagePin);
    currentSamples[i] = analogRead(currentPin);
    delay(10); // Small delay between samples
  }
  
  // Calculate the average
  int avgVoltage = 0;
  int avgCurrent = 0;
  
  for (int i = 0; i < numSamples; i++) {
    avgVoltage += voltageSamples[i];
    avgCurrent += currentSamples[i];
  }
  
  avgVoltage /= numSamples;
  avgCurrent /= numSamples;
  
  // Convert the analog values to voltages
  float voltage = avgVoltage * (referenceVoltage / 1023.0) * voltageDividerRatio;
  float current = (avgCurrent * (referenceVoltage / 1023.0) - 2.5) / currentSensorSensitivity;

  // Print the voltage and current
  Serial.print("Voltage: ");
  Serial.print(voltage);
  Serial.print(" V, Current: ");
  Serial.print(current);
  Serial.println(" A");

  delay(500); // Slow down the loop to prevent freezing
}

You should show your wiring...
Anyway try with 5v wire disconnected, you already power arduino from usb.

1 Like

Have you taken into account the starting surge of that motor? At 5x (conservative) it needs 250 amps, I think that may be the source of your problem. Running it of the USB as @kmin suggested should be tried to validate the code but be sure the grounds are connected at the battery.

1 Like

Let's hope that's for the battery, not for the motor :grimacing:
Powering 2.5kW motor directly from battery needs certain caution...

1 Like

Problem occurs with 5v or without. According to me the ground from the power module is creating problem.



Thanks for your reply. What you are saying is the power module may not be able to takeup the initial load / surge. If i use a clamp meter i dont see any surge in current while motor starts. This is a hobbywing X6 motor.

There is always surge when motor starts, your clamp might be too slow to "see" it.
I can't follow your wiring from pictures. Where are all 6 wires from module going to?

Here is the pin out link of this power module.

Can we supress / isolate the spike. I also tried using 9v power supply to arduino.
I also tried different versions of arduino. When i use arduino mega frequency of this problem is less.

I am ready to use compatible arduino current sensor and voltage sensor. Most sensors not made for 50V and 60A.

Lot of things we can do but the point is that if your motor is powered from battery and arduino from usb and if you have good common ground, there should not be this kind of behavior.
You could verify few things.
Make sure that +5V is not connected and that GND is connected. You could could try the other GND pin from module. Disconnect both analog signal wires from arduino and try if it's working when you start motor..
If yes, connect just one of your analog signal wires and try again.

That is like using a yard/meter stick to measure 1mm. I try to size my power supply at least 10X the motors full rated current when possible.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.