BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

ESP12E goes offline and comes online randomly

esp8266

#1

Hello,

I am running a LED dimmer code on ESP12E ( the chip that sits on NODEMCU )(Currently)
It was working well on NODEMCU(earlier) no disconnects what so ever. So i decided to run it on ESP12E as it is much smaller in size. I programmed it via TTL , the code is uploaded and the device also came online and it was shown on the Blynk app as well. After few second or a min or so it will go offline. But there is another device running parallel with this on the local sever but that is running just fine with out any disconnects.
And there is a 3rd device this acts wiered as well it automatically goes offline and comes online after few min or hours ( randomly ) . Is there any limitations on only few devices must be running on local server ? If so how many devices can it handle ?
Is it something to do with the code or hardware am not able to debug. Can anyone point me out in the right direction.


#2

No there are no limitations AFAIK.

Post your code and the serial monitor output.
Maybe the pin you are using is wrong which is resulting to reconnection.


#3
#include <Bounce2.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
BlynkTimer timer;
int ReCnctFlag;


#define server "192.1xx.1.1xx"

char auth[] = "xxxxxxxxx";
char ssid[] = "xxxxxx";
char pass[] = "xxxxxxxxxx";

int val;
int encoder0PinA = 5;
int encoder0PinB = 4;
int encoder0Pos = 0;
int encoder0PinALast = LOW;
int n = LOW;

int curBrightness = 0;
bool isFirstConnect = true;

const int PinDT=5;    // DATA signal
const int PinCLK=4;    // CLOCK signal


BLYNK_CONNECTED() {
  if (isFirstConnect) {
     Blynk.syncAll();
     Blynk.syncVirtual(V6, V5, V3); 
     isFirstConnect = false;
  }
  int value = millis() / 1000;
  Blynk.virtualWrite(V33, value);
}

BLYNK_WRITE(V6) {

  curBrightness = param.asInt();
  Blynk.virtualWrite(V6, curBrightness);
  analogWrite(D5, curBrightness);
}

Bounce debouncer1 = Bounce(); 
Bounce debouncer2 = Bounce();

void setup() {
  pinMode (encoder0PinA, INPUT);
  debouncer1.attach(encoder0PinA);
  debouncer1.interval(5); 
  
  pinMode (encoder0PinB, INPUT);
  debouncer1.attach(encoder0PinB);
  debouncer1.interval(5); 
  
  
  pinMode(D5, OUTPUT);
  pinMode(encoder0PinA, INPUT);
  pinMode(encoder0PinB, INPUT);
  delay(10);
  
  Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,1xx), 8080);
  Serial.begin (115200);
  
}

void loop() {
  debouncer1.update();
  debouncer2.update();

  int value1 = debouncer1.read();
  int value2 = debouncer2.read();
  
    n = digitalRead(encoder0PinA);
  if ((encoder0PinALast == LOW) && (n == HIGH)) {
    if (digitalRead(encoder0PinB) == LOW) {
      encoder0Pos--;
      if(curBrightness - 700 >= 0)curBrightness -= 100;
      Blynk.virtualWrite(V6, curBrightness);
      analogWrite(D5, curBrightness);
    } else {
      encoder0Pos++;
      if(curBrightness + 100 <= 1023) curBrightness += 100;
      Blynk.virtualWrite(V6, curBrightness);
      analogWrite(D5, curBrightness);
    }
  }
  encoder0PinALast = n;
  

  if(Blynk.connected()){
    Blynk.run();
  }
  timer.run();
}

The same code was running fine on nodemcu from past 2 weeks. No disconnects. But now as soon as i am using ESP12E the problem has started.


#4

If the same code runs flawlessly on a NodeMCU dev board, but doesn’t work on your bare bones ESP12 then that seems to point the finger at your hardware.
I think I’d be looking at the power supply you’re using for your ESP12 and what sort of voltage stabilisation and ripple reduction you’ve incorporated into your setup.
You might also want to look at monitoring your RSSI and hooking-up an FTDI interface so you can monitor your serial output for some clues.

Pete.


#5

I am using AMS1117 3.3v voltage regulator with 10uf electrolytic cap and 104 cap for input(ESP12E). I guess there is no possible issue with the voltage.


#6

I was not able to find any problem.

One thing I noticed that in documentation it is mentioned not to put Blynk.virtualWrite and any other Blynk.* command inside void loop() as it will cause lot’s of outgoing messages to the server and the connection will be terminated.
So i think you can try to keep the void loop() clean and try again. Maybe it will work.


#7

Agreed may be true. But the same code was running just fine on the Nodemcu. Without any change in the code. Should i change the Auth token ?? Is this something to do with the connection ??


#8

I don’t think auth code has to do anything with this issue.

Maybe any other community member will help you with this as I can’t figure out the solution for this. Sorry :disappointed_relieved:


#9

Even i tried to troubleshoot whats wrong!!! But failed terribly…


#10

Your void loop is extremely cluttered, which will cause disconnections.

