user42205: I have the following code as part of my efforts to clean this all up into more neatly organised functions.
I'm trying to run GetTemperatures and RunSerial as part of the main loop, however neither are being called.
If I uncomment the two code blocks I've tried to migrate into the functions in the main loop and comment out the calling of those two new functions, everything works ok.
I've looked through the arduino documentation and other places online but I'm unable to see where I've gone wrong.
#include <OneWire.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

//#include <DallasTemperature.h>

const char* ssid = "ssid";
const char* password = "password";


//This sketch is for Wemos R1 not Arduino
//Pin Assignment
OneWire  ds(D6);

//Digital Pin 4 Fan PWM pins)
int FanPin = D7; //Pin 4
int FanPWM = 0; //Start fans at max speed
int FanPercent = 100; // PWM power %

//Temperature thresholds

int Set0PCTemp = 26;   // Temp for 0% fan speed
//int MidTemp = 30;   // Max Temp for Min & Min Temp for Max
int Set100PCTemp = 36;   // Temp for 100% fan speed

// Temperature measurements

float MeasTemp;       //Measured temperature value
float DStemp;         //Value extracted from DS18B20 Sensor

// Serial port input values
int In0PCTemp;
int In100PCTemp;


ESP8266WebServer server(80);

void setup(void) 
  {
  //analogWriteFreq(25000);
  pinMode(FanPin, OUTPUT);
  analogWrite(FanPin, 128);
  delay(1000);
  Serial.begin(9600);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED)
    {
    delay(500);
    Serial.print(".");
    }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  if (MDNS.begin("esp8266"))
    {
    Serial.println("MDNS responder started");
    }
    server.on("/", handleRoot);
    server.on("/inline", []()
      {
      server.send(200, "text/plain", "this works as well");
      }
              );
    server.onNotFound(handleNotFound);
    server.begin();
    Serial.println("HTTP server started");
    //wifi end
    }

void handleRoot()
  {
  //declare CSV variables
  String CSVHeaders = "Set0PCTemp,Set100PCTemp,MeasTemp,FanPercent,FanPWM";
  String CSVMessage = "";
  String CSVPayload = "";
  //  Compile CSV variables
  //CSVMessage = Set0PCTemp + "," + Set100PCTemp + "," + MeasTemp + "," + FanPercent + "," + FanPWM;
  CSVMessage += Set0PCTemp;
  CSVMessage += ",";
  CSVMessage += Set100PCTemp;
  CSVMessage += ",";
  CSVMessage += MeasTemp;
  CSVMessage += ",";
  CSVMessage += FanPercent;
  CSVMessage += ",";
  CSVMessage += FanPWM; 
  CSVPayload = CSVHeaders;
  CSVPayload += "\n";
  CSVPayload += CSVMessage;
  //  char CSV_Payload[] = CSVPayload;
  //notify serial port of HTTP request
  Serial.println( "Sending Readings");
  Serial.println(CSVPayload);
  server.send(200, "text/plain", CSVPayload);
  }

void handleNotFound()
  {
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++)
    {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
    }
  server.send(404, "text/plain", message);
  }

void GetTemperature ()
  {
    Serial.println("step1");
  //original
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float DStemp;
  //////
  if ( !ds.search(addr)) 
    {
    Serial.println("step2");
    ds.reset_search();
    delay(250);
    return;
    } 
  if (OneWire::crc8(addr, 7) != addr[7]) 
    {
    Serial.println("CRC is not valid!");
    return;
    }
    // the first ROM byte indicates which chip
    switch (addr[0]) 
      {
      case 0x10:
      type_s = 1;
      break;
      case 0x28:
      type_s = 0;
      break;
      case 0x22:
      type_s = 0;
      break;
      default:
      Serial.println("Device is not a DS18x20 family device.");
      return;
      }
    Serial.println("step3");
    ds.reset();
    ds.select(addr);
    ds.write(0x44, 1);        // start conversion, with parasite power on at the end  
    delay(1000);
    present = ds.reset();
    ds.select(addr);    
    ds.write(0xBE);         // Read Scratchpad
    for ( i = 0; i < 9; i++) 
      {           
      data[i] = ds.read();
      }
    // Convert the data to actual temperature
    int16_t raw = (data[1] << 8) | data[0];
    if (type_s)
      {
      raw = raw << 3; // 9 bit resolution default
      if (data[7] == 0x10) 
        {
        raw = (raw & 0xFFF0) + 12 - data[6];
        }
      } 
    else 
      {
      byte cfg = (data[4] & 0x60);
      if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
      else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
      else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
      }
  DStemp = (float)raw / 16.0;
  }

