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

@luisr320 WiFiManager is an excellent library but as the name suggests it manages WiFi connections and is intended for ESP’s in standalone mode.

Are you able to redesign your project to use what many consider to be the best Blynk connection method, ESP in standalone mode?

Standalone mode doesn’t have to mean that you can only use the ESP in isolation. You can still hook it up to an Arduino if you think an Arduino offers something an ESP doesn’t.

Thank you for your comment.
The problem with the Wifi modules, all of them, is range. I have a 3 floor house and I need a wifi router in every floor to get a reliable internet connection. So why do people insist on using standalone ESP modules as the holly Grail of IOT?

With my solution, all I need is a simple ESP8266-1, to stand next to one of my wifi routers and act as a gateway for all the nodes that I may scatter around in my house.
I have one of those Moteinos ( an arduino Uno with a packet radio ) inside the bonnet of my car connected to the high beam lights and when I approach my house I just flash the high beams and all gates and garage doors open.
And I can pick up the temperature sent from my boiler on the 3 rd floor with ease.
You just can’t do that with Wifi. So I think that having a gateway setup like the one I propose e a much viable option to connect stuff around the house. IOT style.

Blynk brought a new level to my idea. A practical and very easy to setup interface for activating all kinds of stuff, from garage doors to the garden lights. Having a Moteino taking care of the logic and data comunnications just makes everything come together in a very simple way. Moteinos are full open source that you can make on your own without paying a cent, supported by a community very keen to help anyone who wants to learn how to use it. By the way, I’m in no way associated with Lowpowerlab.com.
There is another device like this, in fact it is a Moteino clone, the Anarduino. I have never tried those, but supposedly they do exactly the same. Not sure if they are full open source, though.

My next step on this project, the one that I’m missing, is a simple way to connect to an existing wifi network without having to hardcode the ssid, pass and token. That would really make an already very useful IOT gadget very simple to implement and use.

I guess the best approach would be to have the Moteino check if a wifi connection is already made and if not, serve a simple web page with a preset IP to allow the input of what ever router is available, and then store that data in the EPROM, or even the FLASH that Moteinos have and fire up the Blynk sketch to allow control of the nodes.
Oh, and you can reprogram a Moteino Over-The-Air, in case you implant it inside a wall, or a car bonnet.

I’ll try to post a video showing the range and the potential of this setup.

My car garage remote project in hackaday: http://hackaday.com/2015/04/08/blink-thrice-to-let-me-in/
And my project posted at Lowpowerlab.com forum: https://lowpowerlab.com/forum/projects/project-gate-garage-controlled-by-car-lights-(photos)

2 Likes

Hi Costas, thanks for the code, so that is the way to get “ssid, pass and auth token” from web browser (as AP) or there is another easier way, maybe with less lines?

@alvaroaguero55 there are other ways to do the same thing as WiFiManager but it’s regarded as the defacto tool for what you want to do.

As far as the number of lines are concerned I personally wouldn’t worry too much. You can comment out most of the Serial print() lines and remove them altogether if you wish.

As long as you have a basic understanding of what WiFiManager is doing you can also remove the lines that are already just comments.

All the Ticker stuff can be removed too as this is just a visible indicator of what is happening. Some people use it, others just watch Serial Monitor etc.

hello @Costas, its sound interesting if we can program ESP standalone and can still hook it up on arduino.
i have project make Smart power strip using UNO and ESP8266-01 as shield, i want add wifiManager so i can change to another AP easly, but i know WifiManager just for ESP standalone. like you said before we can program ESP standalone and can still hook to arduino, its can give WifiManager feature and give Wifi connection to UNO, can you explain to me how make that possible??

@Junrevol look up the SoftwareSerial library. It’s actually used for ESP as a WiFi Shield but can be used “in reverse” for “ESP with Arduino shield”. There is actually a port designed specifically for ESP’s at https://github.com/plerup/espsoftwareserial but in our last project that we set up as an “ESP with Arduino shield” we just used the regular SoftwareSerial library and it was fine.

I notice you are planning to use the ESP-01 which has a very limited number of pins. You can use the RX and TX pins of the ESP-01 providing you have switches to “disconnect” the SoftwareSerial connection during flashing. You can also do one way SoftwareSerial to save a pin if required i.e. just ESP to Arduino rather than a 2 way link.

Do remember that most Arduinos run at 5V and ESP’s are 3.3V so technically you need a voltage divider between the Arduino’s TX and the ESP’s RX pins. If you are just doing “one way”, ESP TX to Arduino RX, then you don’t need a voltage divider.

Espressif’s Chairman has gone on record as saying his products are 5V tolerant and that it was a mix up in translation but I’m not sure if that applies to the original ESP-01’s.

1 Like

@Costas
Hi
I am getting errors with Wi-fi Manager and i don’t know the cause.
I am using ESP-01 1M flash the (black version) also i don’t know the correct SPIFFS to use with WM.

*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster

Exception (0):
epc1=0x40220d00 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: sys 
sp: 3ffffe00 end: 3fffffb0 offset: 01a0

>>>stack>>>
3fffffa0:  3ffea390 40000f49 3fffdab0 40000f49  
<<<stack<<<


   ets Jan  8 2013,rst cause:2, boot mode:(3,0)

    load 0x4010f000, len 1384, room 16 
    tail 8
    chksum 0x2d
    csum 0x2d
    v3de0c112
    ~ld

     ets Jan  8 2013,rst cause:4, boot mode:(3,0)

    wdt reset
    load 0x4010f000, len 1384, room 16 
    tail 8
    chksum 0x2d
    csum 0x2d
    v3de0c112
    ~ld

@Ze_Pico WiFiManager only holds a few bytes in SPIFFS (i.e. Blynk token) so any size from the 64Kb minimum upwards is fine.

Dig out a sketch to format SPIFFS if you don’t know where the setting is in WiFiManager and try again.

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.