Coder Social home page Coder Social logo

unclegrumpy / wifiquick Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 158 KB

ESP32/8266 Arduino/PlatformIO library that painlessly enables incredibly fast re-connect to the previous wireless network after deep sleep.

License: MIT License

C++ 100.00%
esp32 esp8266 deepsleep wifi ardiuno platformio library

wifiquick's Introduction

WiFiQuick

ESP32/8266 Platformio/Arduino library that painlessly enables incredibly fast re-connect to the previous wireless network after deep sleep.

This library uses RTC RAM to store all the settings, so it will be saved during sleep as long as power is not lost. This method is much faster than the native Arduino one, which saves some of this information in a special segment of flash. Not only is this method faster, but it also eliminates those write cycles, saving flash wear and lowering power consumption. The biggest time saver is eliminating the need to do a network scan before connection. A smaller but still not insignificant amount of time is saved by saving the previously issued ip address, gateway, netmask, and dns server so that dhcp is not used for connections after the first time. The WiFiQuick.begin() has a default timout of 10 seconds, this can be changed by supplying a time in seconds as its final or only argument depending on how you choose to initiate the connection.

Installation

ArduinoIDE:

  • Clone or download and extract this repository into your Arduino libraries folder.

Platformio:

  • Install or add "winford/WiFiQuick" to your project using the pio library manager.
  • add to project platformio.ini file like:
lib_deps = 
	https://github.com/UncleGrumpy/WiFiQuick.git

Usage

A growing collection of samples are included. In ArduinoIDE they will show up in the usual menu:

File > Examples > WiFiQuick

The simplest usage looks like:

#include <WiFiQuick.h>

const char* ssid = "NETWORK_NAME";
const char* password = "PASSWORD";

WiFiQuick WiFiQuick;

void setup() {

  // Start connection...
  WiFiQuick.begin(ssid, password);

}

void loop() {

  // You can safely add RF_DISABLED as a second argument to leave WiFi off
  // when the ESP first wakes up. WiFiQuick will turn it back on before connecting.
  ESP.deepSleep(10e6);
}

There are two basic methods of starting a connection. WiFiQuick.begin() should work very much like you would expect. Using this function like in the example above will start a connection.

Method 1

WiFiQuick.begin(ssid, pass);

For Static IP it looks like:

WiFiQuick.begin(ssid, pass, IP, gateway, netmask, dns);

or for a longer timeout:

WiFiQuick.begin(ssid, pass, IP, gateway, netmask, dns, 30);  // 30 second timeout 

Method 2

You can start the connection, but not wait for it to finish. This might be useful if you are trying to optimize your run time. Just be sure to include delays to give time to the wifi to negotiate the connection, and avoid anything processor heavy. This is started with the init() method, but must still include the begin() function to make sure your settings are stored for faster re-connection next time.

WiFiQuick.init(SSID, PASSWORD);  // starts the connection

/* do some other stuff... */

WiFiQuick.begin();	// returns "true" if connection is successful
			// saves your netinfo for faster connection next time.

Or for static IP:

WiFiQuick.init(SSID, PASSWORD, IP, gateway, netmask, dns);  // starts the connection

/* do some other stuff... */

WiFiQuick.begin(30) // 30 second timeout.

WARNING

Make sure your board is set up to wake from DeepSleep! For example...

  • D1 Mini > connect D0 to RST.
  • ESP12-F > connect GPIO16 to RST
  • ESP01 > see here: https://blog.enbiso.com/post/esp-01-deep-sleep/ to make the necessary modifications.
    • For this modification I personally like to use conductive paint and a sharp needle to apply it...

wifiquick's People

Contributors

unclegrumpy avatar

Stargazers

 avatar

Watchers

 avatar

wifiquick's Issues

ESP32 not connecting as fast as it should.

Tests with ESP32 lead me to believe that wifi persistence is not being completely disabled. The connection times are completely unaffected by setting WiFi.persistence() to true ore false. setting it to false should greatly increase connection time under normal circumstances, which it does not. changing the value to true or false makes no difference in connection times using this library or not, so there must be more required to fully disable it.

Fails on ESP32!

This does not work with esp32. The way that RTC RAM is used is completely different. I am investigating this...

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.