I'm trying to use `millis` because I need to run several loops function at the same time. One to get GPS and temperature value then send every value to user's phone number when a request received, and another to display those value on OLED. But my functions seem to be blocking each other even though I have been using `millis`. This is my code:

**initializing**

```
#include<TinyGPS++.h>
#include <SoftwareSerial.h>
#include "DHT.h"

#include <Adafruit_ssd1306syp.h>                        
Adafruit_ssd1306syp display(A4,A5);                  

//dht
#define DHTPIN 5
#define DHTTYPE DHT11
//gps
const double Home_LAT = -6.1887;                     
const double Home_LNG = 106.7;
float glatitude;
float glongitude;
//sms  
char ReceivedSms;
short DHT_OK=-1, GPS_OK=-1;
String DataSms;
//dht
int nilaiSuhu;
int nilaiKelembaban;
//millis
unsigned long counting_millis;
unsigned long millis_now;
const unsigned long delay_val = 2000;
const unsigned long delay_val2 = 1000;

TinyGPSPlus gps;
DHT dht(DHTPIN, DHTTYPE);
SoftwareSerial sim800l(2,3);

```

**void setup**

```
void setup(){

  sim800l.begin(9600);
  Serial.begin(9600);
  dht.begin();
  Serial.println("Starting..");
  delay(7000);
  ReceiveMode();

  display.initialize();                                  
  display.clear();                                      

}

```

**void loop**

```
void loop() {

  millis_now = millis();

  if(millis_now - counting_millis > delay_val)
  {
    oled_Display();
    counting_millis = millis_now;

  }

  if(millis_now - counting_millis > delay_val2){
    mergeFunction();
    counting_millis = millis_now;
  }

}

```

*oled\_Display()* is a function for displaying every value on OLED

```
void oled_Display() {

      display.clear();
      display.setCursor(0,0); 

      float nilaiSuhu = dht.readTemperature();
      float nilaiKelembaban = dht.readHumidity();

      display.print("Suhu      : ");
      display.println(nilaiSuhu);
      display.print("Kelembaban: ");
      display.println(nilaiKelembaban);
      display.print("Latitude  : ");
      display.println(gps.location.lat(), 5);
      display.print("Longitude : ");
      display.println(gps.location.lng(), 4);
      display.print("Satellites: ");
      display.println(gps.satellites.value());
      display.print("Speed     : ");
      display.println(gps.speed.mph());

      unsigned long Distance_To_Home = (unsigned long)TinyGPSPlus::distanceBetween(gps.location.lat(),gps.location.lng(),Home_LAT, Home_LNG);
      display.print("KM asal   :");                        // Have TinyGPS Calculate distance to home and display it
      display.print(Distance_To_Home);
      display.update();                                       
}

```

*mergeFunction()* is a function to get GPS and temperature value, and send it to user based on request.

```
void mergeFunction(){

   nilaiSuhu = dht.readTemperature();
   nilaiKelembaban = dht.readHumidity();
   String RSMS;

    while(sim800l.available() > 0) {
      ReceivedSms = sim800l.read();
      Serial.print(ReceivedSms);
      RSMS.concat(ReceivedSms);
      DHT_OK = RSMS.indexOf("Suhu");
      GPS_OK = RSMS.indexOf("All");

    }

     while(Serial.available() > 0){
      if(gps.encode(Serial.read()))
        readGPS();

    }

    if(DHT_OK!=-1){
      Serial.println("DHT found");

      Serial.print("Temperature = ");
      Serial.print(nilaiSuhu);
      Serial.print("*C      Humidity = ");
      Serial.print(nilaiKelembaban); 
      Serial.println(" %");

      DataSms = "DHT11\nSuhu = "+String(nilaiSuhu,1)+" C"+" \nKelembaban ="+String(nilaiKelembaban,1)+" %";

      SendData();
      ReceiveMode(); 

      DHT_OK=-1; 
    }

    if(gps.location.isValid())
    { 
        glatitude = gps.location.lat();
        glongitude = gps.location.lng();

        String link = "http://www.google.com/maps/place/" + String(glatitude,6) + "," + String(glongitude,6);

        DataSms = "ALL\nSuhu = "+String(nilaiSuhu,1)+" C"+" \nKelembaban ="+String(nilaiKelembaban,1)+" %"+" \nMaps = "+link;
        if(GPS_OK!=-1)
        {
        SendData();
        ReceiveMode();
        GPS_OK = -1;
        } 
    } 
    else
    {
        if(GPS_OK!=-1)
        {
        DataSms = "ALL\nSuhu = "+String(nilaiSuhu,1)+" C"+" \nKelembaban ="+String(nilaiKelembaban,1)+" %"+" \nMaps = "+"Lokasi tidak ditemukan";
        SendData();
        ReceiveMode();
        GPS_OK = -1;
        } 
    }

}

```

Both of those function are working perfectly when they are not running at the same time. I don't know why both of my function are blocking each other when they are running at the same time even though I have been using `millis`. What is the proper way to run Arduino multitasking? Enlighten me.