I have two pieces of code one is with Blynk.begin. Which is working and esp8266 is getting connect to the server.
Connections are the same.
while the other is with blynk.config which is stuck in errors
Code 1
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
char auth[] = "*******************************************";
char ssid[] = "PTCL-BB";
char pass[] = "3553C8A8";
#define ESP8266_BAUD 115200
ESP8266 wifi(&Serial);
int server , port;
void setup()
{
// Debug console
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
Serial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
pinMode(13, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(9, INPUT);
pinMode(10, INPUT);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
}
void loop()
{
Serial.println("Hello this is before ");
Blynk.run();
}
BLYNK_WRITE(V1) {
int pinValue = param.asInt(); // Assigning incoming value from pin V3 to a variable
if (pinValue == 1) {
digitalWrite(13, HIGH); // Turn LED on.
Blynk.virtualWrite(V6, 255);
} else {
digitalWrite(13, LOW); // Turn LED off.
Blynk.virtualWrite(V6, 0);
}
}
Code 2
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <BlynkSimpleShieldEsp8266.h>
#include <SimpleTimer.h>
#include "WiFiEsp.h"
char auth[] = "*******************************************";
char ssid[] = "PTCL-BB";
char pass[] = "3553C8A8";
bool Connected2Blynk = false;
int x = 10001;
#define ESP8266_BAUD 115200
ESP8266 wifi(&Serial);
SimpleTimer timer;
int blynkConnStat;
void setup()
{
Serial.begin(115200);
delay(100);
// Set ESP8266 baud rate
Serial.begin(ESP8266_BAUD);
delay(100);
Blynk.config(wifi,auth);
}
void loop()
{
Serial.println ("hello");
if (blynkConnStat == 0 ){
Serial.print("Blynk connecting");
Blynk.connect();
Blynk.run();
blynkConnStat = Blynk.connected();
x=0;
}
x++;
Blynk.run();
Serial.print(blynkConnStat);
}
Perhaps if you didn’t jump to another new topic instead of working with the help you were getting here
I merged your topics back together, please keep your issue in the same topic.
If you read the directions closer… you would see that, unlike Blynk.begin()… Blynk.config() is just for Blynk setup… you MUST have previously setup your own network connection with whatever hardware you are using.
FYI, one of the primary reasoning for using Blynk.config() is to allow your code to start and run, even if there is no connection to Blynk’s Server currently available… assuming you need and code it that way of course.
Otherwise if using Blynk.begin() it will never move past that command until a successful connection is made.
Yes, I just thought that blynk.connect() will make the connection but now I am using Blynk.connectWiFi(ssid, pass);
And this is working just fine . but thanks to you for that .