D1 mini pro wifi drops on local server

Hey guys, I’m using a d1 mini pro (esp8266) for a work project. It mesure the current with a sensor and write it down pin V0 trough a0. On my own wifi the connection is stable : Wifi connect, connect to blynk, send datas… When we try to set it up at work : Wifi connect, connect to blynk, send datas for 3-7 scd, wifi still connected but on the serial monitor it says connecting to ipadressofblynkserver:xxxx for an infinite amount of time. I’ve checked the bandwith it’s 2.4ghz so the wifi seems ok but I don’t understand why the connection with the server drops

// Premiere partie du code qui définie la base du code. Permet d'inclure les librairies, définir les noms etc..)

// #define BLYNK_PRINT Serial // Permet d'écrire ce qu'il se passe sur le monitor

#include "EmonLib.h" // Librairie de mesure de courant
EnergyMonitor emon1; // Creation d'une instance

#include <ESP8266WiFi.h> // Lib Wifi
char ssid[] = "xxx"; // Nom du wifi   
char pass[] = "xxx"; // Mot de passe du wifi

#include <BlynkSimpleEsp8266.h> // Lib Blynk
char auth[] = "xxxxxxxxxx"; // Token de projet Blynk (crée automatiquement lors de la création d'un projet blynk)

BlynkTimer timer; // Fait appel a la librairie Blynk pour lui faire comprendre qu'un timer sera ajouté dans le code

// Début de la fonction sendSensor

void sendSensor()
{
Blynk.virtualWrite(V0, emon1.calcIrms(1480)); // Lib Blynk, écrit sur le pin virtuel V0 la valeur emon1.calcIrms(1480)
}


void sendLED()
{
if (emon1.calcIrms(1480) >= 0.5){
  Blynk.virtualWrite(V1, 255);
  Blynk.virtualWrite(V2, 0);
}
else
{
if (emon1.calcIrms(1480) <= 0.5){
  Blynk.virtualWrite(V1, 0);
  Blynk.virtualWrite(V2, 255);  
}
}
}




// Début de la fonction Setup, qui ne se réalise qu'une seule fois (sauf si appel...)

void setup()
{
  
  Serial.begin(9600); // Ecris sur le monitor en baud 9600
  Blynk.begin(auth, ssid, pass, "192.168.1.31", 8080); // Lib blynk, connexion Token,wifi,mdp, ip serveur blynk, port 8080 ou 81 à modifier
  emon1.current(0, 6.525);             // Courant : Pin input a savoir Analogique0 = 0, calibration (à taton, nécessaire de lire la librairie pour comprendre si calcul possible).
  timer.setInterval(350L, sendSensor); // timer lancant en boucle tout les "xL" en ms, la fonction sendSensor
  timer.setInterval(3000L, sendLED);
}

// Début de la fonction loop, qui tourne en boucle
// Il est nécessaire d'avoir une fonction loop la plus épuré possible sous peine de latence, déconnexion, bug .......

void loop()
{    
  Blynk.run(); // fait appel a tout les arguments blynk
  timer.run(); // enclenche le timer.setInterval, qui tout les "xL" active la fonction sendSensor
}

Also sometimes I get heartbeat timeout before getting disconnected, but the only thing that changes is the wifi, the material remain the same … Could it be a firewall problem, does the esp8266 ping on google DNS or something ? I also tried the WiFi.setSleepMode(WIFI_NONE_SLEEP) in the setup but it didn’t change a thing!

Am I flooding the server ? I thought my timer was ok, maybe I should use “Blynk.virtualWrite(V0, millis() / 1000);” ?

I also found someone having the same problem

You should read this:

Can I use Blynk App commercially?

NO. Blynk apps for iOS and Android can’t be used commercially .

Blynk takes automated measures to track and detect such activity. Any account that is suspected for commercial use can be deactivated immediately without a prior notice. We provide no warranty and no liability for any losses caused by stopping of your account and associated business or commercial use.

To use Blynk commercially, you need an active subscription to any plan listed on this page.

Any other commercial use is considered as violation of Terms And Conditions

Are you taking your Blynk local server to work with you, and attaching it to the work network at the same IP address as it has at home?
If not, then this won’t be able to resolve your Blynk server.
If you’re using a DDNS service and replacing 192.168.1.31 with your home server’s IP address then you’re introducing many more variables - such as potential port forwarding issues - into the equation.

I think you need to explain more about the local server setup at work scenario before we can provide any more clarity.

Turning on Blynk debugging may also provide more useful info…
https://docs.blynk.cc/#troubleshooting-enable-debug

Pete.

Thank you Pete! It’s for my “memoire’” as I need to make a PoC :slight_smile: I guess I can setup a hotspot with my phone to make the demonstration

For the local server, the IT guy set up a local server running on a computer, I was giving accès to the ssid and the password to use it in my code. I don’t think the network differs much from a house network, but there’s a firewall for outgoing and incoming transmission

I still don’t understand the home/work setup as far as accessing the local server(s) is concerned.
When you test at home, are you using the same local server as when you test at work?
If so, how does the 192.168.1.31 on your home network resolve to the machine on your work network?

Pete.

No at home I deployed a local server using a RPi on my local network.

At work it’s deployed on the RPi as well but with the work network.

It’s the same server but different I’m adresse due to a different network :slight_smile:

It sounds like some of the traffic between the Wemos and the server is being blocked. By default the Wemos will do a ping to the server every 10 seconds, and this may not be getting through.
You could try increasing the Blynk timeout to a higher number to see if it takes longer before it disconnects.

Pete.

Thank you Pete! I’ll try to modify that !