Project served from ESP32 microcontroller.
Project served from web hosting domain.
“CameraRainGauge.ino" was developed to provide a data Logger for weather observations; that is accessible over the Internet, provides capability to manage files with file transfer protocol (FTP), over-the-air (OTA) firmware updates. two web sites, and a webRTC video feed! Project uses GPS from a “Neo” m8n, GPS module; everyday, GPS data is recorded and placed on the first line of the log file for that day. Heart of the project is task management; this is accomplished using network time protocol, (NTP) servers to set ESP32 system time. UDP packets are decoded into DOW, MONTH, DATE, YEAR HOUR, MINUTE, AND SECOND. Conditional statements; like “if ((MINUTE % 15 == 0) && (SECOND == 0))” are used to execute tasks at specified number of minutes and seconds; this statement evaluates “true” every 15 Minutes and 0 seconds. NTP is used to automatically configure time zones and if daylight saving time, logic control statements, and creation of time stamps.
Project code: https://github.com/Tech500/CameraRainGauge
Most libraries are part of the ESP32 core; version 1.0.4; used for this project.
Additional libraries:
AsyncWebServer handles “GET” requests and processing of web pages.
AsyncTCP.h // https://github.com/me-no-dev/AsyncTCP
ESPAsyncWebServer.h // https://github.com/me-no-dev/ESPAsyncWebServer
SimpleFTPServer.h // https://github.com/xreef/SimpleFTPServer
ThingSpeak.h // https://github.com/mathworks/thingspeak-arduino
TinyGPS++.h // http://arduiniana.org/libraries/tinygpsplus/ //Used for GPS parsing
BME280I2C.h //Use the Arduino Library Manager, get BME280 by Tyler Glenn
EnvironmentCalculations.h //Use the Arduino Library Manager, get BME280 by Tyler Glenn
Imported files index1-7.h make up HTML web pages: stored in memory:
Index1.h contains web page for Main Menu selection options.
Index2.h contains web page for “File Reader”; which creates the URL list of filenames
Index3.h contains web page for iframes provided by “ThingSpeak.com” for graphs.
index4.h contains web page for restarting web server.
Index5.h contains web page for contact us form.
Index6.h contains web page with java script for “File Reader”; adds header and URL options to continue.
Index7.h contains web page for displaying “Camera View” webRTC “live” video feed.
variableInput.h provides configurable options; without having to search 2024 lines of code to edit a variable.
Setup: Serial connections, WiFi, GPIO pins, interrupts, AsyncWebServer, FTP, OTA, BME280 sensor, Time configuration, and diagnostics (commented out) are configured.
Loop: repeats continuously; running tasks based on logic control statements, using timing derived from UTP packets sent from a NTP time server, used to set ESP32, system time.
Project functions:
AccessLog function logs activity; such as, ipaddress, requested web page, date and time of request
Beep function enables “SONALERT”.
All Eprom functions and rain gauge code by Haroon of Arduino.cc forum.
End function completes HTML code for all web pages.
FileStore function stores current log file at midnight and creates new log file with naming convention “LOG, MONTH, DATE, YEAR.TXT”.
GetDateTime function handles processing of NTP udp packets into useable units; hours, minutes, seconds, month, date and year.
UpdateDifference function determines difference in barometric pressure from last log entry to current log entry.
LogtoSD function date and time stamps log with data from BME280 sensor along with difference in barometric pressure, dew point and heat index.
LogWatchdog function records date and time of watchdog event; writes to “WIFI.TXT.”
NotFound function processes the selected URL filename from the “File Reader” filename list; for selected file content, to be displayed.
Speak function sends data to “ThingSpeak.com” for graphing and retrieval of iFrames, produced from graphs; used to display on web page.
SmartDelay function gets GPS data from “NEO” M8N GPS module; after “good” GPS fix.
WebInterface function sends data every 15 minutes to a domain hosted web site.
Wifi_Start function handles process of starting WiFi in Setup and in reconnects.
Files created by project:
"ACCESS.TXT" log includes date, time, ipaddress, and web URL request.
"LOGXXYYZZZZ.TXT" log files; naming convention “LOG”, month, date, and year.
"README.TXT" lists features of project.
"WIFI.TXT" logs events: WiFi disconnects, WiFi reconnected, watchdog events, and ESP32 Starts with date, time. Main Menu:
Project web pages:
Main Menu web page (“index1.h”):
File Reader web page (“index2.h”):
Processing of the “File Reader” web page is by AsyncWebServer:
“Main Menu” selection, “File Reader” request, loads HTML2 (“index2.h”) web page by “Processor2”; which creates the list of filenames as URL links. Function “String notFound(AsyncWebServerRequest *request)” code by Pablo2048 of “Github.com” processes selected URL link, filename into a SPIFFS, filename and returning the filename (“fn”). Request->redirect("/Show"); loads HTML6 (“index6.h”) web page by “Processor6”. HTML6 has embedded Java script from Sara Santos of "Random Nerd Tutorials"; which “GETS” request “/get-file” to display contents of the selected “File Reader” filename. HTML6 adds web page title, header and links; for return to “File Reader” and “Main Menu” links.
Graphed Weather Observations web page (“index3.h”):
Graphs of weather observations are provided by “ThingSpeak.com.” Web page “iframes” are created and made available by “ThingSpeak.com. Following the graphed line with the mouse on the web page; pops up a text box with value and time stamp of data point. Datapoints are at a fifteen-minute interval.
Camera View (“index7.h”):
Camera used for video streaming is a Wyse Cam v3. My method of video streaming is a little different; with a Raspberry Pi 4 running Portainer with a Docker container, “WyzeBridge.” This “Wyze-Bridge” interfaces with your “Wyze” account; using your “Wyze” account credentials to capture the H.264 video stream and provide URL’s that can be embedded in a web page. “Wyze-Bridge” is specific to the “Wyze” cameras and does not need “Wyze” RTSP firmware.
Previously I used a Windows 11 computer to run Unreal Media Server, 24/7 consuming around 300 Watts per hour. Switching to Raspberry Pi saves 290 Watts per hour. UMS provided RTSP URL that was embedded in HTML web page.
Current Live view of Wetland Pond behind our home.
Live view web page is served from ESP32 running “CameraRainGauge” which receives URL from Docker container, “Wyze-Bridge” running on Raspberry Pi 4.
Researching replacing 10, 000 mA power bank; with solar panel, charger, and battery. Power bank provides; roughly twenty-four hours of power,
WIFI event logging:
“WIFI.TXT” selection request; log file displays following events: ESP32 Starts, Wi-Fi disconnects, Wi-Fi reconnects, Brownouts, and Watchdog. Each event is time stamped. “WIFI.TXT” is deleted daily.
“Readme” file:
“Readme” option; request displays features of project.
ESP32, AsynceWebServer on stripboard:
AsyncWebServer Fritzing
Thank you:
Project would have been impossible without the help of people from community forums; Arduino.cc, Adafruit.com, ESP8266.com, Github.com. and Random Nerd Tutorials.com. Project started, fall of 2012 with a Barometric pressure sensor library example, sketch; when a friend gave me an “Arduino Uno” and has evolved into this project. Thank you to all persons that have helped with the project.
Comments