Connection lost after wifi access point reboot

so, it’s another issue
I will try your code

1 Like

Try timing your sendUpTime… maybe it takes longer than 400ms to finish so that could be the problem…
Put unsigned long currentMillis = millis(); at the beginning of the function and another unsigned long currentMillis2 = millis(); at the end and print them out and you’ll now if the problem is there…

1 Like

put something like this:


void StartOfTestingFunction()
{
unsigned long temp;
temp = millis();
// your function is here
functionDuration = millis() - temp;
 // print with you convenient way the functionDuration to serial or to terminal widget etc
|

1 Like

you have to install NoxPlayer, it works fine with blynk.

1 Like

@ErfanDL

please try that first

timer.setInterval(1000L, sendUptime);
//timer.setInterval(1100L, PIRval);
//timer.setInterval(1200L, pir);
//timer.setInterval(1300L, dozd);
//timer.setInterval(1400L, sendWifi);

and remove slash one by one
I think you have a sensor that needs more time …
I have had the same issue with DHT11 sensor when I tried my first blynk project :wink:

1 Like

…or, you could use setTimeout -> check this post: [SOLVED] Timer.setinterval - best use?
If you set it this way you will not need to take in consideration how long does a function run so there will be no collisions…
You will need to change your functions a little bit though…

1 Like

Thanks. I will try and report

My sensors is SI7021, BMP180, BH1750, MQ135 GAS at analog pin and a PIR sensor.

I tried one by one but not solved. and a question: Can I add timer.setInterval to another void expect void setup ?

tried but nothing !

1 Like

yes you can

1 Like

As Alexis said… try first with only the sendUptime interval, if it works, try to comment out that and uncomment the PIRval, etc… maybe there is something that stops the exec of the program. As my last link I posted should work with your script. You only need to set the interval for the first function, all the other should be called with setTimeout…
Did you measure the execution time of your sendUptime?

he said that don’t work anymore
so I don’t understand

I checked the datasheet for the BMP180 and it takes 8 ~ 176ms to return the measurement, depending on accuracy…

can you write an example for me ? thanks

what happened if you delete all timers ?
if it works
try only first timer with 10000L
you don’t need to get value every seconds
10 seconds is good enough

1 Like

When I delete all timers expect sendUptime there is no problem and connection restored after rebooting wifi router. But when I add function to sendUptime void or adding any timer the connection to server lost after rebooting wifi router

I don’t understand
But when I add function to sendUptime void
this function works or not?

1 Like

Try this:
-comment out all timers except sendUptime in setup. Than modify that function to include sthe setTimeout:
void sendUptime() { float temperature = sensor.getCelsiusHundredths(); Blynk.virtualWrite(5, (float)temperature/100); float humidity = sensor.getHumidityPercent(); Blynk.virtualWrite(6, humidity); // virtual pin uint16_t lux = lightMeter.readLightLevel(); Blynk.virtualWrite(4, lux); float bp = bmp.readPressure(); Blynk.virtualWrite(9,(float)bp/100); int callFunction2 = timer.setTimeout(1000, PIRval);//TWO not ONE }

2 Likes

Not worked.

Thanks. I will test tomorrow and tell the result