NTP_Web_Interface_Data_Logger.ino by William M. Lucid
- Requires Wemos D1 R2 Development Board, DS3231 Real Time Clock, and BME280 Barometric Pressure, Humidity, and Temperature sensor.
1. Real Time Clock: used for 15-minute time interval, date, time stamping and day of the week. (Every Saturday, “LOG.TXT” file gets renamed to keep file size manageable and renamed in the format "LOGXXYY" XX being the month and YY being the date; a new log.txt is created after every file renaming. New “LOG.TXT” is created, after renaming the original file.)
2. Dynamic web page of current observations for last updated time and date, humidity, dew point, temperature, heat index and barometric pressure (both inches of mercury and millibars).
3. Server files are listed as web links: clicking link prompts for "Open with/Save as," "FAVICON.ICO" and "ACCESS.TXT" are listed; however, they are for internal use and cannot "Opened with/Save as" and so the result of clicking this link produces "404 page not found."
4. LOG.TXT file is appended every 15 minutes with the latest update; storing data from Dynamic web page.
5. ACCESS.TXT is a restricted file that logs Client IP address.
6. DIFFER.TXT stores the difference in Barometric Pressure for the last fifteen minutes. Only a difference of equal to or greater than .020 inches of mercury are logged with difference, date and time.
7. URL file names other than ones defined in the Sketch produce "404 page not found."
8. Audible alert from Piezo electric buzzer when there is a barometric pressure difference of .020 inches of mercury. I am interested in a sudden drop of barometric pressure in a 15-minute interval. Serve weather is more likely with a sudden drop. Difference of .020 inches of mercury point is set from my log observations and sound/audible alerts, and are not based on any known value to be associated with serve weather.
9. Two-line LCD display of barometric pressure, in both inches of mercury and millibars.
10. Graphs from "ThingSpeak.com" are accessible on web page; uses embedded iframes provided by "ThingSpeak.com."
Temperature, humidity, barometric pressure, and dew point have embedded ThinkSpeak.com graphs on one web page. The server is a Wemos D1 R2 development board, DS3231 Real Time Clock, and BME280 breakout board. Total project cost: about $15.00! The sensor is currently located indoors.
Fall of 2013, I was given an Arduino Uno project and started with a sketch to read barometric pressure using BMP280 Barometric Pressure sensor. This was interesting; however, the output was way too fast! I purchased a Real Time Clock for a timed interval between readings, also for date and time stamping when reading was taken.
Initially I used the RTCTimeEvent library of the ebl-arduino Project created by Renato A. Ferreira; later using logic and output from the RTC, for needed timed intervals, since the Ferreira RTCTimedEvent library failed to work with the Wemos board. I needed a way to store the readings. So I ordered a SD Card Shield and learned how to work with files watching Jeremy Blum’s “Arduino Tutorials”.
I really did not know much C++ programming; my background in programming was ASCII Basic. Reading Arduino library examples and merging parts of examples and referring to the book “Beginning C for Arduino” by Ph.D. Jack Purdum, I started adding the Arduino C++ code needed to accomplish tasks. It progressed to the point of needing internet connectivity. About this point, it was running low on memory. Desiring internet connectivity, I ordered an Arduino Mega 2560 R3 for additional memory and an Arduino Ethernet Shield for internet connectivity. I started work on the SdWebBrowse_Ethernet_HTTPServer.ino” project. Along the way, I asked questions on the Arduino.cc Forum. The Arduino.cc Forum, Adafruit Forum and ESP8266 Community Forum were very important in the learning experience. I learned on the Adafruit Forum about the Adafruit’s CC3000 Wireless Shield. So I purchased one and began modifying the project code, which resulted in SdWebBrowse_CC3000_HTTPServer.ino.
When it came time to order another Adafruit’s CC3000 Wireless Shield, I learned it had been discontinued. So I turned to Google searching for a replacement wireless shield and found the Wemos D1 R2 selling for under $9.00 shipped.
March 2017, I started the porting of the SdWebBrowse_CC3000_HTTPServer.ino to the Wemos D1 R2 and decided to rename project Observations_SPIFFS.ino. Observational data was collected with SPIFFS for the SPI Flash File System. Project porting went well until two necessary functions would fail to port. I returned to the ESP8266 Forum with thanks to martinayotte; the listFile and readFile functions were created. The listFile function takes the place of the function based on SDBrowse.ino that lists files as downloadable URL links. The function readFile handles all file reading.
June 2017 graphing was added to the project. ThingSpeak.com is used to produce graphs. Initially, there was only a web link to the ThingSpeak.com assigned channel number in the project. Problem with this approach was it took the client to a new web page. Improving on this using HTML iframes, two additional web pages were produced with two vertical fields on each page. Consolidating these two pages into a single web page was accomplished with a two-by-two column configuration and a “Continue” URL linked to ”Current Weather Observations” page.
Online since March 2017, this project has maintained availability and reliability. WEMOS D1 R2 development board continues to perform very well, with much better reliability than experienced with the Adafruit’s CC3000 Shield or with the Arduino Mega 2560 R3. SPIFFS system on the Wemos D1 is built into the wireless module/processor with four megabytes of memory. There is no SD card to deal with having to be reset and properly seat. Wire interference is a non-factor in day-to-day operation. Using the WEMOS D1 R2 development board has been a very good experience. This project is open source, and the code has many, reusable functions. Projects can be obtained from: https://github.com/Tech500/NTP_Time-synced_Web_Interface
Comments