|
| 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 | +``` |
0 commit comments