Chat freely about anything...

User avatar
By Sirquil
#84560 11/14/2019, Version 2.3

Project has now been coded to use the AsyncWebServer library while retaining all but one feature of the earlier versions. OTA will now be become a standalone sketch; if needed. All editing to setup project on your network is done in small, short configuration file: "variableInput.h" , located in the Sketch folder.

Async Web Server: Rain_Gauge_Two project

Project is Open Source. I could not have completed this code without the help of others, commented sections of the code with reference to those that have helped with the project. Special thanks to Pavel for his help and patience with my questions.


William
Attachments
Async Web Server version of "Rain_Gauge_Two.zip" posted here previously...
(14.3 KiB) Downloaded 86 times
User avatar
By Sirquil
#84571 Project supports all previous features except OTA firmware updates; which if needed can be a stand alone sketch using the example from:

AsyncElegantOTA

There are six files in "Rain_Gauge_Two.zip:" index1.h, index2.h, index3.h, index4, variableInput.h, and Rain_Gauge_Two.ino. Unzip to folder on Desktop; double click "Rain_Gauge_Two.ino" after editing "variableInput.h" for you networking requirements/credentials. All files are required. Index files are "templates for web pages" and may contain "Placeholders" referenced in sketched "processor" functions.

New feature; we can now restart the sketch remotely! To restart server; send a URL request of "publicIP:LISTEN_PORT/Restart" example URL request: "68.xx.xx.xx:5999/Restart"

Async Web Server version of "Rain_Gauge_Two" project

Note, there is a correction factor for Barometric Pressure in the "getWeatherData" function. Getting correction factor is commented in the "getWeatherData" function.

Formula is: Relative Pressure (in millibars) equals Absolute Pressure (BME280, in millibars) plus (elevation in meters divided by 8.3).

William
User avatar
By Sirquil
#84620 11/23/2019

Added support for login and update (firmware updates; see comments in "variableInput.h".)

Found SPIFFS was getting corrupted; I believe by writes to the log file, while Server was sending request. Added a flag to give priority to logging to SPIFFS. So far, responses have been good.

Additional files are included in the "Rain_Gauge_Two.zip." Files for sending data to Domain hosted web page ("dataCollector.php"), Schematic for optocoupler ("Rain Gauge 4N25 Circuit.jpg"), Schematic for beep function ("Sonalert circuit.png"), and a couple of read me files.

ESP32, Async Web Server; project web site

William
Attachments
ESP32 Async Web Server; project version 2.4
(407.69 KiB) Downloaded 40 times
User avatar
By Sirquil
#85040 12/24/2019

AsyncWebServer Library

Why should you care:

Using asynchronous network means that you can handle more than one connection at the same time
You are called once the request is ready and parsed

When you send the response, you are immediately ready to handle other connections while the server is taking care of sending the response in the background

Speed is OMG

Easy to use API, HTTP Basic and Digest MD5 Authentication (default), ChunkedResponse

Easily extendible to handle any type of content

Supports Continue 100

Async WebSocket plugin offering different locations without extra servers or ports

Async EventSource (Server-Sent Events) plugin to send events to the browser

URL Rewrite plugin for conditional and permanent url rewrites

ServeStatic plugin that supports cache, Last-Modified, default index and more

Simple template processing engine to handle templates

____________________________________________

There are six files in "Rain_Gauge_Two.zip:" index1.h, index2.h, index3.h, index4, variableInput.h, and Rain_Gauge_Two.ino.  Unzip to folder on Desktop; double click "Rain_Gauge_Two.ino" after editing "variableInput.h" for you networking requirements/credentials.  All files are required.  Index files are "templates for web pages" and contain "Placeholders" referenced in sketched "processor" functions.

Online, Async Web Server version of "Rain_Gauge_Two" project

Note, there is a correction factor for Barometric Pressure in the "getWeatherData" function. Correction Factor Formula is:  Relative Pressure (in millibars) equals Absolute Pressure (BME280, in millibars) plus (elevation in meters divided by 8.3).

"Rain_Gauge_Two.zip" is in previous POST

William