Have you actually tried flashing exactly the same code onto both the ESP12 and the NodeMCU.
The reason I ask is that there have been some changes in the Blynk libraries, and the ESP core over time. If the same lines of code were compiled at different times then you could be getting different results because of differences in these libraries.

You also mention the Auth code. It’s not clear if you’re running multiple devices at the same time that share the same Auth code. This isn’t good practice, and whilst it it probably won’t cause disconnections it’s something to be avoided.

Pete.


#11

Yes… Am pretty sure that i have uploaded the same code on to both devices.And i have not updated any libraries.

Yes the same Auth token is used from the nodemcu’s code. But the nodemcu is no longer used, and only the ESP12E is active now. So this should not be a problem right ?(Correct me if i am wrong.) And even the brightness range is now lesser then it was earlier. Anyways i will create a new project and add the new Auth token and check if that resolves. But i am not understanding the brightness malfunction. (Again exact same code) . Is it something to do with the firmware ? (May be NO…)


#12

Me neither! It’s the first time you’ve mentioned this and im not clear what the issue is, you’ll need to explain more.

Have there been any changes to your app - have you changed the device type?
Some devices use 0-254 PWM steps and others use 0-1023 steps. Changes in brightness could be connected with this.

It’s always good to keep your local server, app, Blynk libraries and Arduino core at the latest version, but maybe best to get this issue resolved first.

Pete.


#13

Sorry ! As i said earlier i am using this ESP-12E as an LED dimmer. When the same code was running on NODEMCU the range i was giving was distributed through out the band. But now i am getting only half of the range of what i was getting earlier.

No. I have choose NODEMCU on the app (select device and connection type Wifi. ) should i choose ESP8266 ?

Agreed ! But on the NODEMCU its running fine with the same set of lib , app and server !!!

And the device when turned on takes about 5 min to get online and after a min or so it will go offline and never comes back on.


#14

Now, when i give the input from the App it takes 5 to 6 sec to respond. Its just too laggy. I have also tried changing the Device to ESP8266 on the app. And still same problem.


#15

So when the device is trying to connect, what sort of messages are you seeing in your serial monitor?

Have you tried rebooting all of your network devices (router, Blynk server, switches, WAPs etc)?

Have you tried pitputti g RSSI values to your serial monitor as I suggested before?

What happens if you run some very simple code on your ESP12 device - something like the Blynk blink sketch?

Have you tried using your ESP12 device with the cloud server?

Pete.


#16

It spits out some random characters(changed the baud rate as well but not getting proper output) as i am using an USB to TTL converter for programming the ESP 12-E

NO ! I will do it right now. !!!

Sorry i am not aware of this ! Can you please help me understand this a bit ! :pray:

I have not tried this out yet because i had no problems in the past with the code.

NO. I have a local server setup and all my test subjects run on the same server without any problem. Except this -


#17

You need to get your serial monitor sorted out. The default baud rate is probably 115200.

Once you have that sorted, and set-up a serial output then this line of code will print wi-Fi signal strength (RSSI) values to the serial monitor:

Serial.println(WiFi.RSSI());

Expect readings in the -50 (very good) to -70 (okay) range.
This should give you an indication of whether your issues are to do with Wi-Fi dropouts.

Pete.


#18

Yeah i tried that out. But no use. It is just spitting out random characters. But when i used a diff version of IDE it was giving an error like boot cause 18 jan (3, 6) {something like this.} …And also it was stuck on [46] connecting to XXXX and nothing after this…

Now i setup a new Blynk server on Rpi Zero W just for checking and a new Wifi router as well and the blynk server is up and running and i am able to login with my phone as well. And the interesting part is the ESP12-E connected fast, and i was happy and that did not last for 1 min. i have connected a small led to the output[For dimming purpose as mentioned in earlier thread] and randomly every 2 or 5 or 8 min or so there is a pause and then again it works for a while. I am not understanding the reason behind this miss behavior… And again the range(brightness) is not through out the band. Its very dim compared to previous(on nodemcu) , i cross checked the LED and also replaced it. even the power supply is providing solid 3.39v with out any fluctuation. There are no loose wires for sure, everything is soldered well, no shorts as well.
Main problems are

  1. Disconnect from server
  2. Dimness range (Not blynk related maybe) is it something to do with serial begin (115200 or
    9600) ??
  3. Connects to new Rpi Zero W but not the old Rpi 3 (wifi is near by just a 15 feet at max)

#19

@PeteKnight
Hello,
The Blynk server that is running on Rpi 3 is “server-0.36.5-java8.jar” .
Is this something to do with the connection ? Was this a stable release? i mean to say was there any problems reported on this version ?

But now the same version of server is up and running on on Rpi Zero W without any noticeable problem till now.

And one more thing, there is one more device pushing lots of data to the same server[Rpi3] … will this prevent the other devices from connecting or disconnect the device due to over load to the server ??

There is no Wifi dropouts the reading i am getting is -62 to -68 (so this should be in good enough)


#20

No idea I’m afraid, I’m a cloud user myself.
However, the latest version is 0.41.4 so your version sounds like it’s well past it’s sell by date.

Pete.