Connecting to blynk-cloud.com:80 MOS Driver

Hi. I know, there are lots of same error has been discussed here. Mine is bit different. I think I can guess the problem, but I want definite answer.

In my case, I do LED dimming by using esp8266 and it is all working out very well, being able to connect with Blynk; Can turn it on/off by button, and having slider to adjust brightness. Also, this part, I use common typical LDR for auto brightness.

So I make my project more bit advance by having external source of 6v for 6v LED and digital light intensity sensor. Single testing WITHOUT Blynk connectivity, the LED output that go through MOSFET driver (as pwm) can give wanted output, and wanted brightness. It went well.

But then, as I put it altogether to be controlled by Blynk, it gives this “Connecting to blynk-cloud.com:80” message. So I cannot control the LED from Blynk.

When I revert back to original setup that uses small LED as mentioned earlier with same coding (of course lil bit alteration of I/O pin), Blynk can be connected again. So, I guess, the mobile hotspot I am being using is all ok.

I really hope that the problem is not the nodemcu itself. But, is it the ESP that problematic one, cant handle MOSFET?
Is it lies on the library list?

What pins are you using?

Pete.

!
This first photo is the advance one. This one, the message of ’ connecting to blynk-cloud.com:80 ’ keep showing up

photo_2018-12-19_00-18-48|666x500
The second one is the basic component that I use for testing. I connect the LDR with analog pin and overall, for this connection, the Blynk can be connected.

D3 = GPIO0, which isn’t a good pin to use.it MUST be HIGH at boot time, otherwise the NodeMCU will go in to flash mode.

Pete.

thank you for that new info.
So, I tried to remove GY-30(Digital light sensor) component that uses D3 and D4…instead, I use typical light sensor LDR that uses A0 pin as the replacement. The message keep give same error. From my observation, I assume tht the board do not support too much components at one time. Is it?
Because:

  1. When I use directly MOSFET with 6v led with map function in arduino without blynk connection, the code enable to be executed. LED is successfully dimmed by writing the value on the code.

  2. When I use MOSFET with 6v led with Blynk Connection(Blynk Write input button), the code give that Connecting to blynk-cloud.com:80 error.

  3. When I use 3V small LED with and without Blynk Connection(Blynk Write input button), the code enable to be executed, and can be controlled by Blynk.

I think we need to see the code you’re using with Blynk, because ther isn’t a limit on the components that can be used, provided you connect and code them correctly.

Pete.

So this is my code. When I used 3v led that doesnt require amplifier, it can connect to blynk. But when I use Mosfet with external battery for 6v led for D5(GPIO14) output, it gives the blynk-cloud.com:80 error. But, it works with mosfet when code for blynk is excluded. I wish there will be just some add up/alteration of this code that can help with the connectivity.

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

//%%%%%%%%%%%%%%%%    WIFI BLYNK CONFIG     %%%%%%%%%%%%%%%%%%%
char auth[] = "f02a65835ef449cc985befc65c82a4d3";//"f02a65835ef449cc985befc65c82a4d3";
char ssid[] = "projecthelp";
char pass[] = "projecthelppass";
//%%%%%%%   GLOBAL VAR   %%%%%%%%%%%%%
int LDR_Value;
int lighttoled;
int lighttoledslide;
int brightness;
int power;
int timeron;
int onlamp;
int slide;
int resetbrightness;

BlynkTimer timer;

BLYNK_WRITE(V1)     //on/off switch button
{
  onlamp = param.asInt();
  if (onlamp == 1)
  {
    operate();
  }
  else
  {
    nooperate();
  }
}

BLYNK_WRITE(V2)    //slider
{
  slide = param.asInt();
  if (onlamp == 1)
  {
    lighttoledslide = map(slide, 0, 1023, 0, 1023);
    analogWrite(14, lighttoledslide);
    brightness = (lighttoledslide * 100) / 1023;
    power = (90 - 0.01466 * lighttoled * 6) * 100 / 90;
    brightnessbreached();
  }
  else
  {
    nooperate();
  }
}
//
BLYNK_WRITE(V3)   //brightness reset button
{
  resetbrightness = param.asInt();
  if (onlamp == 1) {
    if (resetbrightness == 1)
    {
      operate();
      WidgetLED led1(V0);
      led1.off();
    }
  }
}

BLYNK_WRITE(V7)//timer
{
  timeron = param.asInt();
  if (timeron == 1)
  {
    operate();
  }
  if (timeron == 0)
  {
    nooperate();
  }
}

void setup()
{ Serial.begin(115200);
  pinMode(A0, INPUT);
  pinMode(14, OUTPUT);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(10L, blynkupdate);


}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}


void operate()
{
  LDR_Value = analogRead(A0);
  lighttoled = map(LDR_Value, 30, 1023, 1023, 0); ; //100 = 1023, 400=0
  analogWrite(14, lighttoled);
  brightness = (lighttoled * 100) / 1023;
  power = (90 - 0.01466 * lighttoled * 6) * 100 / 90;
  Blynk.virtualWrite(V1, 1) ;
  Blynk.virtualWrite(V2, lighttoled) ;

}

void brightnessbreached()
{
  if (slide != 0)
  {
    WidgetLED led1(V0);
    led1.on();
  }
  if (onlamp == 0)
  {
    WidgetLED led1(V0);
    led1.off();
  }
}

void nooperate()
{
  brightness = 0;
  lighttoled = 0;
  analogWrite(14, lighttoled);
  Blynk.virtualWrite(V1, 0) ;
  WidgetLED led1(V0);
  led1.off();
  Blynk.virtualWrite(V2, 0) ;
}


void blynkupdate()
{

  if (lighttoled == 0)
  {
    Blynk.virtualWrite(V5, "      Saved Power: NULL");
  }
  else
  {
    Blynk.virtualWrite(V5, "      Saved Power: ", power, " %");
  }
    Blynk.virtualWrite(V4, "        Brightness: ", brightness, " %");
  
}

So you’re calling a function 100 times per second, which is then evaluating an if statement and doing either one or two BlynkvirtualWrites, depending on the if statement.
That’s not good Blynk programming!

Why on earth do you need to update Blynk 100 times per second?

Pete.

1 Like

I have been away for a while. Thank you for the reply. I would like to retry to see either disabling the blynk update will bring the fixation or not, but unfortunately I encounter another problem where ARDUINO is sucessfully upload the code but the output is not executed on the hardware even as simple as LED blink. If I able to settle this MCU problem, I will come back to this.

Try disconnecting everything from the pins of your NodeMCU.
If GPIO2 (D4) is being pulled LOW at boot-up then your MCU will not connect to your Wi-Fi.

Pete.

Well, first of all I’d change the 10ms intervall for calling the blynkupdate to let’s say once a second? (1000L). The operate function is run just once when you click on the V1 (button?), is this the correct behaveour? I’d trigger a timer if V1 is on…
In BLYNK_WRITE(V2)… why do you map that - lighttoledslide?

Yes…It can operate once V1 button is clicked. Operate means the lamp turn on in suitable brightness in accordance to its algorithm.
The V2 is slider…yes for that case it not necessary to be using mapping function since the value is the same, but during testing I always attempt in changing the inconsistency in the ratio, instead 1:1 I sometimes would test it in 1:1/2 for example

Ok, but did you try to lower the blynkupdate to something like once a sevond?