void RunSerial()
  {
        Serial.print(Set0PCTemp);
    Serial.print(",");
    Serial.print(Set100PCTemp);
    Serial.print(",");
    Serial.print(DStemp);
    Serial.print(",");
    MeasTemp = DStemp;
    //control fan speed
    //if(MeasTemp < Set0PCTemp) 
     //{ 
     // if temp is lower than minimum temp
       //FanPWM = map(DStemp, Set0PCTemp, Set100PCTemp, 255, 0); // the actual speed of fan
       FanPWM = map(DStemp, Set0PCTemp, Set100PCTemp, 1023, 0); // the actual speed of fan
       //FanPWM = constrain(FanPWM, 0, 255);
       FanPWM = constrain(FanPWM, 0, 1023);
       analogWrite(FanPin, FanPWM);  // spin the fan at the fanSpeed speed
       //FanPercent = map(FanPWM,0,255,100,0);
       FanPercent = map(FanPWM,0,1023,100,0);
       Serial.print(FanPercent);   
       Serial.print(",");
       Serial.println(FanPWM);   
       //Serial.println(CSVMessage);
       //} 
       //take temperature threshold input
      while (Serial.available() > 0)
        {
        int In0PCTemp = Serial.parseInt();
        int In100PCTemp = Serial.parseInt();
        if (Serial.read() == '\n')
          {
          In0PCTemp = constrain(In0PCTemp, 20, 35);
          In100PCTemp = constrain(In100PCTemp, 35, 50);
          Serial.print("Min=");
          Serial.print(In0PCTemp);
          Serial.print(",");
          Serial.print("Max=");
          Serial.print(In100PCTemp);
          Serial.println();  
          Set0PCTemp = In0PCTemp;
          Set100PCTemp = In100PCTemp;
          }
      }
  }

void loop(void) 
  {
    GetTemperature;
  //start of GetTemperature content
  /*
  Serial.println("step1");
  //original
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float DStemp;
  //////
  if ( !ds.search(addr)) 
    {
    Serial.println("step2");
    ds.reset_search();
    delay(250);
    return;
    } 
  if (OneWire::crc8(addr, 7) != addr[7]) 
    {
    Serial.println("CRC is not valid!");
    return;
    }
    // the first ROM byte indicates which chip
    switch (addr[0]) 
      {
      case 0x10:
      type_s = 1;
      break;
      case 0x28:
      type_s = 0;
      break;
      case 0x22:
      type_s = 0;
      break;
      default:
      Serial.println("Device is not a DS18x20 family device.");
      return;
      }
    Serial.println("step3");
    ds.reset();
    ds.select(addr);
    ds.write(0x44, 1);        // start conversion, with parasite power on at the end  
    delay(1000);
    present = ds.reset();
    ds.select(addr);    
    ds.write(0xBE);         // Read Scratchpad
    for ( i = 0; i < 9; i++) 
      {           
      data[i] = ds.read();
      }
    // Convert the data to actual temperature
    int16_t raw = (data[1] << 8) | data[0];
    if (type_s)
      {
      raw = raw << 3; // 9 bit resolution default
      if (data[7] == 0x10) 
        {
        raw = (raw & 0xFFF0) + 12 - data[6];
        }
      } 
    else 
      {
      byte cfg = (data[4] & 0x60);
      if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
      else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
      else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
      }

    //Display current values
    DStemp = (float)raw / 16.0;
    */
    //end of GetTemperature content
    RunSerial;
    //start of RunSerial content
    /*
    Serial.print(Set0PCTemp);
    Serial.print(",");
    Serial.print(Set100PCTemp);
    Serial.print(",");
    Serial.print(DStemp);
    Serial.print(",");
    MeasTemp = DStemp;
    //control fan speed
    //if(MeasTemp < Set0PCTemp) 
     //{ 
     // if temp is lower than minimum temp
       //FanPWM = map(DStemp, Set0PCTemp, Set100PCTemp, 255, 0); // the actual speed of fan
       FanPWM = map(DStemp, Set0PCTemp, Set100PCTemp, 1023, 0); // the actual speed of fan
       //FanPWM = constrain(FanPWM, 0, 255);
       FanPWM = constrain(FanPWM, 0, 1023);
       analogWrite(FanPin, FanPWM);  // spin the fan at the fanSpeed speed
       //FanPercent = map(FanPWM,0,255,100,0);
       FanPercent = map(FanPWM,0,1023,100,0);
       Serial.print(FanPercent);   
       Serial.print(",");
       Serial.println(FanPWM);   
       //Serial.println(CSVMessage);
       //} 
       //take temperature threshold input
      while (Serial.available() > 0)
        {
        int In0PCTemp = Serial.parseInt();
        int In100PCTemp = Serial.parseInt();
        if (Serial.read() == '\n')
          {
          In0PCTemp = constrain(In0PCTemp, 20, 35);
          In100PCTemp = constrain(In100PCTemp, 35, 50);
          Serial.print("Min=");
          Serial.print(In0PCTemp);
          Serial.print(",");
          Serial.print("Max=");
          Serial.print(In100PCTemp);
          Serial.println();  
          Set0PCTemp = In0PCTemp;
          Set100PCTemp = In100PCTemp;
          }
      }
      */
      //end of RunSerial content
      //wifi
      server.handleClient();
  }


