New Releases v1.0.0
- Add support to STM32 boards with built-in Ethernet, ENC28J60 or W5x00 Ethernet shields
- This is the new library, adding to the current Blynk_WiFiManager. It’s designed to help you eliminate
hardcoding
your Blynk credentials inSTM32
boards using with Ethernet (Built-in, W5100, W5200, W5500, ENC28J60, etc). It’s currently not supporting SSL and can not saved config dada to non-volatile memory (EEPROM, battery-saved SRAM, SPIFFS, etc.). To be fixed in future releases. - You can update Blynk Credentials any time you need to change via Configure Portal. Data to be saved in configurable locations in EEPROM.
This library currently supports
- STM32 boards with built-in Ethernet such as :
- Nucleo-144 (F429ZI, F767ZI)
- Discovery (STM32F746G-DISCOVERY)
- All STM32 Boards with Built-in Ethernet, See How To Use Built-in Ethernet
- STM32 boards (with 64+K Flash) running ENC28J60 shields
- STM32 boards (with 64+K Flash) running W5x00 shields
So, how it works?
If no valid config data are stored in EEPROM, it will switch to Configuration Mode
. Connect to access point at the IP address displayed on Terminal or Router’s DHCP server as in the following picture:
After you connected to, for example, 192.168.2.113
, the Browser will display the following picture:
Enter your credentials (Blynk Server and Port). If you prefer static IP, input it (for example 192.168.2.113
) in the corresponding field. Otherwise, just leave it blank
or nothing
.
Then click Save
. After the board auto-restarted, you will see if it’s connected to your Blynk server successfully as in the following picture:
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_ARCH_STM32F1)
#define DEVICE_NAME "STM32F1"
#define BLYNK_NO_YIELD
#elif defined(ARDUINO_ARCH_STM32F3)
#define DEVICE_NAME "STM32F3"
#define BLYNK_NO_YIELD
#elif defined(ARDUINO_ARCH_STM32F4)
#define DEVICE_NAME "STM32F4"
#define BLYNK_NO_YIELD
#elif defined(ARDUINO_ARCH_STM32F7)
#define DEVICE_NAME "STM32F7"
#define BLYNK_NO_YIELD
#else
#define DEVICE_NAME "STM32 Unknown"
#define BLYNK_NO_YIELD
#endif
#define USE_BUILTIN_ETHERNET false
// If don't use USE_BUILTIN_ETHERNET, and USE_UIP_ETHERNET => use W5x00 with Ethernet library
#define USE_UIP_ETHERNET false
#if (USE_BUILTIN_ETHERNET)
#define ETHERNET_NAME "Built-in STM32 Ethernet"
#elif (USE_UIP_ETHERNET)
#define ETHERNET_NAME "ENC28J60 Ethernet Shield"
#else
#define ETHERNET_NAME "W5x00 Ethernet Shield"
#endif
// 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_CHECKSUM true
#if USE_SSL
// Need ArduinoECCX08 and ArduinoBearSSL libraries
// Currently, error not enough memory for many STM32 boards. Don't use
#error SSL not support
#else
#if USE_BUILTIN_ETHERNET
#include <BlynkSTM32BIEthernet_WM.h>
#elif USE_UIP_ETHERNET
#include <BlynkSTM32UIPEthernet_WM.h>
#else
#include <BlynkSTM32Ethernet_WM.h>
#endif
#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
#if !(USE_BUILTIN_ETHERNET || USE_UIP_ETHERNET)
#define W5100_CS 10
#define SDCARD_CS 4
#endif
void setup()
{
// Debug console
Serial.begin(115200);
Serial.println("\nStart W5100_Blynk on STM32 running " + String(ETHERNET_NAME) + " " + String(DEVICE_NAME));
#if !(USE_BUILTIN_ETHERNET || USE_UIP_ETHERNET)
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
#endif
#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())
{
#if USE_BLYNK_WM
Serial.print(F("Conn2Blynk: server = "));
Serial.print(Blynk.getServerName());
Serial.print(F(", port = "));
Serial.println(Blynk.getHWPort());
Serial.print(F("Token = "));
Serial.println(Blynk.getToken());
#endif
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();
}
The following is the sample terminal output when running example BI_Ethernet_Blynk on Nucleo-144 F767ZI with built-in Ethernet PHY.
Start BI_Ethernet_Blynk on STM32 running Built-in STM32 Ethernet STM32 Unknown
[1] EEPROM, sz:16384
[3] CCksum=0x0,RCksum=0x0
[6] InitEEPROM
[6621] GetIP:
[6621] IP:192.168.2.94
[6621] bg: No cfgdat. Stay
[6621] CfgIP=192.168.2.94
F[10938] SaveEEPROM,sz=16384,chkSum=0x19b4
[10938] Hdr=W5100,Auth=****
[10941] Svr=account.duckdns.org,Port=8080
[10945] SIP=nothing,BName=STM32-F767ZI-WM
[10949]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.6.1 on Arduino
[10962] BlynkArduinoClient.connect: Connecting to account.duckdns.org:8080
[10984] Ready (ping: 6ms).
[11051] run: got E&B
BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB
BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB
BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB
BBBBBBBBBB BBBBBBBBBB BBBB
Updated: Mar 2nd 2020
BlynkEthernet_STM32_WM for STM32 libraries v1.0.0
just got included into Arduino Library Manager.
Now you can install this library directly from Arduino Library Manager
Updated: Mar 3rd 2020
Releases v1.0.1
New in this version
- Fix hanging bug in STM32 boards with built-in Ethernet LAN8742A.
Updated: Mar 6th 2020
New in Version v1.0.2
- Fix crashing bug when using dynamic EthernetServer
- Enhance examples, fix indentation, update README.md
New in Version v1.0.3
- Reduce html and code size for faster Config Portal response. Enhance GUI.
- Change default macAddress for boards to avoid macAddress conflict while simultaneously testing multiple boards.