Hi,
I have need for a support, if anyone can share few minutes of their time.
I have had devices connected to Blynk Legacy since early 2017 and now I am trying convert to Blynk 2.0 without full success.
I have used and have in hand the bad reputation Robotdyn Uno with combined ESP8266 board, using Hardware Serial communication between the UNO and ESP8266 part.
They have worked fine with Blynk Legacy, after steep learning curve in the beginning.
To start with, my aim was only to get connection and therefore used the QuickStart code which the Blynk supplies.
In addition to the code supplied in the example, I needed to add the Hardware serial communication between the UNO and the ESP8266.
The ESP8266 contains the standard firmware and is unchanged from the Blynk Legacy setup.
It answers AT message and I have confirmed it has ip-number and I have tried using baud rate from 9600 to 115200.
I have used the very good instruction from Pete on the serial communication in the FAQ:
Which are in line fully rhymes with what I found out when I started to use boards of this kind.
The issue I have is that the board goes online for 9 seconds and then goes offline for 26 seconds.
Always the same time sequence.
It though never connects as the uptime never increases.
My thought is that the board re-boots for some reason or is thrown off the server.
Using:
IDE 2.0.3
Blynk library 1.1.0
ESP8266_Lib.h from 2016
ESP8266 Firmware version: 1.4.0.0
Following is the code I try to run:
/*************************************************************
This is a simple demo of sending and receiving some data.
Be sure to check out other examples!
*************************************************************/
// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID "TMPLAIhuZiTj"
#define BLYNK_DEVICE_NAME "Quickstart Device"
#define BLYNK_AUTH_TOKEN "************"
// Comment this out to disable prints and save space
//#define BLYNK_PRINT Serial // Defines the object that is used for printing
//#define BLYNK_DEBUG // Optional, this enables more detailed prints
//Works with Blynk Legacy and now but cuts off
#include <SPI.h>
#include <ESP8266_Lib.h> //Was used with Blynk legacy
#include <BlynkSimpleShieldEsp8266.h> //Was used with Blynk legacy
BlynkTimer timer; // Create a timer object
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "********"; // Access point name
char pass[] = "*******"; // Your WiFi credentials. Set password to "" for open networks.
//____________________________________________________
// Serial setup
//____________________________________________________
// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX
#define EspSerial Serial //For Uno with Uno to ESP8266 through Hardware serial
//#define ESP8266_BAUD 115200 // Define your ESP8266 baud rate --> Worked in Temp sketch on Legacy
//#define ESP8266_BAUD 57600
#define ESP8266_BAUD 115200
//#define ESP8266_BAUD 9600 //Check this speed
ESP8266 wifi(&EspSerial); // Tell the Blynk library to use the HardwareSerial port for WiFi..
// This function is called every time the Virtual Pin 0 state changes
BLYNK_WRITE(V0)
{
// Set incoming value from pin V0 to a variable
int value = param.asInt();
// Update state
Blynk.virtualWrite(V1, value);
}
// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
// Change Web Link Button message to "Congratulations!"
Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
Blynk.setProperty(V3, "onImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}
void myTimerEvent() // This loop defines what happens when timer is triggered
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V2, millis() / 1000); // This function sends Arduino's uptime every second to Virtual Pin 2.
}
void setup()
{
EspSerial.begin(ESP8266_BAUD); // Set ESP8266 baud rate
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
}
void loop()
{
Blynk.run();
timer.run(); // runs the timer in the loop
// You can inject your own code or combine it with other sketches.
// Check other examples on how to communicate with Blynk. Remember
// to avoid delay() function!
}
Are the Serial libraries I use wrong if using Blynk 2.0?
The QuickStart code, when Arduino and Wi-Fi is chosen, shows libraries:
#include <SPI.h>
#include <WiFi101.h>
#include <BlynkSimpleWiFiShield101.h>
Which do not compile with my code.
The instruction from Pete show libraries:
#include<ESP8266_Lib.h>
#include<BlynkSimpleShieldEsp8266.h>
Which are the ones I used for Blynk Legacy.
The QuickStart code uses for Blynk connection :
Blynk.begin(auth, ssid, pass);
But the code from Pete uses:
Blynk.begin(auth, wifi, ssid, pass);
Does this matter?