'peviousMillis' was not declared in this scope

hi there,i have problem in my code program.i try to make an esp32 as a receiver data from arduino uno and i put two sensor (dht22 and LDR sensor)that i connected in esp32.and display all sensor value on oled display. but my program is not finished, and when i run the problem like this appears. when i add millis() to the program.


this error ive showing below:

"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\ridho\AppData\Local\Temp\arduino_build_754163\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\Users\ridho\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10812 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\ridho\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\cores\arduino" "-IC:\Users\ridho\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\variants\standard" "-IC:\Users\ridho\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries\Wire\src" "-IC:\Users\ridho\Documents\Arduino\libraries\arduino_696289" "-IC:\Users\ridho\Documents\Arduino\libraries\Adafruit_SSD1306" "-IC:\Users\ridho\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries\SPI\src" "-IC:\Users\ridho\Documents\Arduino\libraries\Adafruit_Unified_Sensor" "-IC:\Users\ridho\Documents\Arduino\libraries\DHT_sensor_library" "-IC:\Users\ridho\Documents\Arduino\libraries\Adafruit_BusIO" "C:\Users\ridho\AppData\Local\Temp\arduino_build_754163\sketch\main_eps32.ino.cpp" -o "C:\Users\ridho\AppData\Local\Temp\arduino_build_754163\sketch\main_eps32.ino.cpp.o"
C:\Users\ridho\Documents\sppa\PROGRAM FINAL\MENTAH\main_eps32\main_eps32.ino: In function 'void loop()':

main_eps32:62:7: error: 'peviousMillis' was not declared in this scope

   peviousMillis = currentMillis;

   ^~~~~~~~~~~~~

C:\Users\ridho\Documents\sppa\PROGRAM FINAL\MENTAH\main_eps32\main_eps32.ino:62:7: note: suggested alternative: 'previousMillis'

   peviousMillis = currentMillis;

   ^~~~~~~~~~~~~

   previousMillis

main_eps32:66:13: error: 'DataSerial' was not declared in this scope

   while(DataSerial.available()>0)

         ^~~~~~~~~~

C:\Users\ridho\Documents\sppa\PROGRAM FINAL\MENTAH\main_eps32\main_eps32.ino:66:13: note: suggested alternative: 'Serial'

   while(DataSerial.available()>0)

         ^~~~~~~~~~

         Serial

main_eps32:113:3: error: 'DataSerial' was not declared in this scope

DataSerial.println("Ya");

^~~~~~~~~~

C:\Users\ridho\Documents\sppa\PROGRAM FINAL\MENTAH\main_eps32\main_eps32.ino:113:3: note: suggested alternative: 'Serial'

DataSerial.println("Ya");

^~~~~~~~~~

Serial

Multiple libraries were found for "Adafruit_SSD1306.h"
Used: C:\Users\ridho\Documents\Arduino\libraries\Adafruit_SSD1306
Not used: C:\Users\ridho\Documents\Arduino\libraries\Adafruit_SSD1306_Wemos_Mini_OLED
Not used: C:\Users\ridho\Documents\Arduino\libraries\Adafruit_SSD1306-master
Using library Wire at version 1.0 in folder: C:\Users\ridho\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries\Wire
Using library arduino_696289 at version 1.10.10 in folder: C:\Users\ridho\Documents\Arduino\libraries\arduino_696289
Using library Adafruit_SSD1306 at version 2.4.4 in folder: C:\Users\ridho\Documents\Arduino\libraries\Adafruit_SSD1306
Using library SPI at version 1.0 in folder: C:\Users\ridho\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries\SPI
Using library Adafruit_Unified_Sensor at version 1.1.4 in folder: C:\Users\ridho\Documents\Arduino\libraries\Adafruit_Unified_Sensor
Using library DHT_sensor_library at version 1.4.2 in folder: C:\Users\ridho\Documents\Arduino\libraries\DHT_sensor_library
Using library Adafruit_BusIO at version 1.7.2 in folder: C:\Users\ridho\Documents\Arduino\libraries\Adafruit_BusIO
exit status 1
'peviousMillis' was not declared in this scope

and this is my code:

#include <Wire.h>
#include<Adafruit_GFX.h>
#include<Adafruit_SSD1306.h>
#include <Adafruit_Sensor.h>
#include<DHT.h>
#define RXD2 16 //serial comunication uart RX 
#define TXD2 17 //TX serial comunication uart

