Code stop to run if don't find wifi (mega & esp-01)

hello everyone
my project work fine if WiFi signal is available
i want it too work with or without WiFi signal
i tried every solution i found in the forum and didn’t work

I’m using arduino mega with esp-01

here’s my code

#include <Wire.h>

#include <Adafruit_MLX90614.h>

#include "max32664.h"

#define RESET_PIN 04

#define MFIO_PIN 02

#define RAWDATA_BUFFLEN 250

#define BLYNK_TEMPLATE_ID "************"

#define BLYNK_DEVICE_NAME "**************"

#define BLYNK_AUTH_TOKEN "****************"

// Send Blynk user messages to the hardware serial port…

#define BLYNK_PRINT Serial1

#include <ESP8266_Lib.h>

#include <BlynkSimpleShieldEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "*********";

char pass[] = "*********";

// Hardware Serial on Mega, Leonardo, Micro...

#define EspSerial Serial1

// Your ESP8266 baud rate:

#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

BlynkTimer timer;

void setup(){

  Serial.begin(9600);

  Serial1.begin(9600);

  Wire.begin();

 

  mlx.begin();

 

  // Debug console for ESP and to restore the Serial monitor update (ask mohammed it hard to explain)

  Serial1.begin(115200);

  // Set ESP8266 baud rate

  EspSerial.begin(ESP8266_BAUD);

  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);

  // You can also specify server:

  //Blynk.begin(auth, wifi, ssid, pass, "blynk.cloud", 80);

  //Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second

  timer.setInterval(1000L, myTimerEvent);

 

  delay(10000);

}

void loop(){

  Blynk.run();

  timer.run(); // Initiates BlynkTimer

    //some codes here

  delay(100);

}

// This function sends Arduino's up time every second to Virtual Pin (5).

// In the app, Widget's reading frequency should be set to PUSH. This means

// that you define how often to send data to Blynk App.

void myTimerEvent()

{

//  // You can send any value at any time.

//  // Please don't send more that 10 values per second.

  Blynk.virtualWrite(V0,00000000000000);

  Blynk.virtualWrite(V1,11111111111111111);

  Blynk.virtualWrite(V2,222222222222222);

  Blynk.virtualWrite(V3,333333333333333);

  Blynk.virtualWrite(V4,444444444444444);

  Blynk.virtualWrite(V5,555555555555555);

}

Blynk.begin() is a blocking function.
If a connection to the internet or the Blynk server can’t be established then all code execution will halt at that point.

Your options are limited with the hardware you are using, you’d be better with an ESP8366 or ESP32 as you can then manage your own WiFi connection and use Blynk.config() and Blynk.connect()

Also, these three lines of code…

need to be the FIRST THREE lines of your sketch.

Pete.

thanks for your response Pete

is there any other solution with the type of hardware I’m using ?
i tried to use blynk.config() as i saw in other posts in the forum but it didn’t work, now i know way

My days of messing around with the Uno/Mega and ESP-01 are long gone, and I forget exactly what is possible with that hardware.
There are some old posts by @Gunner about offline running and you might find some answers there, but TBH it’s about time that you abandoned this 13 year old technology and went for something more modern and with better functionality.

Pete.

i know but didn’t know any mcu like mega, it have multiple SDA&SCL and TX/RX

any suggestion for esp based that have this many SDA&SCL and TX/RX ?

Bear in mind that you’ll need one less UART because you won’t be using one for the ESP-01.
Also, I’m not sure why you’d need so many I2C interfaces, as I2C is a bus system that allows multiple sensors to be attached to the same bus. Having said that, the ESP32 has 2 x I2C interfaces.

Pete.

if one sensor is 5v and the second is 3.3v it cannot be in same bus, and my project can’t hold that many component

thank you for your time pete