GithubHelp home page GithubHelp logo

tzapu / wifimanager Goto Github PK

View Code? Open in Web Editor NEW
6.5K 236.0 1.9K 1.54 MB

ESP8266 WiFi Connection manager with web captive portal

Home Page: http://tzapu.com/esp8266-wifi-connection-manager-library-arduino-ide/

License: MIT License

C++ 67.38% HTML 8.55% Shell 0.76% JavaScript 0.74% C 22.48% CMake 0.09%
esp8266 configuration-portal wifimanager arduino captive

wifimanager's People

Contributors

cpainchaud avatar d-a-v avatar domonetic avatar dontsovcmc avatar flavio-fernandes avatar fllaca avatar franklinvv avatar gmag11 avatar horendus avatar irwanayeah avatar ivankravets avatar j0hnlittle avatar joergaj avatar lbussy avatar liebman avatar mikdatdogru avatar mollayo avatar mrbig avatar mrthiti avatar niklaswall avatar ohadcn avatar riccibitti avatar rpseng avatar ruandv avatar sidey79 avatar taaralabs avatar tablatronix avatar thorrak avatar tzapu avatar vyruz1986 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wifimanager's Issues

Problem with MF-RC522

Does wifimanager interfeere with spi timings? I had a working code that reads rfid cards and after adding wifimanager i get timeouts when looking for a new card present ( the library returns false, but i tracked internaly that it gives a timeout status )
PS: great work!

mDNS not supported in AP mode

Hi nice idea.
Ive already implemented similar method in my project but with simple functions.
Fortunately ive found your library which has many functions similar as mine.

By the way, why are you using mDNS, as per the esp8266 arduino page this not supported in
AP mode?

ap scan speed

I am at a location where I have maybe 25 AP in range with the same name.

Sometimes the list dumps out immediately, and the page pops up.
Sometimes each one ticks by 1 every 10 seconds, and it takes forever, and the page times out.

I know i can skip scans, but why do you think this is? Maybe i can fix it since I can reproduce easily.

You have an error in WifiManager.cpp

Your library is called WiFiManager, your files are called WifiManager.h and WifiManager.cpp and the references in WifiManager.cpp - L12 - are for #include "WiFiManager.cpp"

I can't understand how this tested correctly?

Using POST instead of GET

First of all: Nice Project! Everyone who starts a Project with the ESP8266 needs this lib! :)

Just a small change:
If you use a Password-Field in the HTML to hide the Password chars,
it also makes sense to use POST in the Form-Method?!
At the Moment the "p" Argument is shown in plaintext in the url, wenn you click save...

Compile error

Hi @tzapu,
I am facing some compile errors while testing the code. The error is somewhat like this
error: 'class ESP8266WiFiClass' has no member named 'psk'

I have checked the ESP8266WiFiClass and it doesnot contain and psk member function.
I am on 1.6.5-947-g39819f0 version of esp8266-arduino.

I am working on similar thing and I have used the apboot code as reference. I am adding extra functionality like GPIO toggling for my RGB bulb.

This is my repo
https://github.com/automote/thingSocket/tree/v0.6

Move loop from autoConnect to the main loop

Hi. Thanks for a great library! I'm new to GitHub and I'm not entirely sure where to put a suggestion.

Just a suggestion for devices that could be used offline. Instead of doing a loop in autoConnect() with timeout and such, you could have the users put the server's handleClient() calls in their main loop(). This way the device can do something while offline.

Auto join open APs

Can esp8266 lib even detect this ?

Combined with strength logic, this might be neat for a roaming option.
Could also add wildcard ap matching, for example how xfinity and atts free wifi works.

public and private methods

I am reviewing the code to help with the wiki and find something I do not understand.
begin () is called by AutoConnect () but is declared public and I think it should be private.

Manually start config portal.

Hello.
I'm invoking startConfigPortal("Lamp settings") when I detect "setup" button pressed in setup() function.

This works well.

Than I have autoConnect().

