How To Install Using Library Manager
Simple Ethernet Manager Library for Blynk and Arduino Mega, Teensy, SAM DUE, SAMD boards, with or without SSL, configuration data saved in EEPROM or FlashStorage.
-
This is the new library, adding to the current Blynk_WiFiManager. It's designed to help you eliminate hardcoding your Blynk credentials in Arduino Mega 1280, Mega 2560, Teensy (3.x, 4.0), SAM DUE, SAMD, etc. boards using Ethernet shields (W5100, W5200, W5500, ENC28J60, etc). It's currently not supporting SSL for Mega because there is not enough memory (only 8 KBytes) in Mega boards.
-
It's not supporting UNO/Nano and other AVR boards having only 32KBytes of program storage space.
-
You can update Blynk Credentials any time you need to change via Configure Portal. Data are saved in configurable locations in EEPROM or FlashStorage.
Sample Code
#if defined(ESP8266) || defined(ESP32)
#error This code is designed to run on Arduino AVR, SAM, SAMD, Teensy platform, not ESP8266 nor ESP32! Please check your Tools->Board setting.
#endif
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \
|| defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \
|| defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \
|| defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) )
#if defined(ETHERNET_USE_SAMD)
#undef ETHERNET_USE_SAMD
#endif
#define ETHERNET_USE_SAMD true
#endif
#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) )
#if defined(ETHERNET_USE_SAM_DUE)
#undef ETHERNET_USE_SAM_DUE
#endif
#define ETHERNET_USE_SAM_DUE true
#endif
#if defined(ETHERNET_USE_SAMD)
#if defined(ARDUINO_SAMD_ZERO)
#define BOARD_TYPE "SAMD Zero"
#elif defined(ARDUINO_SAMD_MKR1000)
#define BOARD_TYPE "SAMD MKR1000"
#elif defined(ARDUINO_SAMD_MKRWIFI1010)
#define BOARD_TYPE "SAMD MKRWIFI1010"
#elif defined(ARDUINO_SAMD_NANO_33_IOT)
#define BOARD_TYPE "SAMD NANO_33_IOT"
#elif defined(ARDUINO_SAMD_MKRFox1200)
#define BOARD_TYPE "SAMD MKRFox1200"
#elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) )
#define BOARD_TYPE "SAMD MKRWAN13X0"
#elif defined(ARDUINO_SAMD_MKRGSM1400)
#define BOARD_TYPE "SAMD MKRGSM1400"
#elif defined(ARDUINO_SAMD_MKRNB1500)
#define BOARD_TYPE "SAMD MKRNB1500"
#elif defined(ARDUINO_SAMD_MKRVIDOR4000)
#define BOARD_TYPE "SAMD MKRVIDOR4000"
#elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS)
#define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS"
#elif defined(__SAMD21G18A__)
#define BOARD_TYPE "SAMD21G18A"
#else
#define BOARD_TYPE "SAMD Unknown"
#endif
#elif defined(ETHERNET_USE_SAM_DUE)
#if ( defined(ARDUINO_SAM_DUE) || (__SAM3X8E__) )
#define BOARD_TYPE "SAM DUE"
#else
#define BOARD_TYPE "SAM Unknown"
#endif
#elif ( defined(CORE_TEENSY) )
// For Teensy 4.0
#if defined(__IMXRT1062__)
#define BOARD_TYPE "TEENSY 4.0"
#elif ( defined(__MKL26Z64__) || defined(ARDUINO_ARCH_AVR) )
#define BOARD_TYPE "TEENSY LC or 2.0"
#else
#define BOARD_TYPE "TEENSY 3.X"
#endif
#else
// For Mega
#define BOARD_TYPE "AVR Mega"
#endif
#include <SPI.h>
// Start location in EEPROM to store config data. Default 0.
// Config data Size currently is 128 bytes w/o chksum, 132 with chksum)
#define EEPROM_START 0
#define USE_SSL false
//#define USE_SSL true
#define USE_CHECKSUM true
#if USE_SSL
// Need ArduinoECCX08 and ArduinoBearSSL libraries
// Currently, error not enough memory for UNO, Mega2560. Don't use
#include <BlynkSimpleEthernetSSL_WM.h>
#else
#include <BlynkSimpleEthernet_WM.h>
#endif
#define USE_BLYNK_WM true
#if !USE_BLYNK_WM
#define USE_LOCAL_SERVER true
#if USE_LOCAL_SERVER
char auth[] = "******";
char server[] = "account.duckdns.org";
//char server[] = "192.168.2.112";
#else
char auth[] = "******";
char server[] = "blynk-cloud.com";
#endif
#define BLYNK_HARDWARE_PORT 8080
#endif
#define W5100_CS 10
#define SDCARD_CS 4
void setup()
{
// Debug console
Serial.begin(115200);
Serial.println("\nStart W5100_Blynk on " + String(BOARD_TYPE));
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
#if USE_BLYNK_WM
Blynk.begin();
#else
#if USE_LOCAL_SERVER
Blynk.begin(auth, server, BLYNK_HARDWARE_PORT);
#else
Blynk.begin(auth);
// You can also specify server:
//Blynk.begin(auth, server, BLYNK_HARDWARE_PORT);
#endif
#endif
if (Blynk.connected())
{
Serial.print(F("Conn2Blynk: server = "));
Serial.print(Blynk.getServerName());
Serial.print(F(", port = "));
Serial.println(Blynk.getHWPort());
Serial.print(F("Token = "));
Serial.print(Blynk.getToken());
Serial.print(F(", IP = "));
Serial.println(Ethernet.localIP());
}
}
void heartBeatPrint(void)
{
static int num = 1;
if (Blynk.connected())
Serial.print(F("B"));
else
Serial.print(F("F"));
if (num == 80)
{
Serial.println();
num = 1;
}
else if (num++ % 10 == 0)
{
Serial.print(F(" "));
}
}
void check_status()
{
static unsigned long checkstatus_timeout = 0;
#define STATUS_CHECK_INTERVAL 60000L
// 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))
{
heartBeatPrint();
checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL;
}
}
void loop()
{
Blynk.run();
check_status();
}
This is the link to Blynk
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.
You 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. You can download, compile and use to be sure having full control.
Releases v1.0.6
New in this version
- Support ENC28J60 Ethernet shields and other boards such as SAMD, Teensy using UIPEthernet
- Add checksum
- Add more examples for ENC28J60 Ethernet shields
Releases v1.0.7
New in this version
- Add support to SAM DUE and SAMD (ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit CIRCUITPLAYGROUND_EXPRESS, etc.) boards
- Add clearConfigData() to enable resetting Config Data when necessary.