Feeding WIFI SSID, Passwords and Blynk key's via a webpage in the ESP8266 EEPROM

I don’t get what you mean

now working on a new device

*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result: 
*WM: 0
*WM: SET AP STA
*WM: 
*WM: Configuring access point... 
*WM: ESP_05529C
*WM: AP IP address: 
*WM: 192.168.4.1
*WM: HTTP server started
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root

Well I ended up doing exactly what you said, and changed the way I was looking at this problem.
Now I have all the Blynk functions loaded on the ESP8266 (an Adafruit HUZZAH) to deal with the blynk server, with an attached OLED screen to have some feedback info of what’s going on.
So now, when I get a BLYNK_WRITE(V0) command from the Blynk app, to make it reach the relay attached to the Moteino node, I just send a NODE1:RELAY1:1# protocol trough the serial port of the ESP to the serial port of the Moteino Gateway. The gateway checks for the # to find the end of the command and then checks what the command is and to what node it is for. Then it just relays the new command trough the RFM69HW radio to the Moteino node to control that relay.
And the opposite is also done in the same, but reversed manner. to send the status of a button, for instance.
The advantage of this setup is that I can now load a Webserver on the ESP and access it trough as web page to change any network data and enter the token. The Webserver is based on the Webmanager and uses a template created by Pedro Albuquerque (https://github.com/Pedroalbuquerque/template) with some changes to add the token input line. This template makes it extremely ease to use the Webserver, Just load the code as it is and you immediately get it running. The changes I made were to include the Blynk stuff in it. And it gives the ESP OTA capability. Since both the ESP and the Moteino have that OTA capability, they can be updated without any fuss.
Here is a very low quality video of my setup: https://youtu.be/Oajx46P2gNY (or click on the photo below)
I will post a much better video soon with all the details and a range check of the Moteinos.
It works flawlessly. Thank you for your suggestion.

2 Likes

@luisr320 glad you got everything up and running and took my suggestion seriously.

ESP’s really are the best way to connect to Blynk and Blynkers should make every effort possible to design their projects to connect direct with the ESP. My patented “ESP with Arduino shield” works well for anyone that needs to interface with an Arduino but “Arduino with ESP shield” should be avoided like the plague.

@Costas after read from your reply, searching about how to make arduino as shield for ESP, and still confused for how the make it on my device, could you give me some example how user software serial for controlling UNO from ESP, its very helpfull for me or another person who want make ESP can bring wifi manager also can control more pin using UNO

@Junrevol I will try to dig out one of my projects when I have time but in the meantime the best internet resource for reading Serial data is Robin2’s tutorial at http://forum.arduino.cc/index.php?topic=396450.

Combine this with the SoftwareSerial between ESP and Arduino as per https://www.arduino.cc/en/Tutorial/SoftwareSerialExample and you are good to go.

getting error as FS.H help me !!

C:\Users\shahs\AppData\Local\Temp\arduino_modified_sketch_482130\sketch_jun22b.ino:2:25: fatal error: ESP8266WiFi.h: No such file or directory

#include <ESP8266WiFi.h
getting here error please help !!!

@scientist1995 from your posts to me and @pnewb it looks like you are missing some quite basic libraries.

Provide details of your hardware and paste your sketch.

I was confronted with the problem of how to take off the code a fixed SSID and PWD when I found this post and discovered the WiFiManager.

But reading the complete topic, I don’t undestand why is not used the simple way that the WiFiManager documentation suggest.

@Costas, why your code is not using just the way suggested by the WiFiManager documentation?

I plan to start coding tomorrow, but may be I’m missing something that advices not to just use the simple way.

@lrossel as far as I remember, as stated in the thread, the sketch I provided was a straight pull from WiFi Manager. Unless you are referring to the ESP with Arduino shield method which is simply reversing the more common Arduino with ESP shield because WiFi Manager will not work with Arduino’s.

WiFi Manager is excellent but it’s so last year now. Blynk have a much better system that all takes place in the app.

@Costas, can you give a link to follow how to avoid hard coding the SSID and Pwd for the wifi connection of the ESP?

I’m usig ESP8266 standalone.

Thanks in advance.

Take a look at the following Blynk video on YouTube together with the url’s referenced below the video https://www.youtube.com/watch?v=RLKuIHaraKs

Thank @Costas

It’s looks like this video is talking about the paid blynk.io service.

The BlynkProvisioning is usable with the Blynk free version?

For sure.

Great!

Thanks a lot @Costas!

I reviewed the video and tried the Template_ESP8266.ino example.

I works great! Now I just want to modify the code in order just to input the SSID and Password, and leave the token, host and port hardcoded.

I checked the example, and it looks like I have to modify the ConfigMode.h code.

something like this:

<!DOCTYPE HTML><html>
<form method='get' action='config'>
  <label>WiFi SSID: </label><input type="text" name="ssid" length=32 required="required"><br/>
  <label>Password:  </label><input type="text" name="pass" length=32><br/>
 //     <label>Auth token:</label><input type="text" name="blynk" placeholder="a0b1c2d..." pattern="[a-zA-Z0-9]{32}" maxlength="32" required="required"><br/>
//      <label>Host: </label><input type="text" name="host" length=32><br/>
//      <label>Port: </label><input type="number" name="port" value="8442" min="1" max="65535"><br/>
  <input type='submit' value="Apply">
</form>
</html>
)html";

And to make this values fixed on this lines:

String token = server.arg("blynk");
String host  = server.arg("host");
String port  = server.arg("port");

I’ll try that!

Thanks a lot again

1 Like

That file has a structure for server and port. For the token you just decide if you want static or dynamic provisioning, no requirement to hack the form.

There is a hardware reset button in the last tab to clear credentials from EEPROM. You can also use a Blynk button to clear credentials via software but you must remember to do it before you set off to your next AP site. Alternatively you have the credentials set to your phone’s 3G shared network and then you can change to a local AP at any time via software if you don’t want to use a hardware button.

We also did some experimenting with GitHub - datacute/DoubleResetDetector: Library to detect a double reset, using ESP8266 RTC User Memory but you have to be careful as part of the provisioning includes a coded double reset.

Great to here my friend. JoeS i need ur help,if u don’t mind can u share your wifimanager code with me buddy?

Thanks for sharing the sketch.
I am in a project where it fits perfectly, as a matter of fact it is working great for me with one exception:

My light controllers work with two hardButtons 1 and 2 with micro switches pulling to 0v the GPIO12 and GPIO13 respectively of an ESP8266-12
When I combine this wifimanager to config the WIFI and AuthToken parameters, with my Blynk sketch, hardButton 2 works fine, however hardbutton 1 does NOT work anymore.
With soft button from Blynk app both work fine.

As I understand, the wifimanager is using the flash memory as EEPROM; Is it possible that there is a conflict
in the use of the memory addresses that make hard changes in GPIO12 not been recognized ???

Please folks if you have any clue I will appreciate very much
Regards