If for some reason autoConnect fails to connect it enters config mode. How can I make it so that it tries to connect to this network in a loop without entering configuration portal. In short. I only want to enter configuration portal when I request it. I want autoConnect to retry connection till it succeeds.

How to do it?

Also... what is the best method to restart whole chip/program?

windows laptop failed to acquire ip after connecting.

hi, im trying the simple example from wifi manager and when i connect with my android device, it has no problem and gets the ip 192.168.4.3, can connect to 192.168.4.1 and change the settings. but when i try this with my windows laptop it gives me this ip settings:

ip 164.254.145.161
subnet 255.255.0.0
default gateway: none

it wont connect to 192.168.4.1 unless i manually set a static ip like this:

ip 192.168.4.4
subnet 255.255.255.0
default gateway: 192.168.4.1

eeprom

share settings with other data

from that address writes data occupy and how to use EEPROM to store other data?

Intermittent Wifi.begin() on ESP.reboot();

First off: awesome work on this library! It is exactly what I'm looking for.

I noticed a weird issue though. I am experimenting with the ESP8266 (Adafruit Huzzah Feather to be specific). In my experiment, I created a console application, so I could interact with it via the serial port. I'm using WifiManager as the connection framework for Wifi. I added a "command line" ability to software reboot the module using ESP.reset();

When I use this method, often times the autoConnect() call fails. That is: Wifi.begin returns 6 but Wifi.waitForConnectResult() starts to return "1", and continues to do so even if I try to run the Wifi.begin / waitForConnectResult() within a loop.

In this case, unless I actually force a disconnect using WiFi.disconnect(), then after a hard reboot, Wifi.begin() and waitForConnectResult() both start to return zero indefinitely In this state, even a hard reboot (using the reset button) in some cases doesn't correct the problem, and I need to re-upload the sketch.

The funny part is though, if I comment out autoConnect() and manually connected via Wifi.begin() inside the setup() routine, it always works, regardless of the reboot method.

I have read that ESP.reset() has its own issues, so perhaps there is something going on there, although once WifiManager fails to connect in this state, it seems that it can't instantiate the WiFi.begin() process (it always returns 0).

I'm happy to provide more info if needed?

compilation troubles

Hi,

Nice job !
i'm trying to compile on arduino ide 1.6.5 and have the following result

Arduino: 1.6.5 (Windows 8.1), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200"

