Code Monkey home page Code Monkey logo

wifimanager's Introduction

WiFiManager

Espressif ESPx WiFi Connection manager with fallback web configuration portal

⚠️ This Documentation is out of date, see notes below

Release

Build CI Status

Build CI Status Examples

arduino-library-badge

Build with PlatformIO

ESP8266

ESP32 ESP32 ESP32 ESP32

Member to Member Support / Chat

Join the chat at https://gitter.im/tablatronix/WiFiManager

Discord The configuration portal is of the captive variety, so on various devices it will present the configuration dialogue as soon as you connect to the created access point.

Works with the ESP8266 Arduino and ESP32 Arduino platforms.

Known Issues

  • Documentation needs to be updated, see #500

Contents

How It Works

  • When your ESP starts up, it sets it up in Station mode and tries to connect to a previously saved Access Point
  • if this is unsuccessful (or no previous network saved) it moves the ESP into Access Point mode and spins up a DNS and WebServer (default ip 192.168.4.1)
  • using any wifi enabled device with a browser (computer, phone, tablet) connect to the newly created Access Point
  • because of the Captive Portal and the DNS server you will either get a 'Join to network' type of popup or get any domain you try to access redirected to the configuration portal
  • choose one of the access points scanned, enter password, click save
  • ESP will try to connect. If successful, it relinquishes control back to your app. If not, reconnect to AP and reconfigure.
  • There are options to change this behavior or manually start the configportal and webportal independantly as well as run them in non blocking mode.

How It Looks

ESP8266 WiFi Captive Portal Homepage ESP8266 WiFi Captive Portal Configuration

Wishlist

  • remove dependency on EEPROM library
  • move HTML Strings to PROGMEM
  • cleanup and streamline code (although this is ongoing)
  • if timeout is set, extend it when a page is fetched in AP mode
  • add ability to configure more parameters than ssid/password
  • maybe allow setting ip of ESP after reboot
  • add to Arduino Library Manager
  • add to PlatformIO
  • add multiple sets of network credentials
  • allow users to customize CSS
  • rewrite documentation for simplicity, based on scenarios/goals

Development

  • ESP32 support
  • rely on the SDK's built in auto connect more than forcing a connect
  • add non blocking mode
  • easy customization of strings
  • hostname support
  • fix various bugs and workarounds for esp SDK issues
  • additional info page items
  • last status display / faiilure reason
  • customizeable menu
  • seperate custom params page
  • ondemand webportal
  • complete refactor of code to segment functions
  • wiif scan icons or percentage display
  • invert class for dark mode
  • more template tokens
  • progmem for all strings
  • new callbacks
  • new callouts / filters
  • shared web server instance
  • latest esp idf/sdk support
  • wm is now non persistent, will not erase or change stored esp config on esp8266
  • tons of debugging output / levels
  • disable captiveportal
  • preload wiifscans, faster page loads
  • softap stability fixes when sta is not connected

Quick Start

Installing

You can either install through the Arduino Library Manager or checkout the latest changes or a release from github

Install through Library Manager

Currently version 0.8+ works with release 2.4.0 or newer of the ESP8266 core for Arduino

  • in Arduino IDE got to Sketch/Include Library/Manage Libraries Manage Libraries

  • search for WiFiManager WiFiManager package

  • click Install and start using it

Checkout from github

Github version works with release 2.4.0 or newer of the ESP8266 core for Arduino

  • Checkout library to your Arduino libraries folder

Using

  • Include in your sketch
#include <WiFiManager.h>          //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
  • Initialize library, in your setup function add, NOTEif you are using non blocking you will make sure you create this in global scope or handle appropriatly , it will not work if in setup and using non blocking mode.
WiFiManager wifiManager;
  • Also in the setup function add
//first parameter is name of access point, second is the password
wifiManager.autoConnect("AP-NAME", "AP-PASSWORD");

if you just want an unsecured access point

wifiManager.autoConnect("AP-NAME");

or if you want to use and auto generated name from 'ESP' and the esp's Chip ID use

wifiManager.autoConnect();

After you write your sketch and start the ESP, it will try to connect to WiFi. If it fails it starts in Access Point mode. While in AP mode, connect to it then open a browser to the gateway IP, default 192.168.4.1, configure wifi, save and it should reboot and connect.

Also see examples.

Install Using PlatformIO

PlatformIO is an emerging ecosystem for IoT development, and is an alternative to using the Arduino IDE. Install WiFiManager using the platformio library manager in your editor, or using the PlatformIO Core CLI, or by adding it to your platformio.ini as shown below (recommended approach).

