Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.

Commit 9d9143b

Browse files
authored
Version v1.0.4
***New in this version*** 1. Add configurable personalized RFC-952 DHCP hostname and setHostname() 2. Modify examples to use new feature
1 parent 968bfd8 commit 9d9143b

File tree

17 files changed

+413
-45
lines changed

17 files changed

+413
-45
lines changed

README.md

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,30 @@ EEPROM_SIZE can be specified from 256 to 4096 bytes. See examples [ESP32WM_Confi
4848
4949
```
5050

51-
Then replace
51+
Then replace `Blynk.begin(...)` with :
5252

53-
, `Blynk.begin(...)` with `Blynk.begin()` in your code. Keep `Blynk.run()`.
53+
1. `Blynk.begin()` to use default DHCP hostname `ESP8266-XXXXXX` or `ESP32-XXXXXX`
54+
55+
or to have a personalized hostname `(RFC952-conformed,- 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char)`
56+
57+
2. `Blynk.begin("Personalized-HostName")`
58+
59+
in your code. Keep `Blynk.run()` intact.
5460

5561
That's it.
5662

63+
Also see examples:
64+
1. [AM2315_ESP32_SSL](examples/AM2315_ESP32_SSL)
65+
2. [AM2315_ESP8266](examples/AM2315_ESP8266)
66+
3. [DHT11ESP32](examples/DHT11ESP32)
67+
4. [DHT11ESP32_SSL](examples/DHT11ESP32_SSL)
68+
5. [DHT11ESP8266](examples/DHT11ESP8266)
69+
6. [DHT11ESP8266_Debug](examples/DHT11ESP8266_Debug)
70+
7. [DHT11ESP8266_SSL](examples/DHT11ESP82662_SSL)
71+
8. [ESP32WM_Config](examples/ESP32WM_Config)
72+
9. [ESP82WM_Config](examples/ESP8266WM_Config)
73+
74+
5775
## So, how it works?
5876
If it cannot connect to the Blynk server in 30 seconds, it will switch to `Configuration Mode`. You will see your built-in LED turned ON. In `Configuration Mode`, it starts an access point called `ESP_xxxxxx`. Connect to it using password `MyESP_xxxxxx` .
5977

@@ -73,7 +91,8 @@ This `Blynk.begin()` is not a blocking call, so you can use it for critical func
7391
Anyway, this is better for projects using Blynk just for GUI (graphical user interface).
7492

7593
In operation, if WiFi or Blynk connection is lost, `Blynk.run()` will try reconnecting automatically. Therefore, `Blynk.run()` must be called in the `loop()` function. Don't use:
76-
```
94+
95+
```cpp
7796
void loop()
7897
{
7998
if (Blynk.connected())
@@ -83,7 +102,8 @@ void loop()
83102
}
84103
```
85104
just
86-
```
105+
106+
```cpp
87107
void loop()
88108
{
89109
Blynk.run();
@@ -144,15 +164,31 @@ Please take a look at examples, as well.
144164
145165
void setup()
146166
{
147-
Blynk.begin();
167+
// Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX
168+
//Blynk.begin();
169+
// Use this to personalize DHCP hostname (RFC952 conformed)
170+
// 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char
171+
Blynk.begin("Personalized-HostName");
148172
}
149173
150-
151174
void loop()
152175
{
153176
Blynk.run();
154177
}
155178
```
179+
### Releases v1.0.4
180+
181+
***Why this version***
182+
183+
I'm really fed-up with the unfriendly, confusing and cryptic DHCP hostnames such as `ESP_XXXXXX`, `espressif` using ChipID. Thanks to an issue opened in library ESP_WiFiManager, I decided to add this option to have built-in, yet configurable DHCP hostname to these libraries.
184+
185+
Now you can easily specify and have the friendly, identifiable, RFC-952-conformed DHP hostnames associated with your boards, such as `SmartFarm-1`, `Irrigation`, `Master-Controller`, etc. You'll be happier to have a look at your WiFi Router DHCP list.
186+
187+
***New in this version***
188+
189+
1. Add configurable personalized RFC-952 DHCP hostname and setHostname()
190+
191+
2. Modify examples to use new feature
156192

157193
### Releases v1.0.3
158194

examples/AM2315_ESP32_SSL/AM2315_ESP32_SSL.ino

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Forked from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases
88
* Built by Khoi Hoang https://github.com/khoih-prog/Blynk_WM
99
* Licensed under MIT license
10-
* Version: 1.0.2
10+
* Version: 1.0.4
1111
*
1212
* Original Blynk Library author:
1313
* @file BlynkSimpleEsp8266.h
@@ -22,8 +22,13 @@
2222
* 1.0.0 K Hoang 28/10/2019 Initial coding
2323
* 1.0.1 K Hoang 28/10/2019 Add features
2424
* 1.0.2 K Hoang 21/11/2019 Fix bug. Add features.
25+
* 1.0.4 K Hoang 07/01/2020 Use configurable personalized RFC-952 DHCP hostname in Blynk_WM v1.0.4
2526
*****************************************************************************************************************************/
26-
27+
28+
#ifndef ESP32
29+
#error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.
30+
#endif
31+
2732
#define BLYNK_PRINT Serial
2833

2934
// Not use #define USE_SPIFFS => using EEPROM for configuration data in WiFiManager
@@ -161,7 +166,11 @@ void setup()
161166
}
162167

163168
#if USE_BLYNK_WM
164-
Blynk.begin();
169+
// Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX
170+
//Blynk.begin();
171+
// Use this to personalize DHCP hostname (RFC952 conformed)
172+
// 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char
173+
Blynk.begin("AM2315_ESP32_SSL");
165174
#else
166175
WiFi.begin(ssid, pass);
167176

examples/AM2315_ESP8266/AM2315_ESP8266.ino

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Forked from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases
88
* Built by Khoi Hoang https://github.com/khoih-prog/Blynk_WM
99
* Licensed under MIT license
10-
* Version: 1.0.2
10+
* Version: 1.0.4
1111
*
1212
* Original Blynk Library author:
1313
* @file BlynkSimpleEsp8266.h
@@ -22,8 +22,13 @@
2222
* 1.0.0 K Hoang 28/10/2019 Initial coding
2323
* 1.0.1 K Hoang 28/10/2019 Add features
2424
* 1.0.2 K Hoang 21/11/2019 Fix bug. Add features.
25+
* 1.0.4 K Hoang 07/01/2020 Use configurable personalized RFC-952 DHCP hostname in Blynk_WM v1.0.4
2526
*****************************************************************************************************************************/
26-
27+
28+
#ifndef ESP8266
29+
#error This code is intended to run on the ESP8266 platform! Please check your Tools->Board setting.
30+
#endif
31+
2732
#define BLYNK_PRINT Serial
2833

2934
#include <ESP8266WiFi.h>
@@ -54,7 +59,7 @@
5459
#define BLYNK_HARDWARE_PORT 9443
5560
#else
5661
#include <BlynkSimpleEsp8266.h>
57-
#define BLYNK_HARDWARE_PORT 8080
62+
#define BLYNK_HARDWARE_PORT 8080
5863
#endif
5964
#endif
6065

@@ -127,7 +132,11 @@ void setup()
127132
}
128133

129134
#if USE_BLYNK_WM
130-
Blynk.begin();
135+
// Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX
136+
//Blynk.begin();
137+
// Use this to personalize DHCP hostname (RFC952 conformed)
138+
// 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char
139+
Blynk.begin("AM2315_ESP8266");
131140
#else
132141
WiFi.begin(ssid, pass);
133142

examples/DHT11ESP32/DHT11ESP32.ino

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Forked from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases
88
* Built by Khoi Hoang https://github.com/khoih-prog/Blynk_WM
99
* Licensed under MIT license
10-
* Version: 1.0.2
10+
* Version: 1.0.4
1111
*
1212
* Original Blynk Library author:
1313
* @file BlynkSimpleEsp8266.h
@@ -22,8 +22,13 @@
2222
* 1.0.0 K Hoang 28/10/2019 Initial coding
2323
* 1.0.1 K Hoang 28/10/2019 Add features
2424
* 1.0.2 K Hoang 21/11/2019 Fix bug. Add features.
25+
* 1.0.4 K Hoang 07/01/2020 Use configurable personalized RFC-952 DHCP hostname in Blynk_WM v1.0.4
2526
*****************************************************************************************************************************/
2627

28+
#ifndef ESP32
29+
#error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.
30+
#endif
31+
2732
#define BLYNK_PRINT Serial
2833

2934
// Not use #define USE_SPIFFS => using EEPROM for configuration data in WiFiManager
@@ -103,7 +108,13 @@ void setup()
103108
Serial.println("\nStarting ...");
104109

105110
dht.begin();
106-
Blynk.begin();
111+
112+
// Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX
113+
//Blynk.begin();
114+
// Use this to personalize DHCP hostname (RFC952 conformed)
115+
// 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char
116+
Blynk.begin("DHT11-ESP32");
117+
107118
timer.setInterval(60 * 1000, readAndSendData);
108119

109120
if (Blynk.connected())

examples/DHT11ESP32_SSL/DHT11ESP32_SSL.ino

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Forked from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases
88
* Built by Khoi Hoang https://github.com/khoih-prog/Blynk_WM
99
* Licensed under MIT license
10-
* Version: 1.0.2
10+
* Version: 1.0.4
1111
*
1212
* Original Blynk Library author:
1313
* @file BlynkSimpleEsp8266.h
@@ -22,8 +22,13 @@
2222
* 1.0.0 K Hoang 28/10/2019 Initial coding
2323
* 1.0.1 K Hoang 28/10/2019 Add features
2424
* 1.0.2 K Hoang 21/11/2019 Fix bug. Add features.
25+
* 1.0.4 K Hoang 07/01/2020 Use configurable personalized RFC-952 DHCP hostname in Blynk_WM v1.0.4
2526
*****************************************************************************************************************************/
2627

28+
#ifndef ESP32
29+
#error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.
30+
#endif
31+
2732
#define BLYNK_PRINT Serial
2833

2934
// Not use #define USE_SPIFFS => using EEPROM for configuration data in WiFiManager
@@ -103,7 +108,13 @@ void setup()
103108
Serial.println("\nStarting ...");
104109

105110
dht.begin();
106-
Blynk.begin();
111+
112+
// Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX
113+
//Blynk.begin();
114+
// Use this to personalize DHCP hostname (RFC952 conformed)
115+
// 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char
116+
Blynk.begin("DHT11-ESP32-SSL");
117+
107118
timer.setInterval(60 * 1000, readAndSendData);
108119

109120
if (Blynk.connected())

examples/DHT11ESP8266/DHT11ESP8266.ino

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Forked from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases
88
* Built by Khoi Hoang https://github.com/khoih-prog/Blynk_WM
99
* Licensed under MIT license
10-
* Version: 1.0.2
10+
* Version: 1.0.4
1111
*
1212
* Original Blynk Library author:
1313
* @file BlynkSimpleEsp8266.h
@@ -22,7 +22,13 @@
2222
* 1.0.0 K Hoang 28/10/2019 Initial coding
2323
* 1.0.1 K Hoang 28/10/2019 Add features
2424
* 1.0.2 K Hoang 21/11/2019 Fix bug. Add features.
25+
* 1.0.4 K Hoang 07/01/2020 Use configurable personalized RFC-952 DHCP hostname in Blynk_WM v1.0.4
2526
*****************************************************************************************************************************/
27+
28+
#ifndef ESP8266
29+
#error This code is intended to run on the ESP8266 platform! Please check your Tools->Board setting.
30+
#endif
31+
2632
// Not use #define USE_SPIFFS => using EEPROM for configuration data in WiFiManager
2733
// #define USE_SPIFFS false => using EEPROM for configuration data in WiFiManager
2834
// #define USE_SPIFFS true => using SPIFFS for configuration data in WiFiManager
@@ -101,7 +107,13 @@ void setup()
101107
Serial.println("\nStarting ...");
102108

103109
dht.begin();
104-
Blynk.begin();
110+
111+
// Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX
112+
//Blynk.begin();
113+
// Use this to personalize DHCP hostname (RFC952 conformed)
114+
// 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char
115+
Blynk.begin("DHT11-ESP8266");
116+
105117
timer.setInterval(60 * 1000, readAndSendData);
106118

107119
if (Blynk.connected())

examples/DHT11ESP8266_Debug/DHT11ESP8266_Debug.ino

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Forked from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases
88
* Built by Khoi Hoang https://github.com/khoih-prog/Blynk_WM
99
* Licensed under MIT license
10-
* Version: 1.0.2
10+
* Version: 1.0.4
1111
*
1212
* Original Blynk Library author:
1313
* @file BlynkSimpleEsp8266.h
@@ -22,7 +22,12 @@
2222
* 1.0.0 K Hoang 28/10/2019 Initial coding
2323
* 1.0.1 K Hoang 28/10/2019 Add features
2424
* 1.0.2 K Hoang 21/11/2019 Fix bug. Add features.
25+
* 1.0.4 K Hoang 07/01/2020 Use configurable personalized RFC-952 DHCP hostname in Blynk_WM v1.0.4
2526
*****************************************************************************************************************************/
27+
28+
#ifndef ESP8266
29+
#error This code is intended to run on the ESP8266 platform! Please check your Tools->Board setting.
30+
#endif
2631

2732
#define BLYNK_PRINT Serial
2833

@@ -105,7 +110,13 @@ void setup()
105110
Serial.println("\nStarting ...");
106111

107112
dht.begin();
108-
Blynk.begin();
113+
114+
// Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX
115+
//Blynk.begin();
116+
// Use this to personalize DHCP hostname (RFC952 conformed)
117+
// 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char
118+
Blynk.begin("DHT11-ESP8266-Debug");
119+
109120
timer.setInterval(60 * 1000, readAndSendData);
110121

111122
if (Blynk.connected())

examples/DHT11ESP8266_SSL/DHT11ESP8266_SSL.ino

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Forked from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases
88
* Built by Khoi Hoang https://github.com/khoih-prog/Blynk_WM
99
* Licensed under MIT license
10-
* Version: 1.0.2
10+
* Version: 1.0.4
1111
*
1212
* Original Blynk Library author:
1313
* @file BlynkSimpleEsp8266.h
@@ -22,8 +22,13 @@
2222
* 1.0.0 K Hoang 28/10/2019 Initial coding
2323
* 1.0.1 K Hoang 28/10/2019 Add features
2424
* 1.0.2 K Hoang 21/11/2019 Fix bug. Add features.
25+
* 1.0.4 K Hoang 07/01/2020 Use configurable personalized RFC-952 DHCP hostname in Blynk_WM v1.0.4
2526
*****************************************************************************************************************************/
2627

28+
#ifndef ESP8266
29+
#error This code is intended to run on the ESP8266 platform! Please check your Tools->Board setting.
30+
#endif
31+
2732
#define BLYNK_PRINT Serial
2833

2934
// Not use #define USE_SPIFFS => using EEPROM for configuration data in WiFiManager
@@ -105,7 +110,13 @@ void setup()
105110
Serial.println("\nStarting ...");
106111

107112
dht.begin();
108-
Blynk.begin();
113+
114+
// Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX
115+
//Blynk.begin();
116+
// Use this to personalize DHCP hostname (RFC952 conformed)
117+
// 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char
118+
Blynk.begin("DHT11-ESP8266-SSL");
119+
109120
timer.setInterval(60 * 1000, readAndSendData);
110121

111122
if (Blynk.connected())

examples/ESP32WM_Config/ESP32WM_Config.ino

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Forked from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases
88
* Built by Khoi Hoang https://github.com/khoih-prog/Blynk_WM
99
* Licensed under MIT license
10-
* Version: 1.0.2
10+
* Version: 1.0.4
1111
*
1212
* Original Blynk Library author:
1313
* @file BlynkSimpleEsp8266.h
@@ -22,8 +22,13 @@
2222
* 1.0.0 K Hoang 28/10/2019 Initial coding
2323
* 1.0.1 K Hoang 28/10/2019 Add features
2424
* 1.0.2 K Hoang 21/11/2019 Fix bug. Add features.
25+
* 1.0.4 K Hoang 07/01/2020 Use configurable personalized RFC-952 DHCP hostname in Blynk_WM v1.0.4
2526
*****************************************************************************************************************************/
2627

28+
#ifndef ESP32
29+
#error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.
30+
#endif
31+
2732
#define BLYNK_PRINT Serial
2833

2934
// Not use #define USE_SPIFFS => using EEPROM for configuration data in WiFiManager
@@ -127,7 +132,13 @@ void setup()
127132
Serial.println("\nStarting ...");
128133

129134
dht.begin();
130-
Blynk.begin();
135+
136+
// Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX
137+
//Blynk.begin();
138+
// Use this to personalize DHCP hostname (RFC952 conformed)
139+
// 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char
140+
Blynk.begin("ESP32-WM-Config");
141+
131142
timer.setInterval(60 * 1000, readAndSendData);
132143

133144
if (Blynk.connected())

0 commit comments

Comments
 (0)