user359: RunSerial;

that does not call the function. Instead you should do 
RunSerial();

same with GetTemperature

42205: <p>I have the following code as part of my efforts to clean this all up into more neatly organised functions.</p>

<p>I'm trying to run GetTemperatures and RunSerial as part of the main loop, however neither are being called.</p>

<p>If I uncomment the two code blocks I've tried to migrate into the functions in the main loop and comment out the calling of those two new functions, everything works ok.</p>

<p>I've looked through the arduino documentation and other places online but I'm unable to see where I've gone wrong.</p>

<pre><code>#include &lt;OneWire.h&gt;
#include &lt;ESP8266WiFi.h&gt;
#include &lt;WiFiClient.h&gt;
#include &lt;ESP8266WebServer.h&gt;
#include &lt;ESP8266mDNS.h&gt;

//#include &lt;DallasTemperature.h&gt;

const char* ssid = "ssid";
const char* password = "password";


//This sketch is for Wemos R1 not Arduino
//Pin Assignment
OneWire  ds(D6);

//Digital Pin 4 Fan PWM pins)
int FanPin = D7; //Pin 4
int FanPWM = 0; //Start fans at max speed
int FanPercent = 100; // PWM power %

//Temperature thresholds

int Set0PCTemp = 26;   // Temp for 0% fan speed
//int MidTemp = 30;   // Max Temp for Min &amp; Min Temp for Max
int Set100PCTemp = 36;   // Temp for 100% fan speed

// Temperature measurements

float MeasTemp;       //Measured temperature value
float DStemp;         //Value extracted from DS18B20 Sensor

// Serial port input values
int In0PCTemp;
int In100PCTemp;


ESP8266WebServer server(80);

void setup(void) 
  {
  //analogWriteFreq(25000);
  pinMode(FanPin, OUTPUT);
  analogWrite(FanPin, 128);
  delay(1000);
  Serial.begin(9600);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED)
    {
    delay(500);
    Serial.print(".");
    }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  if (MDNS.begin("esp8266"))
    {
    Serial.println("MDNS responder started");
    }
    server.on("/", handleRoot);
    server.on("/inline", []()
      {
      server.send(200, "text/plain", "this works as well");
      }
              );
    server.onNotFound(handleNotFound);
    server.begin();
    Serial.println("HTTP server started");
    //wifi end
    }

