项目作者: ArveLarve

项目描述 :
A base program for ESP8266, with WifiManager, OTA and a simple web server
高级语言: C++
项目地址: git://github.com/ArveLarve/ESPBase.git
创建时间: 2020-05-24T19:00:10Z
项目社区:https://github.com/ArveLarve/ESPBase

开源协议:

下载


ESPBase


A minimalistic Arduino project with WifiManager, OTA and a web server for ESP8266 and ESP32. A nice starting point for any new ESP projects.

PlatformIO and Arduino IDE

The main branch contains code for usage with PlatformIO.
If you prefer using the old Arduino IDE, the ArduinoIDE branch contains the code for this.

Dependencies

Libraires

Make sure you have installed the dependencies according to their installation instructions for your environment

How it works

Connecting to wifi

As described in the WifiManager projects documentation:

  • When your ESP starts up, it enters Station mode and tries to connect to a previously saved Access Point
  • If this is unsuccessful (or no previous network saved) it puts itself into Access Point mode and starts a configuration webpage (default ip 192.168.4.1)
  • Using any wifi enabled device with a browser (computer, phone, tablet) connect to the newly created Access Point
  • On the captive portal webpage, choose one of the access points scanned, enter a password and click save
  • The ESP will try to connect. If successful, it continues running your program

Configure the Web server

The project comes with a simple web page that displays a list of buttons.

The buttons are generated from a javascript array of strings.
The void handleJavascript() function has an example with a single button “Test” and a link to a non-existent enpoint called http://{your_ESP_IP}/led1
The html code for the demo page is available in data/index.html in this repository.
Make sure to upload the contents of the data folder using the LittleFS file upload utility

Demo page

The buttons are generated from an array of strings where the strings contain the button text and link seperated with a pipe symbol as shown here:

  1. var buttonData = ['Toggle LED|/led1']

Demo Page with a singe button