The simplest way is to open the platformio.ini file at the root of your project, and WifiManager to the common top-level env lib_deps key like so:

[env]
lib_deps =
	WiFiManager
[env]
lib_deps =
	https://github.com/tzapu/WiFiManager.git

Documentation

Password protect the configuration Access Point

You can and should password protect the configuration access point. Simply add the password as a second parameter to autoConnect. A short password seems to have unpredictable results so use one that's around 8 characters or more in length. The guidelines are that a wifi password must consist of 8 to 63 ASCII-encoded characters in the range of 32 to 126 (decimal)

wifiManager.autoConnect("AutoConnectAP", "password")

Callbacks

Enter Config mode

Use this if you need to do something when your device enters configuration mode on failed WiFi connection attempt. Before autoConnect()

wifiManager.setAPCallback(configModeCallback);

configModeCallback declaration and example

void configModeCallback (WiFiManager *myWiFiManager) {
  Serial.println("Entered config mode");
  Serial.println(WiFi.softAPIP());

  Serial.println(myWiFiManager->getConfigPortalSSID());
}
Save settings

This gets called when custom parameters have been set AND a connection has been established. Use it to set a flag, so when all the configuration finishes, you can save the extra parameters somewhere.

IF YOU NEED TO SAVE PARAMETERS EVEN ON WIFI FAIL OR EMPTY, you must set setBreakAfterConfig to true, or else saveConfigCallback will not be called.

//if this is set, it will exit after config, even if connection is unsuccessful.
    void          setBreakAfterConfig(boolean shouldBreak);

See AutoConnectWithFSParameters Example.

wifiManager.setSaveConfigCallback(saveConfigCallback);

saveConfigCallback declaration and example

//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;
}

Configuration Portal Timeout

If you need to set a timeout so the ESP doesn't hang waiting to be configured, for instance after a power failure, you can add

wifiManager.setConfigPortalTimeout(180);

which will wait 3 minutes (180 seconds). When the time passes, the autoConnect function will return, no matter the outcome. Check for connection and if it's still not established do whatever is needed (on some modules I restart them to retry, on others I enter deep sleep)

On Demand Configuration Portal

If you would rather start the configuration portal on demand rather than automatically on a failed connection attempt, then this is for you.

Instead of calling autoConnect() which does all the connecting and failover configuration portal setup for you, you need to use startConfigPortal(). Do not use BOTH.

Example usage

void loop() {
  // is configuration portal requested?
  if ( digitalRead(TRIGGER_PIN) == LOW ) {
    WiFiManager wifiManager;
    wifiManager.startConfigPortal("OnDemandAP");
    Serial.println("connected...yeey :)");
  }
}

See example for a more complex version. OnDemandConfigPortal

Exiting from the Configuration Portal

Normally, once entered, the configuration portal will continue to loop until WiFi credentials have been successfully entered or a timeout is reached. If you'd prefer to exit without joining a WiFi network, say becuase you're going to put the ESP into AP mode, then press the "Exit" button on the main webpage. If started via autoConnect or startConfigPortal then it will return false (portalAbortResult)

Custom Parameters

You can use WiFiManager to collect more parameters than just SSID and password. This could be helpful for configuring stuff like MQTT host and port, blynk or emoncms tokens, just to name a few. You are responsible for saving and loading these custom values. The library just collects and displays the data for you as a convenience. Usage scenario would be:

  • load values from somewhere (EEPROM/FS) or generate some defaults
  • add the custom parameters to WiFiManager using
 // id/name, placeholder/prompt, default, length
 WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40);
 wifiManager.addParameter(&custom_mqtt_server);
  • if connection to AP fails, configuration portal starts and you can set /change the values (or use on demand configuration portal)
  • once configuration is done and connection is established save config callback() is called
  • once WiFiManager returns control to your application, read and save the new values using the WiFiManagerParameter object.
 mqtt_server = custom_mqtt_server.getValue();

This feature is a lot more involved than all the others, so here are some examples to fully show how it is done. You should also take a look at adding custom HTML to your form.

  • Save and load custom parameters to file system in json form AutoConnectWithFSParameters
  • Save and load custom parameters to EEPROM (not done yet)

Custom IP Configuration

You can set a custom IP for both AP (access point, config mode) and STA (station mode, client mode, normal project state)

Custom Access Point IP Configuration

This will set your captive portal to a specific IP should you need/want such a feature. Add the following snippet before autoConnect()

