How To Install Using Library Manager
New Version v1.0.3
1. Add support to STM32 (STM32F1, F2, F3, F4, F7, etc) boards
New Version v1.0.2
1. Add support to SAMD (DUE, ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit CIRCUITPLAYGROUND_EXPRESS, etc.) boards
To help you to eliminate hardcoding your Wifi and Blynk credentials for Mega/Teensy boards running ESP8266 AT shields, and updating/reflashing every time when you need to change them. Configuration data are saved in configurable location in EEPROM.
With version v1.0.0 or later, you now can configure:
1. Config Portal Static IP address, Name and Password.
2. Static IP address, Gateway, Subnet Mask and 2 DNS Servers IP addresses.
Sample Code
Code: Select all
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) )
#if defined(ESP8266_AT_USE_STM32)
#undef ESP8266_AT_USE_STM32
#endif
#define ESP8266_AT_USE_STM32 true
#endif
#if ( defined(ESP8266) || defined(ESP32) || defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560) || defined(CORE_TEENSY) || !(ESP8266_AT_USE_STM32) )
//#error This code is intended to run on STM32 platform! Please check your Tools->Board setting.
#endif
#if ESP8266_AT_USE_STM32
// For STM32, you have to declare and enable coreresponding Serial Port somewhere else before using it
#define EspSerial Serial1
#if defined(STM32F0)
#define BOARD_TYPE "STM32F0"
#error Board STM32F0 not supported
#elif defined(STM32F1)
#define BOARD_TYPE "STM32F1"
#elif defined(STM32F2)
#define BOARD_TYPE "STM32F2"
#elif defined(STM32F3)
#define BOARD_TYPE "STM32F3"
#elif defined(STM32F4)
#define BOARD_TYPE "STM32F4"
#elif defined(STM32F7)
#define BOARD_TYPE "STM32F7"
#else
#warning STM32 unknown board selected
#define BOARD_TYPE "STM32 Unknown"
#endif
#else
// For Mega
#define EspSerial Serial3
#define BOARD_TYPE "AVR Mega"
#endif
#include <ESP8266_Lib.h>
// Start location in EEPROM to store config data. Default 0
// Config data Size currently is 128 bytes)
#define EEPROM_START 0
#define USE_BLYNK_WM true
//#define USE_BLYNK_WM false
#if USE_BLYNK_WM
#if ESP8266_AT_USE_STM32
#include <BlynkSimpleShieldEsp8266_STM32_WM.h>
#else
#include <BlynkSimpleShieldEsp8266_WM.h>
#endif
#else
#include <BlynkSimpleShieldEsp8266_STM32.h>
#define USE_LOCAL_SERVER true
#if USE_LOCAL_SERVER
char auth[] = "****";
String BlynkServer = "account.duckdns.org";
//String BlynkServer = "192.168.2.112";
#else
char auth[] = "****";
String BlynkServer = "blynk-cloud.com";
#endif
#define BLYNK_SERVER_HARDWARE_PORT 8080
// Your WiFi credentials.
char ssid[] = "****";
char pass[] = "****";
#endif
// Your Teensy <-> ESP8266 baud rate:
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);
void heartBeatPrint(void)
{
static int num = 1;
if (Blynk.connected())
{
Serial.print("B");
}
else
{
Serial.print("F");
}
if (num == 80)
{
Serial.println();
num = 1;
}
else if (num++ % 10 == 0)
{
Serial.print(" ");
}
}
void check_status()
{
static unsigned long checkstatus_timeout = 0;
#define STATUS_CHECK_INTERVAL 15000L
// Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change.
if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0))
{
// report status to Blynk
heartBeatPrint();
checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL;
}
}
void setup()
{
// Debug console
Serial.begin(115200);
delay(1000);
// initialize serial for ESP module
EspSerial.begin(ESP8266_BAUD);
Serial.println("\nStart Blynk WiFiManager using ESP8266_AT_Shield on " + String(BOARD_TYPE));
#if USE_BLYNK_WM
Serial.println("Start Blynk_WM");
Blynk.setConfigPortalIP(IPAddress(192, 168, 100, 1));
//Blynk.setConfigPortal("Teensy4", "MyTeensy4");
Blynk.begin(wifi);
#else
Serial.println("Start Blynk");
Blynk.begin(auth, wifi, ssid, pass, BlynkServer.c_str(), BLYNK_SERVER_HARDWARE_PORT);
#endif
}
void loop()
{
Blynk.run();
check_status();
}
1. No Config Data => Config Portal
Code: Select all
Start Blynk WiFiManager using ESP8266_AT_Shield on TEENSY 4.0
Start Blynk_WM
[7866] AT version:0.40.0.0(Aug 8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build:1.3.0.2 Sep 11 2015 11:48:04
OK
[8392] Init new EEPROM, size = 1080
[8393] bg: No configdat. Stay forever in config portal
[12836] startConfig: SSID = Teensy4_CCE61, PW = MyTeensy4_CCE61, IP = 192.168.100.1
Code: Select all
Start Blynk WiFiManager using ESP8266_AT_Shield on TEENSY 4.0
Start Blynk_WM
[7866] AT version:0.40.0.0(Aug 8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build:1.3.0.2 Sep 11 2015 11:48:04
OK
[8390] Header = SHD_ESP8266, SSID = ****, PW = ****
[8390] Server = ****.duckdns.org, Port = 8080, Token = ****
[8390] Board Name = Teensy4-WM
[8390]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.6.1 on Teensy 4.0
[8390] con2WF: start
[8390] connectToWifi: Try connectWiFi
[8390] Connecting to ****
[14956] AT version:0.40.0.0(Aug 8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build:1.3.0.2 Sep 11 2015 11:48:04
OK
[15493] Get macAddress = 5c:cf:7f:66:05:d2
[22526] IP = 192.168.2.107
[22543] Connected to WiFi
[22543] con2WF: con OK
[22543] IP = 192.168.2.107
[22560] bg: WiFi connected. Try Blynk
[32717] Ready (ping: 18ms).
[32932] bg: WiFi+Blynk connected
BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB
F[634808] run: Blynk lost. Connect Blynk
F[649868] run: Blynk lost. Connect Blynk
F[664928] run: Blynk lost. Connect Blynk
[675040] Ready (ping: 13ms).
[675265] run: Blynk reconnected
BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB
This is the link to Blynk
Blynk IoT Platform
Blynk was designed for the Internet of Things. It can control hardware remotely, it can display sensor data, it can store data, visualize it and do many other cool things.
We can install and use Local Blynk Server (RPi Zero W, 3B+, 4, Laptop, PC, etc) to have full control.
The Server source code is in Public Domain and written in Java. We can download, compile and use to be sure having full control.
Use Local Blynk Server
Blynk Server
Blynk Server Source Code