C:\Users\pascal\Documents\Arduino\libraries\WiFiManager-master\WiFiManager.cpp: In member function 'boolean WiFiManager::captivePortal()':
C:\Users\pascal\Documents\Arduino\libraries\WiFiManager-master\WiFiManager.cpp:405:20: error: 'class ESP8266WebServer' has no member named 'hostHeader'
if (!isIp(server.hostHeader()) ) {
^
C:\Users\pascal\Documents\Arduino\libraries\WiFiManager-master\WiFiManager.cpp:407:82: error: 'class WiFiClient' has no member named 'localIP'
server.sendHeader("Location", String("http://") + toStringIp(server.client().localIP()), true);
^
Error compiling.

Have you an idea of the real source of hostheader / localip compilation problem ?

THX on advance for any help !
Cheers .

error: field '_server' has incomplete type

This is my Sketch:

#include <EEPROM.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <DNSServer.h>
#include <WiFiManager.h>


void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

My error during compiling process:

Arduino:1.6.6 (Windows 10), Scheda:"NodeMCU 1.0 (ESP-12E Module), 80 MHz, Serial, 115200, 4M (3M SPIFFS)"

In file included from C:\Users\Rocco\Documents\Arduino\hello_world\hello_world.ino:4:0:

 C:\Users\Rocco\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\ESP8266WebServer\src/ESP8266WebServer.h:143:15: error: field '_server' has incomplete type

   WiFiServer  _server;

               ^

exit status 1

The weird thing is that sometime I got the error and sometime I doesn't. o.O

WifiManager PubSubClient and DHT22 sensor

Hi,

Here is the code I'm trying to execute:

#include <DNSServer.h>
#include <WiFiManager.h>
#include <ESP8266WebServer.h>

#include "./libraries/DHT.h"
#include <ESP8266WiFi.h>
#include "./libraries/PubSubClient.h"

// Digital Temperature Sensor
#define DHTPIN 2     // what digital pin we're connected to
#define DHTTYPE DHT22   // DHT 22
DHT dht(DHTPIN, DHTTYPE);

// AP wifi
const char* apName = "hello-world";
// MQTT
const char* mqtt_server = "192.168.1.111";
int mqtt_port = 1883;
const char* clientUsername = "pippo";
const char* clientPassword = "ciao123456";
const char* willTopic = "...";
const char* willMessage = "...";
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[256];


void message_arrived(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");

  String mex = "";
  for (int i = 0; i < length; i++) {
    mex += (char)payload[i]; //Serial.print((char)payload[i]);
  }
  Serial.print(" - Messaggio: ");
  Serial.print(mex);


}



void setup() {
  // setup once:
  Serial.begin(115200);
  WiFiManager wifi;

  wifi.setTimeout(120); // retry after 2 minutes

  if(!wifi.autoConnect(apName)) { // timeut reached
    Serial.println("failed to connect and hit timeout");
    delay(3000);
    //reset and try again
    ESP.reset();
    delay(5000);
  } 

  // if you get here you have connected to the WiFi
  Serial.println("connected!");

  client.setServer(mqtt_server, mqtt_port);
  client.setCallback(message_arrived);

  dht.begin();

}

The last lines raises up this error:

sketch\mqtt-temperature-wifi-manager.ino.cpp.o: In function `WiFiManager::~WiFiManager()':

C:\Users\Rocco\Documents\Arduino\libraries\WiFiManager/WiFiManager.h:23: undefined reference to `PubSubClient::setServer(char const*, unsigned short)'

C:\Users\Rocco\Documents\Arduino\libraries\WiFiManager/WiFiManager.h:23: undefined reference to `PubSubClient::setCallback(void (*)(char*, unsigned char*, unsigned int))'

C:\Users\Rocco\Documents\Arduino\libraries\WiFiManager/WiFiManager.h:23: undefined reference to `DHT::begin()'

Am I wrong importing the libraries or is it a WifiManager issue?

Using PubSubClient with WiFiManager

Hello, can you give some hints how to use PubSubClient with your WiFiManager?

To init the PubSubClient a WiFiClient is given as parameter...
WiFiClient espClient;
PubSubClient client(espClient);

Works simple and fine. But how to retrieve a PubSubClient instance when using WiFiManager? If you recommend a different MQTT library it would be fine for me as well.

Thanks, Jan Christian

refactor: abstract ap scanning

Abstract wifi scanning out of handleWifi so it can be called on its own.

Probably need to abstract most of the html outputters so they can be called internally or used to callout to server->sendContent(item); externally.

make the code more portable

Failed connect to new AP after receiving Wi-Fi credentials

Failed attempt to connect to new AP after receiving user input Wi-Fi credentials.

*WM: Handle root
*WM: Request redirected to captive portal
*WM: WiFi save
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Connection result: 
*WM: 4
*WM: Failed to connect.

After I reset the Arduino board, WM seems loading credentials properly.

Storing multiple accounts

It's more an enhancement than an issue ;-)

Currently the latest network is stored in EEPROM. Would it be possible to store up to 3-4 network credentials.?

The idea is that the WifiManager can then loop thru all credentials. Would be cool when moving between some networks, e.g. use an EPS8266 at home and in company as well.

Thanks, JC

Not connecting to new WiFi without hard reset.

After calling On Demand Configuration and configuring new wifi settings via configuration portal I get.

*WM: WiFi save
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Connection result:
*WM: 0
*WM: Failed to connect.
*WM: Request redirected to captive portal

WiFi settings are good, because after hard reset module connects to this wifi without any problems.

error: 'class ESP8266WebServer' has no member named 'hostHeader'

Hi!
Excellent library, thanks for sharing!

Although, I'm not able to compile it. I'm in a Mac using the original Arduino IDE and installed the ESP8266 libraries following the steps at: https://github.com/esp8266/Arduino

Then, I've added this library, but when I try to compile the example called «AutoConnect» I get this error:

Arduino: 1.6.5 (Mac OS X), Board: "Generic ESP8266 Module, Serial, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS)"

/Users/matto/Documents/Arduino/libraries/WiFiManager-master/WiFiManager.cpp: In member function 'boolean WiFiManager::captivePortal()':
/Users/matto/Documents/Arduino/libraries/WiFiManager-master/WiFiManager.cpp:384:20: error: 'class ESP8266WebServer' has no member named 'hostHeader'
   if (!isIp(server.hostHeader()) ) {
                    ^
/Users/matto/Documents/Arduino/libraries/WiFiManager-master/WiFiManager.cpp:386:82: error: 'class WiFiClient' has no member named 'localIP'
     server.sendHeader("Location", String("http://") + toStringIp(server.client().localIP()), true);
                                                                                  ^
Error compiling.

I've seen a guy with the same issue at:
http://www.esp8266.com/viewtopic.php?p=29587&sid=0ab2ce98b8ece51d93ae1806a5aaa92c#p29587

Any advice?
Thanks again and keep up the good work :)

A better UI with Bootstrap?

I could work on a much better UI by including the Bootstrap library from the CDN, if you are okay with this.

Invalid AP password gives no warning

I've spent a few hours trying to figure out why i couldn't change the default AP SSID / password.

The module would come up with the default "AutoConnectAP" and no password,
and seemed to do so regardless of what i did.

Turns out i picked a password which was too short.

Using a password less than 8 characters results in the module using previous saved AP settings.

This is probably intended behavior, but i suggest printing a warning when using passwords <8 characters, or maybe a comment mentioning this.

Sporadic resets

When I attempt to connect to the soft access point, the module decides that it wants to reset to boot mode and then attempt autoconnecting again. This happens even when I'm running the example code.

Here's what the serial monitor displays when this occurs:

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

wdt reset
load 0x40100000, len 29156, room 16
tail 4
chksum 0xea
load 0x3ffe8000, len 2604, room 4
tail 8
chksum 0x03
load 0x3ffe8a30, len 4144, room 0
tail 0
chksum 0x57
csum 0x57
r�‚

Any idea why this happens or how I could fix this?

Newbie

Sorry for posting this here, But I don't fully understand this yet; I got the example working fine but once
the you get connected how to I use it to start a webserver, Do I refer to the WIFIManager object for the connection?
can someone point me to some examples?

Thanks

Callback when in AP mode

Others might have this need, so feel free to integrate my solution. My application has a display but no user input. It's useful to display that the device is in AP mode, waiting for configuration. I did it with a callback function: in WiFiManager.h, public:

void setAPCallback( void (*func)(void) );

and private:

void (*_apcallback)(void) = NULL;

Then in WiFiManger.cpp after WiFi.mode(WIFI_AP); I added

if( _apcallback != NULL) _apcallback();

and the obvious

void WiFiManager::setAPCallback( void (*func)(void) ) {
_apcallback = func;
}

Feel free to improve. Thanks for the handy library.

False EEPROM reading after manual restart

This library is exactly what I need but looks like it doesn't work as it should.

Module starts in AP mode. After entering SSID and password it automatically restarts and reads correct data from EEPROM and successfully connects to my WiFi router.

But as soon as I manually restart ESP-01 it reads false information from EEPROM, refuse to connect and starts AP again.

Here is what I get when restart my ESP manually:

AutoConnect
Reading EEPROM SSID
SSID: 
��?����ntX�����<script>function
Reading EEPROM Password
Password: 
 c(l){document.getElementById('s').value=l.innerText||l.textCont
Waiting for Wifi to connect
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

Could not connect to WiFi
Started Soft Access Point

WiFi connected
0.0.0.0
192.168.4.1
mDNS responder started
Server started

Add singal strength in AP listings

  • Add quality as a standard range of -50-0dbm.
    ideas ?
int getRSSIasQuality(int RSSI){
  //  int dBm = WiFi.RSSI();
  int quality = 0;

  if(dBm <= -100){
        quality = 0;
  }else if(dBm >= -50){
        quality = 100;
  } else {
        quality = 2 * (dBm + 100); 
  }
  return quality;
}

Any easy way to sort this also, client or server ?

Missing library

I have the ESP8266 Core 2.0.0 and WifiManager installed through board manager. When I go to compile the quick start sample, I get:

In file included from WifiManager_test.ino:1:0:
C:\Users\micha_000\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.0.0\libraries\DNSServer\src/DNSServer.h:3:21: fatal error: WiFiUdp.h: No such file or directory
#include <WiFiUdp.h>
^
compilation terminated.
Error compiling.

Additional settings in WiFiManager.cpp

Adding some values to set the ip address in AP Mode.

Add these lines:

IPAddress local_ip = IPAddress(10, 0, 0, 1);
IPAddress gateway_ip = IPAddress(10, 0, 0, 1);
IPAddress subnet_ip = IPAddress(255, 255, 255, 0);
WiFi.softAPConfig(local_ip, gateway_ip, subnet_ip);

to void WiFiManger::begin(char const *apName)

will set the IP Address - maybe needed in some case.

Would be great to set as parameter in main code.

Best regards.

Updated lock icon (The small things...)

Hi guys,

I've updated the lock icon and specified a size to make it HDPi compatible. Can this be added?

const char HTTP_ITEM_PADLOCK[] PROGMEM = "<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAOUUlEQVR42u2dL7QVtxOARyAQiApERcUKBKICUYFARCAqEIgKBCKioqLiiYqKmh4EAoGoQCCeQCAQFYgKxBUIRAUCUYFAICoqEAhExe+XYR+nr/Rx3727OzuzO993zqf4c5LJZjbJJrkisCbONy83v23+3LzbPDzySXPTfNZ8dYKbIx8f+ze3j/6fm82vmp95VxAARC40rzd/aN6XvlP/1fzfDP4pfaK41zxoXmt+4R0QgDXTSf9Wfyh9B5yjo++rjiJ01KCjhc+9AwawZLQD3ZD+7a4dy7tzD/GP5i/Sj1SYOgCcgg6jdUj9XPw7r4VPpR/FnPcONEAUzkk/ZNYFur/Fv5PO4bvmr9KPDM56NwDA3Jxpft180Hwr/h3SU1241GnOFe9GAbBG33Y6xI+6iOfty2aVPkECrAZdANNv6XN9plu6r6VPlEwPYNF86PhvxL9TLVEdKZEIYHHoJzzdgaeLXd6daA1qAtVEyqdECI3OXXVnXvaFPSt1ClW9GxngJHQV+4X4d5IM6n6CL70bHEDRTS2H4t8psql7JvSg0jnvBwDy8p2wwOetfjH4xvtBgFzoSTw9fef98OM/6hFmDiCBOXpAh0W+mOpnw6veDwisE/0WreffvR9y3K6uDegnQ3YTwmTokH+tJ/TWqh6uYkoAo2HIv1yZEsBgdAjJkH/5fpgSAOyMflvWIaT3wzvmodfbeHRlXLckfy/9DjodzZQjdVrTHfPisT+7efT3dR++3ujzm/Sf27zrNUY9es26AJyKzhuX9IlPpyfa0T9czqkd2epB14VQ3YGnF3noW3UjyzrvoImMjUPwSfRKLn1zej+op73ddSusdkDdfuz9VtMOpZeb6K68JSyUanJncRD+g745o17UoZ1e3/I6hI/+BtOt0Xrv39MAcfuUmuQ770BBHPRNGnFL7+/SD+2Xeolm1/xJ+pt+vGP5sZrsOVAE7xe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DsSALAkQ6lC1B2JAHgSIfSBSg7kgBwpEPpApQdSQA40qF0AcqOJAAc6VC6AGVHEgCOdChdgLIjCQBHOpQuQNmRBIAjHUoXoOxIAsCRDqULUHYkAeBIh9IFKDuSAHCkQ+kClB1JADjSoXQByo4kABzpULoAZUcSAI50KF2AsiMJAEc6lC5A2ZEEgCMdSheg7EgCwJEOpQtQdiQB4EiH0gUoO5IAcKSXBrbt9QBlRxIAjvRgYNveDVB2JAHgSP9ont+zXS80/wpQdiQB4ARummd2bNNz0icN7zIjCQAn9Hnz6inteaP5MkBZkQSARm6at6Xv7OXoAbojfYLwLhuSABBxD6s4UgIEADGzVRwpAQKAmNkqjpQAAUDMbBVHSoAAIGa2iiMlQAAQM1vFkRIgAIiZreJICRAAxMxWcaQECABiZqs4UgIEADGzVRzpAgQAMbNFHDkXIACImf3y1F5qDKfHEH182zx7ehe15U6AQCBm9NEO/dOcywECgZjRGzv0z1nYBAgGYib11qZdb3ky51KAgCBm8vpOPXNGbgUICmIGH+zYJ2fnYYDgIK7ZpxJo6P8xWrDDAEFCXKO/Sb/3Jjw/Nt8FCBjiGvxb+h9qCfvmPwn9cYlHAYKHuGQ3Mvzn3UKgiUB/nkrnLq8CBBQxstpHnjV/khm2+f4fpe8efbAIMawAAAAASUVORK5CYII=' height='16' width='16'/>";

ap doesn't show up, ip reports 0.0.0.0

I read this somewhere, maybe in the source code, I cant remember.

I get a

Entered config mode
0.0.0.0
*WM: 
*WM: Configuring access point... 
*WM: ESP457230
*WM: AP IP address: 
*WM: 0.0.0.0
*WM: HTTP server started

And my AP is never available to devices.

Do you know what causes this ?

resets

sometimes when saving I get

*WM: WiFi save
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...

Exception (28):
epc1=0x4000df2f epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000073 depc=0x00000000

ctx: cont
sp: 3fff0990 end: 3fff0ea0 offset: 01a0

Network Scan as optional parameter

Make the scan for AP as optional.
In my case there are up to 15 different Networks available - it takes a lot of time to scan and list
all these Networks - sometimes the page did not load at all, i commented out the setting and everything worked fine. So make this feature optional would be great.

Duplicate Wifi networks

Hello, when scanning in our company all Wifi networks are listed 2-3 times.

I didn't had the chance for further investigation; but I assume following reason... We have several access points providing the same Wifi network. Means we can use network XYZ inside the whole building on all floors. So, assumption is that a Wifi network is getting listed multiple times if multiple access points are in range.

Is there a chance putting all items with the same name together?

Thanks, JC

Help for send Pushover Message

Hi
first many thanks for the wifimanager, i'am very enthusiastic!
I need your support for send pushover message.
I declare first my parameters, this works perfectly, but i dont understand the void loop with my funktion when i press the button. My Arduino compiler send the following error:

sketch_jan17a.ino: In function 'void loop()':
sketch_jan17a:165: error: invalid operands of types 'const char [7]' and 'const char_' to binary 'operator+'
sketch_jan17a:166: error: expected primary-expression before '.' token
sketch_jan17a:167: error: expected unqualified-id before '.' token
sketch_jan17a:168: error: expected unqualified-id before '.' token
sketch_jan17a:169: error: expected unqualified-id before '.' token
sketch_jan17a:170: error: expected unqualified-id before '.' token
sketch_jan17a:171: error: expected unqualified-id before '.' token
sketch_jan17a:172: error: expected unqualified-id before '.' token
sketch_jan17a:173: error: expected unqualified-id before '.' token
sketch_jan17a:174: error: expected unqualified-id before '.' token
sketch_jan17a:176: error: expected unqualified-id before '.' token
invalid operands of types 'const char [7]' and 'const char_' to binary 'operator+'

my ino-file:

include <FS.h> //this needs to be first, or it all crashes and burns...

include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino

//needed for library

include <DNSServer.h>

include <ESP8266WebServer.h>

include <WiFiManager.h> //https://github.com/tzapu/WiFiManager

include <ArduinoJson.h> //https://github.com/bblanchon/ArduinoJson

define TRIGGER_PIN 0 // Defintion Dani GPIO0 Button

//define your default values here, if there are different values in config.json, they are overwritten.
const char *mqtt_server = NULL;
const char *mqtt_port = "8080";
const char *blynk_token = "YOUR_BLYNK_TOKEN";
const char *pushover_user = "Your_Pushover_User";
const char *pushover_token = "Your_Pushover_Token";

//flag for saving data
bool shouldSaveConfig = false;

//callback notifying us of the need to save config
void saveConfigCallback () {
Serial.println("Should save config");
shouldSaveConfig = true;
}

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println();
pinMode(TRIGGER_PIN, INPUT); // Definition Dani

//clean FS, for testing
//SPIFFS.format();

//read configuration from FS json
Serial.println("mounting FS...");

if (SPIFFS.begin()) {
Serial.println("mounted file system");
if (SPIFFS.exists("/config.json")) {
//file exists, reading and loading
Serial.println("reading config file");
File configFile = SPIFFS.open("/config.json", "r");
if (configFile) {
Serial.println("opened config file");
size_t size = configFile.size();
// Allocate a buffer to store contents of the file.
std::unique_ptr<char[]> buf(new char[size]);

    configFile.readBytes(buf.get(), size);
    StaticJsonBuffer<200> jsonBuffer;
    JsonObject& json = jsonBuffer.parseObject(buf.get());
    json.printTo(Serial);
    if (json.success()) {
      Serial.println("\nparsed json");

      mqtt_server = json["mqtt_server"];
      mqtt_port = json["mqtt_port"];
      blynk_token = json["blynk_token"];
      pushover_user = json["pushover_user"];
      pushover_token = json["pushover_token"];
    } else {
      Serial.println("failed to load json config");
    }
  }
}

} else {
Serial.println("failed to mount FS");
}
//end read

// The extra parameters to be configured (can be either global or just in the setup)
// After connecting, parameter.getValue() will get you the configured value
// id/name placeholder/prompt default length
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40);
WiFiManagerParameter custom_mqtt_port("port", "mqtt port", mqtt_port, 8);
WiFiManagerParameter custom_blynk_token("blynk", "blynk token", blynk_token, 32);
WiFiManagerParameter custom_pushover_user("user", "user", pushover_user, 32);
WiFiManagerParameter custom_pushover_token("token", "token", pushover_token, 32);

//WiFiManager
//Local intialization. Once its business is done, there is no need to keep it around
WiFiManager wifiManager;

//set config save notify callback
wifiManager.setSaveConfigCallback(saveConfigCallback);

//add all your parameters here
wifiManager.addParameter(&custom_mqtt_server);
wifiManager.addParameter(&custom_mqtt_port);
wifiManager.addParameter(&custom_blynk_token);
wifiManager.addParameter(&custom_pushover_user);
wifiManager.addParameter(&custom_pushover_token);

//reset settings - for testing --Die naechste Zeile wurde von Dani auskommentiert, da sonst der ESP nach jedem Stromausfall in den AP Modus faellt
//wifiManager.resetSettings();

//set minimu quality of signal so it ignores AP's under that quality
//defaults to 8%
wifiManager.setMinimumSignalQuality();

//sets timeout until configuration portal gets turned off
//useful to make it all retry or go to sleep
//in seconds
//wifiManager.setTimeout(120);

//fetches ssid and pass and tries to connect
//if it does not connect it starts an access point with the specified name
//here "AutoConnectAP"
//and goes into a blocking loop awaiting configuration
if (!wifiManager.autoConnect("myAP", "myAP")) {
Serial.println("failed to connect and hit timeout");
delay(3000);
//reset and try again, or maybe put it to deep sleep
ESP.reset();
delay(5000);
}

//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");

//read updated parameters
mqtt_server = custom_mqtt_server.getValue();
mqtt_port = custom_mqtt_port.getValue();
blynk_token = custom_blynk_token.getValue();
pushover_user = custom_pushover_user.getValue();
pushover_token = custom_pushover_token.getValue();

//save the custom parameters to FS
if (shouldSaveConfig) {
Serial.println("saving config");
StaticJsonBuffer<200> jsonBuffer;
JsonObject& json = jsonBuffer.createObject();
json["mqtt_server"] = mqtt_server;
json["mqtt_port"] = mqtt_port;
json["blynk_token"] = blynk_token;
json["pushover_user"] = pushover_user;
json["pushover_token"] = pushover_token;

File configFile = SPIFFS.open("/config.json", "w");
if (!configFile) {
  Serial.println("failed to open config file for writing");
}

json.printTo(Serial);
json.printTo(configFile);
configFile.close();
//end save

}
}

