A library for configuring Wifi and Blynk credentials dynamically

Hi guys, I’ve made a small wrapper library. It helps you to configure your credentials without hardcoding them.

link: https://github.com/Barbayar/EasyBlynk8266

EasyBlynk8266

If you are hardcoding your Wifi and Blynk credentials, and reflashing everytime when you need to change them, please stop it, seriously. I was like that before, but one day I woke up, and said enough is enough.
I understand that if you do Arduino as a hobby, it’s quite difficult to make time to write unnecessary features. But, with this library, you can do it without writing any extra code. Just replace, Blynk with EasyBlynk8266 in your code, then it should just work fine, technically.

So, how it works?

If it cannot connect to the Blynk server in 30 seconds, it will switch to Configuration Mode. You will see your built-in LED (if you have one) flashes every second. In Configuration Mode, it starts an access point called EasyBlynk8266-Config, like below. Connect to it.

After you connected, please, go to http://192.168.1.1. You will see a page showed as below.

Enter your credentials, then click Save. After you restarted, you will see your built-in LED flashes 3 times. That means, it connected to your Blynk server successfully.

Prerequisite

Hello World

Please take a look at examples, as well.

#include <EasyBlynk8266.h>

void setup() {
    EasyBlynk8266.begin();
}


void loop() {
    EasyBlynk8266.run();
}
3 Likes

Thanks.
But be aware that this functionality is available in Blynk out of the box: https://github.com/blynkkk/blynk-library/tree/master/examples/Blynk.Inject
:slight_smile:

  • With Blynk.Inject you have bonus that the Blynk App can actually set up your device automatically.
  • We currently support ESP8266, ESP32, Arduino MKR1000 and MKR1010, TI CC3220.
1 Like

Oh, I should have done more research on Blynk, before I implement it. Thanks for the info.

1 Like

Strange choice of default IP address, as it’s also the default for probably 99% of domestic routers. Easy enough to change by editing the .cpp file, but a strange choice nonetheless.

Pete.

2 Likes

Hi Pete. I’ve chosen 192.168.1.1, because it is easy to remember. 192.168.1.1 is the ip address only when it’s in Configuration Mode. When you finished configuration, it will use an ip address what your wifi router gives. So, there won’t be any conflict.

Barbayar

Obviously when the computer/phone/tablet that you’re using to configure the ESP is connected to the EasyBlynk8266-Configured network there will be no conflict, but you have to consider that this config system may be used by people who aren’t very tech savvy.
If the ESP times-out of Station mode, then the computer being used will really-connnect to the default Wi-Fi network and the user will be presented with the login screen/homepage for the router. The same thing will occur of the user moves out of Wi-Fi range of the ESP, or if the ESP has its power interrupted or if the reset button is pressed. Whilst the ESP may go back in to config mode, the computer won’t reconnect to it by default.

Whilst 192.168.1.1 may be easy to remember for you and me, it’s just a string of numbers and punctuation for most people.
I just think that using an IP address that is extremely unlikely to reach alternative any network device would make it much easier for people to realise that they’d done something wrong and start the config process over again, rather than hitting an actual device and being asked for a username and password.

Maybe I’ve just spent too many years trying to provide phone support to people that do the weirdest things :roll_eyes:

Pete.

1 Like

Yup… bin der, dun dat, have the scars :face_with_head_bandage: Even spent a few years being tech support for the field techs… amazing what they didn’t know at times :stuck_out_tongue:

1 Like

Hi Pete,
Thank you for taking your time to give a feedback. Honestly, I didn’t think of that situation. I’ll consider to change the IP address in my next commit.

Best,
Barbayar

1 Like

what mr. @vshymanskyy have commented is for the paid versions right ? for the free versions we cant use the blynk.inject out of the box am i correct , Im sort of confused? @Barbayar :thinking:

1 Like

I believe that is the case yes. Commercial only.

1 Like

Im having a small issue with blinking an led while my device is trying to connect do you know any libraries that worth looking into @DaleSchultz ? im sort of a noob to this field .

I use WifiManager but it does not offer any LED blinking that I recall.

I use Ticker, which is non-blocking and it’s great.
Just be aware that the ticket frequency ius in seconds, not milliseonds. You can specify down to 0.1 seconds though, which is plenty fact enough for flashing an LED.

The other thing to consider is that when you’re flashing an LED while waiting for something (like Wi-Fi connection) to complete, the task could complete while the LED is either on or off. If you want the LED off after the completion of the process then you need to set it off at the end of the process to be 100% certain.

Pete.

1 Like

Thanks a lot i will read more info about Ticker and ill try to give it a go .:heart_eyes:

There’s an example of how to use the Ticker library in the code in this post:

Pete.

2 Likes

Thanks for the ticker library @PeteKnight i see what i can do with that