Nowadays, we are seeing a lot of drones that has an obstacle avoidance and hand control feature, is a toy or video drone. In the background of these products, there are a lot of programming algorithms. But, we could not see or edit these algorithms. Unlikely drone market, ESP8266-Powered Mini Drone: ESPcopter is programmable with Arduino and also is a modular drone. Users can add new features by using expansion shields.


One Of the expansion shields is a multi-ranger shield. Multi-ranger shield has four vl53l0x laser laser-ranging sensor that can measure up to 1000mm the distance and look at the forward, backward, right and left.


The Multi-ranger shield gives lots of exciting new possibilities. One of the features is that you can work with the ESPcopter more without getting into the hardcore control algorithms thanks to the ESPcopter SDK. Some ideas that were published, are:

  • Creating fun applications like airhocky or ping ping where you can play around with the ESPcopter

-Working on algorithms for autonomously driving obstacle courses

Summury Of Arduino Code:

1-) Getting Sensor Value:

   tcaselect(1); 
  int val1Int = sensor1.readRangeSingleMillimeters();

  tcaselect(2); 
  int val2Int = sensor2.readRangeSingleMillimeters();

  tcaselect(3); 
  int val3Int = sensor3.readRangeSingleMillimeters();

  tcaselect(4); 
  int val4Int = sensor4.readRangeSingleMillimeters();

2-) Apply Median Filter:

void bubbleSort(int aray[(5)], int whichOne ) {
    boolean swapped = true;
    int j = 0;
    int tmp;
    while (swapped) {
        swapped = false;
        j++;
        for (int i = 0; i < 5 - j; i++) {
            if (aray[i] > aray[i + 1]) {
                tmp = aray[i];
                aray[i] = aray[i + 1];
                aray[i + 1] = tmp;
                swapped = true;
            }
        }
        if( whichOne == 0){
        for (int i = 0; i < (5) ; i++) {
        valY1[i] = aray[i];
        }}else if(whichOne == 1){
        for (int i = 0; i < (5) ; i++) {
        valX1[i] = aray[i];
        }}else if(whichOne == 2){
        for (int i = 0; i < (5) ; i++) {
        valX0[i] = aray[i];
        }}else if(whichOne == 3){
        for (int i = 0; i < (5) ; i++) {
        valY0[i] = aray[i];
        }}   
    }
}

if(dataValNo < 5){
  valY1[dataValNo] = val1Int;
  valX1[dataValNo] = val2Int;
  valX0[dataValNo] = val4Int;
  valY0[dataValNo] = val3Int;
  dataValNo++;
  }
  
  if(dataValNo == 5){
  bubbleSort(valY1, 0);
  bubbleSort(valX1, 1);
  bubbleSort(valX0, 2);
  bubbleSort(valY0, 3);
  dataValNo=0;
  valY1Med = valY1[2];
  valX1Med = valX1[2];
  valX0Med = valX0[2];
  valY0Med = valY0[2];
  }

3-) Apply Complementary Filter:

int calSensor(int input, int target , int output){
 if((input < multiRange)  &&  (input > 10) ){ // if((val1 < 1200)  &&  (val1 > 10) ){ //  if((valX1Med < 500)  &&  (valX1Med > 10) ){
 // DistanceY = valY1Med;
 int Distanceint = constrain(input,0,multiRange);
 if( output < Distanceint){
 output = output +round((Distanceint - output)/multiAlpha);
 }
 if( output > Distanceint){
 output = output - round((output - Distanceint)/multiAlpha);
 }  
  }else{
  if( output < target){
  output = output + round((target - output)/multiAlphaFree); // (DistanceXint - DistanceX)/2
  }
  if( output > target){
  output = output - round((output - target)/multiAlphaFree);
  }
  }
  return output;
  }

4-) Apply PID Algorithms:

  xMulti.compute(6,targetMultiX1,throttle,0,0,DistanceX1);
  yMulti.compute(7,targetMultiY1,throttle,0,0,DistanceY1);
  
  xMultiM.compute(6,targetMultiX0,throttle,0,0,DistanceX0);
  yMultiM.compute(7,targetMultiY0,throttle,0,0,DistanceY0);


ESPcopter is currently crowdfunding, with differing reward levels available depending on the expansion boards and quantity desired.