void loop() {
// put your main code here, to run repeatedly:
if ( digitalRead(TRIGGER_PIN) == LOW ) {
Serial.println("Sending..");
String PostData = "token="+pushover_token+"&user="+pushover_user+"&message=testmessage&title=testtitle";
if (WiFiManager.connect("api.pushover.net", 80)){
WiFiManager.println("POST /1/messages.json HTTP/1.1");
WiFiManager.println("Host: api.pushover.net");
WiFiManager.println("Connection: close");
WiFiManager.println("Content-Type: application/x-www-form-urlencoded;");
WiFiManager.print("Content-Length: ");
WiFiManager.println(PostData.length());
WiFiManager.println();
WiFiManager.println(PostData);
delay(100);
WiFiManager.stop();
}
}
}
Many thanks for your help!!
Cheers Dani

UserInterface

Change HTTP_HEAD to
const String HTTP_HEAD = "<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/><title>{v}</title>";
to disable user scaling.

How to get current local IP address?

This is what i tried:

  WiFiManager wifi;

  wifi.setTimeout(120); // retry after 2 minutes to connect to a wifi.

  if(!wifi.autoConnect(apName)) { // timeut reached
    Serial.println("failed to connect and hit timeout");
    delay(3000);
    //reset and try again
    ESP.reset();
    delay(5000);
  } 

  // if you get here you have connected to the WiFi
  Serial.println("connected!");
  currentIp = wifi.localIP();

