user56717: I cannot understand the code of controlling the speed of brushless dc motor using ESP8266 WiFi Module.
I found it in- https://ubidots.com/blog/speed-control-for-brushless-motors-with-an-esp8266-2/
The part that I cannot understand is-

float btof(byte * payload, unsigned int length) {

  char * demo = (char *) malloc(sizeof(char) * 10);

  for (int i = 0; i < length; i++) {

    demo[i] = payload[i];

  }

float value = atof(demo);

  free(demo);

  return value;
}

// Callback to handle subscription

void callback(char* topic, byte* payload, unsigned int length) 

{

    value = btof(payload, length);

      value = map(value, 0, 1023, 0, 180); 

//Map the 0-100 values from the slider to the 0-180 to use the servo lib.

 ESC.write(value); 

//Send the value (PWM) to the ESC

}

Please help me with the code!

user55239: 
Callback function must be data send from server to the ESP.
Payload is the data byte sent from server.
Length is the size of data in bytes.
BTOF is basically byte to float converter which converts all the data byte received into single floating variable and return that floating point value.
ECS.write must be the function that write the value to the servo motor controller H-bridge IC. It belongs to servo library.
Value range that can be mapped into this ECS.write is between 0-180 so map function will use that will convert the floating point data received from btof function.
Basic definition of map() function: 

Map function maps a number from one range to another. That is, a value of fromLow would get mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-between, etc.
Does not constrain values to within the range, because out-of-range values are sometimes intended and useful. The constrain() function may be used either before or after this function, if limits to the ranges are desired.
Note that the "lower bounds" of either range may be larger or smaller than the "upper bounds" so the map() function may be used to reverse a range of numbers.
Syntax:
map(value, fromLow, fromHigh, toLow, toHigh)

Then ECS.write(value) will write that mapped value to servor motor controller H-Bridge.

56717: <p>I cannot understand the code of controlling the speed of brushless dc motor using ESP8266 WiFi Module.</p>

<p>I found it in- <a href="https://ubidots.com/blog/speed-control-for-brushless-motors-with-an-esp8266-2/" rel="nofollow noreferrer">https://ubidots.com/blog/speed-control-for-brushless-motors-with-an-esp8266-2/</a></p>

<p>The part that I cannot understand is-</p>

<pre><code>
float btof(byte * payload, unsigned int length) {

  char * demo = (char *) malloc(sizeof(char) * 10);

  for (int i = 0; i &lt; length; i++) {

    demo[i] = payload[i];

  }

float value = atof(demo);

  free(demo);

  return value;
}

// Callback to handle subscription

void callback(char* topic, byte* payload, unsigned int length) 

{

    value = btof(payload, length);

      value = map(value, 0, 1023, 0, 180); 

//Map the 0-100 values from the slider to the 0-180 to use the servo lib.

 ESC.write(value); 

//Send the value (PWM) to the ESC

}
</code></pre>

<p>Please help me with the code!</p>
 55239: <ol>
<li><code>Callback function</code> must be data send from server to the ESP.</li>
<li><code>Payload</code> is the data byte sent from server.</li>
<li><code>Length</code> is the size of data in bytes.</li>
<li><code>BTOF</code> is basically byte to float converter which converts all the data byte received into single floating variable and return that floating point value.</li>
<li><code>ECS.write</code> must be the function that write the value to the servo motor controller H-bridge IC. It belongs to servo library.</li>
<li>Value range that can be mapped into this ECS.write is between 0-180 so <code>map</code> function will use that will convert the <code>floating point data</code> received from <code>btof</code> function.</li>
<li>Basic definition of <code>map()</code> function: </li>
</ol>

<p><code>Map function</code> maps a number from one range to another. That is, a value of fromLow would get mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-between, etc.</p>

<p>Does not constrain values to within the range, because out-of-range values are sometimes intended and useful. The constrain() function may be used either before or after this function, if limits to the ranges are desired.</p>

<p>Note that the "lower bounds" of either range may be larger or smaller than the "upper bounds" so the map() function may be used to reverse a range of numbers.</p>

<p>Syntax:</p>

<pre><code>map(value, fromLow, fromHigh, toLow, toHigh)
</code></pre>

<p>Then <code>ECS.write(value)</code> will write that mapped value to servor motor controller H-Bridge.</p>