#define SCREEN_WIDTH 128 //oled display widht,in pixel
#define SCREEN_HEIGHT 64 //oled display height,in pixel
//declaration for an SSD1306 display connected to i2c (sda,scl pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

#define DHTPIN 15 //DIGITAL pin connected to the DHT sensor
#define DHTTYPE DHT22
DHT dht(DHTPIN,DHTTYPE);

//millis as changer delay
unsigned long previousMillis =0; //detect last time checking
//the different of millis and delay is when millis running the data couldnt be stoped,while delay will stoped.
const long interval = 3000;

String arrData[6]; //because the amouunt of data is 7
//cosntants for the pins where sensors are plugged into.
const int sensorPin = 2;
const int ledPin = 5;

//Set up some global variables for the light level an initial value.
int lightInit;  // initial value
int lightVal;   // light reading

void setup() {
  //ldr sensor
  // We'll set up the LED pin to be an output.
  pinMode(ledPin, OUTPUT);
  lightInit = analogRead(sensorPin);
  //we will take a single reading from the light sensor and store it in the lightCal
  
 Serial.begin(9600);
 dht.begin();

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000);
  display.clearDisplay();
  display.setTextColor(WHITE);

}

void loop() {
  //ldr 
  LDR();
  //milis configuration

  unsigned long currentMillis = millis(); //read millis time (in mili seocnd)
  
  if (currentMillis - previousMillis >= interval) //if program has not reached 3 second,then the program will skipped
    {
      //update previous milllis
      peviousMillis = currentMillis;
      //priority reading data from arduino uno (the result data sending)
      //read the data serial
      String data ="";
      while(DataSerial.available()>0)
      {
        data += char(DataSerial.read());
      }
      //remove data space
      data.trim();

      /*try arduino data if arduino sending empty data it will be ignored.
       if it is not empty then data formad will  be "10#29.34#9845"
      */
      //then parsing the data
      //after parsing the data we need array

      int index =0;
      for (int i=0; i<=data.length();i++)
      {
        char delimiter = '#';//because using arr so the sign is ('')
        if (data[i] != delimiter)
          arrData[index]  += data[i];

        else
          index++;  //index variabel increase 1
      }
      // make sure the data sent is complete (LDR, temp, hum)
      //the order is 0=voltage, 1=pedal torque, 2=RPM motor ,3=current,4=pwm motor,5=pedal count
      if (index == 2)
      {
        //we display sensor value to serial monitor
        Serial.println(arrData[0]);//voltage
        Serial.println(arrData[1]); //torque pedal
        Serial.println(arrData[2]); //speed(rpm motor)
        Serial.println(arrData[3]); //current
        Serial.println(arrData[4]); //pwm motor
        Serial.println(arrData[5]); //pedal count
        
        Serial.println();//space command
      }
      
      arrData[0] = "";//this is left blank otherwise it will add continuously
      arrData[1] = "";
      arrData[2] = "";
      arrData[3] = "";
      arrData[4] = "";
      arrData[5] = "";
      
    }
    //request data to arduino uno 
  DataSerial.println("Ya");
  TemperatureHumidity();
}

void TemperatureHumidity(){
   delay(5000);

  //read temperature and humidity
  float t = dht.readTemperature();
  float h = dht.readHumidity();
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
  }
  // clear display
  display.clearDisplay();
  
  // display temperature
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("Temperature: ");
  display.setTextSize(2);
  display.setCursor(0,10);
  display.print(t);
  display.print(" ");
  display.setTextSize(1);
  display.cp437(true);
  display.write(167);
  display.setTextSize(2);
  display.print("C");
  
  // display humidity
  display.setTextSize(1);
  display.setCursor(0, 35);
  display.print("Humidity: ");
  display.setTextSize(2);
  display.setCursor(0, 45);
  display.print(h);
  display.print(" %"); 
  
  display.display(); 
}

void LDR(){
  lightVal = analogRead(sensorPin); // read the current light levels

  //if lightVal is less than our initial reading withing a threshold then it is dark.
  if(lightVal - lightInit <  50)
  {
      digitalWrite (ledPin, HIGH); // turn on light
  }

  //otherwise, it is bright
  else
  {
    digitalWrite (ledPin, LOW); // turn off light
  }
}

Hello
Well, I thing this a typing error.

oh my GOD....thanks wkwwkwk....why i dont see....??? :rofl: :rofl: :rofl: :rofl: :rofl: :joy: :joy:

**hand over a pair of glasses **