Servo current and voltage measurement

Hi everyone, I am trying to measure the current and voltage of my servo simultaneously with an esp32 devkit while powering everything with breadboard power supply module. I have a voltage sensor module and acs712 current sensor module. I couldnt manage to make the diagram because of esp32 but I may try to draw what I did. I am not sure if I did the wiring correct and also I am not sure how to add the voltage sensor as well( I think just paralleling it to power source should do it but still not sure). Also for servo and current measuring I used this code but I do not think it works, I would be happy if you can help me with both situations and I can answer if there is anything that I did not explain clearly. Also sorry for unclear posting.

This is the code:

#include <Servo.h>

#define SERVO_PIN 13
#define CURRENT_PIN 14

Servo servoMotor;

void setup() {
  servoMotor.attach(SERVO_PIN);
}

void loop() {
  int adc = analogRead(CURRENT_PIN);
  float voltage = adc*5/1023.0;
  float current = (voltage-2.5)/0.100;
  Serial.print("Current : ");
  Serial.println(current);

  for (int pos = 0; pos <= 180; pos += 1) {
   
    servoMotor.write(pos);
    delay(15);
  }

  for (int pos = 180; pos >= 0; pos -= 1) {
    servoMotor.write(pos);
    delay(15);
  }
}

This is the diagram:

I moved your topic to a more appropriate forum category @ysfblkn.

The Nano ESP32 category you chose is only used for discussions directly related to the Arduino Nano ESP32 board.

In the future, please take the time to pick the forum category that best suits the subject of your question. There is an "About the _____ category" topic at the top of each category that explains its purpose.

Thanks in advance for your cooperation.

1 Like

It is not a good idea for a servo and an MCU to share a power supply. Servos inject severe electrical noise into the leads that can damage the MCU. It is better to power them separately.

Check whether the breadboard power supply can even supply the required 1 Ampere start/stall current for small servos, 2.5 Amperes for larger ones.

Finally, breadboards are designed for temporary experiments with low power logic circuits, and cannot handle motor or servo currents. The tracks will burn.

Appreciate the answer, actually I am aware that servo current is too high for breadboard or jumper cables that I use. I just wanted to find the correct wiring for what I want. I forgot that breadboard power supply cannot give more than 1A so I will just use a 5V power source with a higher current rating. But other than these I am trying to figure out how to connect voltage and current sensor and servo at the same time. Thank you!

Are you also aware that the ESP32 is a 3.3V processor, and cannot tolerate voltages higher the 3.3V on any input?

Yes, I am aware of that. I meant it for the servo.

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