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

Commit 47f8d41

Browse files
authored
Add files via upload
0 parents  commit 47f8d41

File tree

6 files changed

+2215
-0
lines changed

6 files changed

+2215
-0
lines changed

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## Blynk_ESP_WM
2+
I'm inspired by [EasyBlynk8266] (https://github.com/Barbayar/EasyBlynk8266)
3+
4+
To help you to eliminate hardcoding your Wifi and Blynk credentials for ESP8266 and ESP32 (with / wwithout SSL), and updating/reflashing every time when you need to change them.
5+
6+
Just copy BlynkSimpleEsp8266_WM.h, BlynkSimpleEsp8266_SSL_WM.h, BlynkSimpleEsp32_WM.h and BlynkSimpleEsp32_SSL_WM.h into Blynk libraries directory (normally ./libraries/Blynk/src)
7+
8+
In your code, replace
9+
1. BlynkSimpleEsp8266.h with BlynkSimpleEsp8266_WM.h for ESP8266 without SSL
10+
2. BlynkSimpleEsp8266_SSL.h with BlynkSimpleEsp8266_SSL_WM.h for ESP8266 with SSL
11+
3. BlynkSimpleEsp32.h with BlynkSimpleEsp32_WM.h for ESP32 without SSL
12+
4. BlynkSimpleEsp32_SSL.h with BlynkSimpleEsp32_SSL_WM.h for ESP32 with SSL
13+
14+
and replace
15+
16+
, `Blynk.begin(...)` with `Blynk.begin()` in your code. Keep `Blynk.run()`.
17+
18+
That's it.
19+
20+
## So, how it works?
21+
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` .
22+
23+
<p align="center">
24+
<img src="https://user-images.githubusercontent.com/???/???.png">
25+
</p>
26+
27+
After you connected, please, go to http://192.168.4.1. You will see a page showed as below.
28+
<p align="center">
29+
<img src="https://user-images.githubusercontent.com/???/???.png">
30+
</p>
31+
32+
Enter your credentials, then click `Save`. After you restarted, you will see your built-in LED turned OFF. That means, it connected to your Blynk server successfully.
33+
34+
In operation, if WiFi or Blynk connection is lost, `Blynk.run()` will try reconnecting automatically.
35+
36+
This `Blynk.begin()` is not a blocking call, so you can use it for critical functions requiring in loop().
37+
Anyway, this is better for projects using Blynk just for graphical user interface.
38+
39+
## Prerequisite
40+
* ESP8266 core for Arduino https://github.com/esp8266/Arduino#installing-with-boards-manager
41+
* Blynk library https://www.arduino.cc/en/guide/libraries#toc3
42+
43+
## Hello World
44+
Please take a look at examples, as well.
45+
```
46+
#include <BlynkSimpleEsp8266_WM.h>
47+
48+
void setup()
49+
{
50+
Blynk.begin();
51+
}
52+
53+
54+
void loop()
55+
{
56+
Blynk.run();
57+
}
58+
```
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <BlynkSimpleEsp8266_WM.h>
2+
#include <DHT.h>
3+
4+
#define DHT_PIN 2
5+
#define DHT_TYPE DHT11
6+
7+
#define DHT_DEBUG 1
8+
9+
DHT dht(DHT_PIN, DHT_TYPE);
10+
BlynkTimer timer;
11+
12+
void readAndSendData()
13+
{
14+
float temperature = dht.readTemperature();
15+
float humidity = dht.readHumidity();
16+
17+
18+
if (!isnan(temperature) && !isnan(humidity))
19+
{
20+
Blynk.virtualWrite(V0, temperature);
21+
Blynk.virtualWrite(V1, humidity);
22+
}
23+
else
24+
{
25+
Blynk.virtualWrite(V0, -100);
26+
Blynk.virtualWrite(V1, -100);
27+
}
28+
}
29+
30+
void setup()
31+
{
32+
dht.begin();
33+
Blynk.begin();
34+
timer.setInterval(60 * 1000, readAndSendData);
35+
}
36+
37+
void loop()
38+
{
39+
Blynk.run();
40+
timer.run();
41+
}

0 commit comments

Comments
 (0)