How to wire an ESC to an arduino

Hi!

I am trying to use this ESC link with my arduino mega. But I cannot get a rotor to spin, I have a very small manual and cannot find any information online with google on how to wire it up properly.

I have used Hobby King ESCs before but not a 4in1, I made a guess and wired it like this (I also treid now to wire the Signal #1 cable direcly onto pin 11, but no movement):

And here is the manual:

When it starts up I can here the three beeps from the rotor for the 3 cell battery, so something is working. Then when I try to use this sketch:

#include <Servo.h>

Servo s;

void setup() {
  Serial.begin(9600);

  Serial.println("Startup");

  s.attach(5);
  s.writeMicroseconds(1000);
}

void loop() {
  Serial.println("loop");
  s.writeMicroseconds(1300);

  delay(1000);
}

Thanks in advance!
Best regards Max

I use 4-in-1 and what you are doing is all good.

Did you calibrate the ESC at least on the channel you are using?

See this may help:


Here

  Serial.println("loop");
  s.writeMicroseconds(1300);

just writing the same thing, are you expecting this to make the motor spin slowly? The ESC may itself need to see no throttle before it spins anything; it may need a more elaborate proof of being connected to something it makes sense to obey.

Then writing something like servo sweep does, within the pulse lengths you expect to do anything.

I see your propeller is off, I mention it out loud for anyone else reading. Remove the propellers at this point…

Since it's a BLHeli firmware, you can poke around in there with the BLHeli Configurator. I know you either have done, or will find it easy to do.

I've been getting through some packs lately, not flying any better but I am having fun and ppl who don't know better seem impressed. I hope you are having fun, I hope you are flying some of the time you are putting into this!

a7

How can I calibrate it with the arduino? Tested this sketch out too:

#include <Servo.h>


#define MIN_PULSE_LENGTH 1000 // Minimum pulse length in µs
#define MAX_PULSE_LENGTH 2000 // Maximum pulse length in µs

Servo motA;
char data;


void setup() {
    Serial.begin(9600);
    
    motA.attach(11, MIN_PULSE_LENGTH, MAX_PULSE_LENGTH);

    
    displayInstructions();
}

void loop() {
    if (Serial.available()) {
        data = Serial.read();
        switch (data) {
            case 48 : Serial.println("Sending minimum throttle");
                      motA.writeMicroseconds(MIN_PULSE_LENGTH);
            break;

            case 49 : Serial.println("Sending maximum throttle");
                      motA.writeMicroseconds(MAX_PULSE_LENGTH);
            break;

            case 50 : Serial.print("Running test in 3");
                      delay(1000);
                      Serial.print(" 2");
                      delay(1000);
                      Serial.println(" 1...");
                      delay(1000);
                      test();
            break;
        }
    }
}

void test()
{
    for (int i = MIN_PULSE_LENGTH; i <= MAX_PULSE_LENGTH; i += 5) {
        Serial.print("Pulse length = ");
        Serial.println(i);
        
        motA.writeMicroseconds(i);
        
        delay(200);
    }

    Serial.println("STOP");
    motA.writeMicroseconds(MIN_PULSE_LENGTH);
    
}

void displayInstructions()
{  
    Serial.println("READY - PLEASE SEND INSTRUCTIONS AS FOLLOWING :");
    Serial.println("\t0 : Send min throttle");
    Serial.println("\t1 : Send max throttle");
    Serial.println("\t2 : Run test function\n");
}

But it doesnt spin now at all, I saw now that I have connected my test motor to the #2 instead of #1, my bad, but I tried to use the #2 cable now on my arduino instead but no difference..

last thing I typed firsrt: Ok I read your calibration sketch a bit, seems like the same thing and did not work, so maybe I am out of ideas. Yours makes no mention of when to apply power. Try the one below.

Read the link I posted… there's a small calibration sketch and some hand waving.

#include <Servo.h>

#define MAX_SIGNAL 2000
#define MIN_SIGNAL 1000  // 700 ?
#define MOTOR_PIN 7

Servo motor;

void setup() {
  Serial.begin(9600);
  Serial.println("ESC Calibration Dance.");

  motor.attach(MOTOR_PIN);
}

void loop()
{
  Serial.println("Start (again) the calibrate dance for ESC.");


  Serial.println("Turn OFF power source."); keywait();

  Serial.println("Now writing maximum output.");
  motor.writeMicroseconds(MAX_SIGNAL);
  Serial.println("Turn ON power source."); keywait();
  
  Serial.println("Now to write minimum output"); keywait();
  motor.writeMicroseconds(MIN_SIGNAL);
}

// Wait for human
void keywait()
{
  Serial.println(" So press any key.");

  while (!Serial.available())
    ;
  Serial.read();
}

a7

I kind of got it to work now, so it seems that when I use the Arduino Uno as a BetaFlight some kind of bridge to communicate with the ESC, if I use pins 8+ it both shows up in BetaFlight and works with the Arduino sketch, I have not yet made it work with the Arduino Mega. I made my own JT cable connector and counted wrong on the ammount of pins, so I accidently wired 11.1v to GND, burned up my brand new BNO085 :sweat_smile:

But thank you for your help mr a7

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