//set custom ip for portal
wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
Custom Station (client) Static IP Configuration

This will make use the specified IP configuration instead of using DHCP in station mode.

wifiManager.setSTAStaticIPConfig(IPAddress(192,168,0,99), IPAddress(192,168,0,1), IPAddress(255,255,255,0)); // optional DNS 4th argument

There are a couple of examples in the examples folder that show you how to set a static IP and even how to configure it through the web configuration portal.

NOTE: You should fill DNS server if you have HTTP requests with hostnames or syncronize time (NTP). It's the same as gateway ip or a popular (Google DNS: 8.8.8.8).

Custom HTML, CSS, Javascript

There are various ways in which you can inject custom HTML, CSS or Javascript into the configuration portal. The options are:

  • inject custom head element You can use this to any html bit to the head of the configuration portal. If you add a <style> element, bare in mind it overwrites the included css, not replaces.
wifiManager.setCustomHeadElement("<style>html{filter: invert(100%); -webkit-filter: invert(100%);}</style>");
  • inject a custom bit of html in the configuration/param form
WiFiManagerParameter custom_text("<p>This is just a text paragraph</p>");
wifiManager.addParameter(&custom_text);
  • inject a custom bit of html in a configuration form element Just add the bit you want added as the last parameter to the custom parameter constructor.
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "iot.eclipse", 40, " readonly");
wifiManager.addParameter(&custom_mqtt_server);

Theming

You can customize certain elements of the default template with some builtin classes

wifiManager.setClass("invert"); // dark theme
wifiManager.setScanDispPerc(true); // display percentages instead of graphs for RSSI

There are additional classes in the css you can use in your custom html , see the example template.

Filter Networks

You can filter networks based on signal quality and show/hide duplicate networks.

  • If you would like to filter low signal quality networks you can tell WiFiManager to not show networks below an arbitrary quality %;
wifiManager.setMinimumSignalQuality(10);

will not show networks under 10% signal quality. If you omit the parameter it defaults to 8%;

  • You can also remove or show duplicate networks (default is remove). Use this function to show (or hide) all networks.
wifiManager.setRemoveDuplicateAPs(false);

Debug

Debug is enabled by default on Serial in non-stable releases. To disable add before autoConnect/startConfigPortal

wifiManager.setDebugOutput(false);

You can pass in a custom stream via constructor

WiFiManager wifiManager(Serial1);

You can customize the debug level by changing _debugLevel in source options are:

  • DEBUG_ERROR
  • DEBUG_NOTIFY
  • DEBUG_VERBOSE
  • DEBUG_DEV
  • DEBUG_MAX

Troubleshooting

If you get compilation errors, more often than not, you may need to install a newer version of the ESP8266 core for Arduino.

Changes added on 0.8 should make the latest trunk work without compilation errors. Tested down to ESP8266 core 2.0.0. Please update to version 0.8

I am trying to keep releases working with release versions of the core, so they can be installed through boards manager, but if you checkout the latest version directly from github, sometimes, the library will only work if you update the ESP8266 core to the latest version because I am using some newly added function.

If you connect to the created configuration Access Point but the configuration portal does not show up, just open a browser and type in the IP of the web portal, by default 192.168.4.1.

If trying to connect ends up in an endless loop, try to add setConnectTimeout(60) before autoConnect();. The parameter is timeout to try connecting in seconds.

I get stuck in ap mode when the power goes out or modem resets, try a setConfigPortalTimeout(seconds). This will cause the configportal to close after no activity, and you can reboot or attempt reconnection in your code.

Releases

1.0.1

Development Overview

Added Public Methods

setConfigPortalBlocking

setShowStaticFields

setCaptivePortalEnable

setRestorePersistent

setCaptivePortalClientCheck

setWebPortalClientCheck

startWebPortal

stopWebPortal

process

disconnect

erase

debugSoftAPConfig

debugPlatformInfo

setScanDispPerc

setHostname

setMenu(menu_page_t[])

setWiFiAutoReconnect

setSTAStaticIPConfig(..,dns)

setShowDnsFields

getLastConxResult

getWLStatusString

getModeString

getWiFiIsSaved

setShowInfoErase

setEnableConfigPortal

setCountry

setClass

htmleEtities

WiFiManagerParameter

WiFiManagerParameter(id,label)

WiFiManagerParameter.setValue(value,length)

getParameters

getParametersCount

Constructors

WiFiManager(Stream& consolePort)

define flags

❗️ Defines cannot be set in user sketches #define WM_MDNS // use MDNS