void handleRoot()
  {
  //declare CSV variables
  String CSVHeaders = "Set0PCTemp,Set100PCTemp,MeasTemp,FanPercent,FanPWM";
  String CSVMessage = "";
  String CSVPayload = "";
  //  Compile CSV variables
  //CSVMessage = Set0PCTemp + "," + Set100PCTemp + "," + MeasTemp + "," + FanPercent + "," + FanPWM;
  CSVMessage += Set0PCTemp;
  CSVMessage += ",";
  CSVMessage += Set100PCTemp;
  CSVMessage += ",";
  CSVMessage += MeasTemp;
  CSVMessage += ",";
  CSVMessage += FanPercent;
  CSVMessage += ",";
  CSVMessage += FanPWM; 
  CSVPayload = CSVHeaders;
  CSVPayload += "\n";
  CSVPayload += CSVMessage;
  //  char CSV_Payload[] = CSVPayload;
  //notify serial port of HTTP request
  Serial.println( "Sending Readings");
  Serial.println(CSVPayload);
  server.send(200, "text/plain", CSVPayload);
  }

void handleNotFound()
  {
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i&lt;server.args(); i++)
    {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
    }
  server.send(404, "text/plain", message);
  }

void GetTemperature ()
  {
    Serial.println("step1");
  //original
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float DStemp;
  //////
  if ( !ds.search(addr)) 
    {
    Serial.println("step2");
    ds.reset_search();
    delay(250);
    return;
    } 
  if (OneWire::crc8(addr, 7) != addr[7]) 
    {
    Serial.println("CRC is not valid!");
    return;
    }
    // the first ROM byte indicates which chip
    switch (addr[0]) 
      {
      case 0x10:
      type_s = 1;
      break;
      case 0x28:
      type_s = 0;
      break;
      case 0x22:
      type_s = 0;
      break;
      default:
      Serial.println("Device is not a DS18x20 family device.");
      return;
      }
    Serial.println("step3");
    ds.reset();
    ds.select(addr);
    ds.write(0x44, 1);        // start conversion, with parasite power on at the end  
    delay(1000);
    present = ds.reset();
    ds.select(addr);    
    ds.write(0xBE);         // Read Scratchpad
    for ( i = 0; i &lt; 9; i++) 
      {           
      data[i] = ds.read();
      }
    // Convert the data to actual temperature
    int16_t raw = (data[1] &lt;&lt; 8) | data[0];
    if (type_s)
      {
      raw = raw &lt;&lt; 3; // 9 bit resolution default
      if (data[7] == 0x10) 
        {
        raw = (raw &amp; 0xFFF0) + 12 - data[6];
        }
      } 
    else 
      {
      byte cfg = (data[4] &amp; 0x60);
      if (cfg == 0x00) raw = raw &amp; ~7;  // 9 bit resolution, 93.75 ms
      else if (cfg == 0x20) raw = raw &amp; ~3; // 10 bit res, 187.5 ms
      else if (cfg == 0x40) raw = raw &amp; ~1; // 11 bit res, 375 ms
      }
  DStemp = (float)raw / 16.0;
  }

void RunSerial()
  {
        Serial.print(Set0PCTemp);
    Serial.print(",");
    Serial.print(Set100PCTemp);
    Serial.print(",");
    Serial.print(DStemp);
    Serial.print(",");
    MeasTemp = DStemp;
    //control fan speed
    //if(MeasTemp &lt; Set0PCTemp) 
     //{ 
     // if temp is lower than minimum temp
       //FanPWM = map(DStemp, Set0PCTemp, Set100PCTemp, 255, 0); // the actual speed of fan
       FanPWM = map(DStemp, Set0PCTemp, Set100PCTemp, 1023, 0); // the actual speed of fan
       //FanPWM = constrain(FanPWM, 0, 255);
       FanPWM = constrain(FanPWM, 0, 1023);
       analogWrite(FanPin, FanPWM);  // spin the fan at the fanSpeed speed
       //FanPercent = map(FanPWM,0,255,100,0);
       FanPercent = map(FanPWM,0,1023,100,0);
       Serial.print(FanPercent);   
       Serial.print(",");
       Serial.println(FanPWM);   
       //Serial.println(CSVMessage);
       //} 
       //take temperature threshold input
      while (Serial.available() &gt; 0)
        {
        int In0PCTemp = Serial.parseInt();
        int In100PCTemp = Serial.parseInt();
        if (Serial.read() == '\n')
          {
          In0PCTemp = constrain(In0PCTemp, 20, 35);
          In100PCTemp = constrain(In100PCTemp, 35, 50);
          Serial.print("Min=");
          Serial.print(In0PCTemp);
          Serial.print(",");
          Serial.print("Max=");
          Serial.print(In100PCTemp);
          Serial.println();  
          Set0PCTemp = In0PCTemp;
          Set100PCTemp = In100PCTemp;
          }
      }
  }