But I've got the following error:

'class WiFiManager' has no member named 'localIP'

Issue compiling

I get this issue every time I try to compile with WiFiManager in my sketch

{
C:\Users\Longo\Documents\Arduino\libraries\WiFiManager-master/WiFiManager.h:113:10: note: in expansion of macro 'DEBUG_PRINT'
void DEBUG_PRINT(Generic text);
^
}

The code compiles once i remove everything WiFiManager related from the sketch, any help would be appreciated.

Thanks, M

Not working tonight...

I have the latest git pull of both esp8266com and wifimanger. I'm using the calls in setup() just like the examples and the way they've been for a month. I added the parameter to my .setAPCallback() function, but I have the same problem even if I don't set the callback. When my ESP-12 goes into AP mode I can't get the Configuration page (Android, iOS, Win7) at 192.168.1.4. The serial log looks like this:

*WM: 
*WM: AutoConnect
*WM: Reading SSID
*WM: SSID: 
*WM: 
*WM: Reading Password
*WM: Password: 
*WM: Connecting as wifi client...
*WM: Connection result: 
*WM: 0
*WM: 
*WM: Configuring access point... 
*WM: ClockAP
*WM: AP IP address: 
*WM: 192.168.4.1
*WM: HTTP server started
*WM: start loop
*WM: 204 No Response
*WM: 204 No Response
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: 204 No Response
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: 204 No Response
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: 204 No Response
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Request redirected to captive portal
*WM: 204 No Response
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal

It repeats as long as something's connected to the AP.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.