#define WM_FIXERASECONFIG // use erase flash fix, esp8266 2.4.0

#define WM_ERASE_NVS // esp32 erase(true) will erase NVS

#include <rom/rtc.h> // esp32 info page will show last reset reasons if this file is included

Changes Overview

  • ESP32 support ( fairly stable )
  • complete refactor of strings strings_en.h
  • adds new tokens for wifiscan, and some classes (left , invert icons, MSG color)
  • adds status callout panel default, primary, special colors
  • adds tons of info on info page, and erase capability
  • adds signal icons, replaces percentage ( has hover titles )
  • adds labels to all inputs (replaces placeholders)
  • all html ( and eventually all strings except debug) moved to strings_en.h
  • added additional debugging, compressed debug lines, debuglevels
  • persistent disabled, and restored via de/con-stuctor (uses setRestorePersistent)
  • should retain all user modes including AP, should not overwrite or persist user modes or configs,even STA (storeSTAmode) (BUGGY)
  • ⚠️ return values may have changed depending on portal abort, or timeout ( portalTimeoutResult,portalAbortResult)
  • params memory is auto allocated by increment of WIFI_MANAGER_MAX_PARAMS(5) when exceeded, user no longer needs to specify this at all.
  • addparameter now returns bool, and it returns false if param ID is not alphanum [0-9,A-Z,a-z,_]
  • param field ids allow {I} token to use param_n instead of string in case someones wants to change this due to i18n or character issues
  • provides #DEFINE FIXERASECONFIG to help deal with esp8266/Arduino#3635
  • failure reason reporting on portal
  • set esp8266 sta hostname, esp32 sta+ap hostname ( DHCP client id)
  • pass in debug stream in constructor WiFiManager(Stream& consolePort)
  • you can force ip fields off with showxfields(false) if you set _disableIpFields=true
  • param menu/page (setup) added to separate params from wifi page, handled automatically by setMenu
  • set custom root menu
  • disable configportal on autoconnect
  • wm parameters init is now protected, allowing child classes, example included
  • wifiscans are precached and async for faster page loads, refresh forces rescan
  • adds esp32 gettemperature ( currently commented out, useful for relative measurement only )

0.12

  • removed 204 header response
  • fixed incompatibility with other libs using isnan and other std:: functions without namespace
0.11
  • a lot more reliable reconnecting to networks
  • custom html in custom parameters (for read only params)
  • custom html in custom parameter form (like labels)
  • custom head element (like custom css)
  • sort networks based on signal quality
  • remove duplicate networks
0.10
  • some css changes
  • bug fixes and speed improvements
  • added an alternative to waitForConnectResult() for debugging
  • changed setTimeout(seconds) to setConfigPortalTimeout(seconds)

Contributions and thanks

The support and help I got from the community has been nothing short of phenomenal. I can't thank you guys enough. This is my first real attept in developing open source stuff and I must say, now I understand why people are so dedicated to it, it is because of all the wonderful people involved.

THANK YOU

The esp8266 and esp32 arduino and idf maintainers!

Shawn A aka tablatronix

liebman

Evgeny Dontsov

Chris Marrin

bbx10

kentaylor

Maximiliano Duarte

alltheblinkythings

Niklas Wall

Jakub Piasecki

Peter Allan

John Little

markaswift

franklinvv

Alberto Ricci Bitti

SebiPanther

jonathanendersby

walthercarsten

And countless others

Inspiration

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

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

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 :)

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'

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

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.

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?

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 .

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+9Awaw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1vFkRIgAIiZreJICRAAxMxWcaQECABiZqs4UgIEADGzVRzpAgQAMbNFHDkXIACImf3y1F5qDKfHEH182zx7ehe15U6AQCBm9NEO/dOcywECgZjRGzv0z1nYBAgGYib11qZdb3ky51KAgCBm8vpOPXNGbgUICmIGH+zYJ2fnYYDgIK7ZpxJo6P8xWrDDAEFCXKO/Sb/3Jjw/Nt8FCBjiGvxb+h9qCfvmPwn9cYlHAYKHuGQ3Mvzn3UKgiUB/nkrnLq8CBBQxstpHnjV/khm2+f4fpe8efbAIMawAAAAASUVORK5CYII=' height='16' width='16'/>";

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.

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...

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.

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

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?

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.

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.

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

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.

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

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

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

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

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.

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.

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?

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

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.

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.

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

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!

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

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.

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

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?

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?

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.

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.

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 ?

eeprom

share settings with other data

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

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.

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?

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.