void loop(void) 
  {
    GetTemperature;
  //start of GetTemperature content
  /*
  Serial.println("step1");
  //original
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float DStemp;
  //////
  if ( !ds.search(addr)) 
    {
    Serial.println("step2");
    ds.reset_search();
    delay(250);
    return;
    } 
  if (OneWire::crc8(addr, 7) != addr[7]) 
    {
    Serial.println("CRC is not valid!");
    return;
    }
    // the first ROM byte indicates which chip
    switch (addr[0]) 
      {
      case 0x10:
      type_s = 1;
      break;
      case 0x28:
      type_s = 0;
      break;
      case 0x22:
      type_s = 0;
      break;
      default:
      Serial.println("Device is not a DS18x20 family device.");
      return;
      }
    Serial.println("step3");
    ds.reset();
    ds.select(addr);
    ds.write(0x44, 1);        // start conversion, with parasite power on at the end  
    delay(1000);
    present = ds.reset();
    ds.select(addr);    
    ds.write(0xBE);         // Read Scratchpad
    for ( i = 0; i &lt; 9; i++) 
      {           
      data[i] = ds.read();
      }
    // Convert the data to actual temperature
    int16_t raw = (data[1] &lt;&lt; 8) | data[0];
    if (type_s)
      {
      raw = raw &lt;&lt; 3; // 9 bit resolution default
      if (data[7] == 0x10) 
        {
        raw = (raw &amp; 0xFFF0) + 12 - data[6];
        }
      } 
    else 
      {
      byte cfg = (data[4] &amp; 0x60);
      if (cfg == 0x00) raw = raw &amp; ~7;  // 9 bit resolution, 93.75 ms
      else if (cfg == 0x20) raw = raw &amp; ~3; // 10 bit res, 187.5 ms
      else if (cfg == 0x40) raw = raw &amp; ~1; // 11 bit res, 375 ms
      }

    //Display current values
    DStemp = (float)raw / 16.0;
    */
    //end of GetTemperature content
    RunSerial;
    //start of RunSerial content
    /*
    Serial.print(Set0PCTemp);
    Serial.print(",");
    Serial.print(Set100PCTemp);
    Serial.print(",");
    Serial.print(DStemp);
    Serial.print(",");
    MeasTemp = DStemp;
    //control fan speed
    //if(MeasTemp &lt; Set0PCTemp) 
     //{ 
     // if temp is lower than minimum temp
       //FanPWM = map(DStemp, Set0PCTemp, Set100PCTemp, 255, 0); // the actual speed of fan
       FanPWM = map(DStemp, Set0PCTemp, Set100PCTemp, 1023, 0); // the actual speed of fan
       //FanPWM = constrain(FanPWM, 0, 255);
       FanPWM = constrain(FanPWM, 0, 1023);
       analogWrite(FanPin, FanPWM);  // spin the fan at the fanSpeed speed
       //FanPercent = map(FanPWM,0,255,100,0);
       FanPercent = map(FanPWM,0,1023,100,0);
       Serial.print(FanPercent);   
       Serial.print(",");
       Serial.println(FanPWM);   
       //Serial.println(CSVMessage);
       //} 
       //take temperature threshold input
      while (Serial.available() &gt; 0)
        {
        int In0PCTemp = Serial.parseInt();
        int In100PCTemp = Serial.parseInt();
        if (Serial.read() == '\n')
          {
          In0PCTemp = constrain(In0PCTemp, 20, 35);
          In100PCTemp = constrain(In100PCTemp, 35, 50);
          Serial.print("Min=");
          Serial.print(In0PCTemp);
          Serial.print(",");
          Serial.print("Max=");
          Serial.print(In100PCTemp);
          Serial.println();  
          Set0PCTemp = In0PCTemp;
          Set100PCTemp = In100PCTemp;
          }
      }
      */
      //end of RunSerial content
      //wifi
      server.handleClient();
  }
</code></pre>
 359: <pre><code>RunSerial;
</code></pre>

<p>that does not call the function. Instead you should do </p>

<pre><code>RunSerial();
</code></pre>

<p>same with <code>GetTemperature</code></p>
