DareWeather Background Story
DareWeather ModulesThe LUA/HTML files used in this new version are here:
In order to minimize memory problems, all of the Lua code was compiled with the exception of 'init.lua'.
The 'Reset Password' input allows the user to reset the DareWeather device in one of two ways:
By appending the word 'json' at the end of the
DareWeather webserver URL, a valid JSON output of the
BME280 sensor values is produced -- so that other
services have the opportunity to query/use them for
The wiring scheme for the ESP8266/NodeMCU and BME280 sensor is extremely simple and was modified from the previous version:
DareWeather BuildingAfter proper wiring of the BME280 sensor, the environment/system was constructed in this way, on a host PC (normally Linux-based), and copied over to the NodeMCU using a USB data cable:
$ esptool.py --port /dev/ttyUSB0 erase_flash
$ esptool.py --port /dev/ttyUSB0 write_flash -fm dio 0x0000
$ nodemcu-tool -p /dev/ttyUSB0 upload xxxl.lua --compile
$ nodemcu-tool -p /dev/ttyUSB0 upload xxx.html
$ nodemcu-tool -p /dev/ttyUSB0 upload init.lua
$ nodemcu-tool -p /dev/ttyUSB0 fsinfo
DareWeather StartingWhen first activated, after the firmware/software has been loaded, the device initializes into a temporary 'Access Point' mode -- where a direct wifi connection is established between DareWeather and the computer used to configure the relevant parameters. Upon connection to 192.168.4.1, the web browser screen looks like this:
The user uses whatever names, settings, values, etc. preferred. If a ThingSpeak account is available (great idea!) the relevant channel and write key is entered here. For full accuracy for location and elevation (which affects barometric pressure readings on the BME280 sensor), exact lat/lon and elevation (meter) values can be entered. Alternatively, native geolocation and API services available on the web can be used to 'guess' the station location (anywhere) and elevation (Canada only). Once everything is set as desired, the 'Save Configuration & Reboot' option is clicked, and the new IP location is used.
When the DareWeather device is (re)started, the following information is sent to the serial interface (invisible to the user unless connected to a terminal display at 115200 baud using a USB data cable):
NodeMCU 188.8.131.52 built on nodemcu-build.com provided by frightanic.com
The ideal location for a DareWeather station is
indoors, in a protected area or container where the
devices and wires will not be disturbed, with good air
circulation, and away from drafts and direct
But the most fun is when the device is placed outdoors,
where a true weather station should live! :) The
electronics themselves are extremely robust as far as
temperatures are concerned -- the main issues are these:
|Having proven the technology required to
create a simple weather station with an ESP8266/NodeMCU
microcontroller and a BME280 weather sensor (see Weather
Station #1 below), it was time to try it again -- this
time sending the data stream to ThingSpeak and Ubidots (in addition to
the original Weather
My public channel page is here. Apart from the challenge/frustration of working with misbehaving NodeMCU chips, another final one was enclosing/positioning this new weather station where minimal heat buildup would occur. Despite my efforts, this station still registers hotter than Weather Station #1.
The wiring scheme for the ESP8266/NodeMCU and BME280 sensor is extremely simple:
Here is the LUA computer code that I use:
NEW! IMPROVED! Avoids hardcoding of configuration parameters. Instead, relevant parameters are solicited during initial configuration phase, and then re-used once the ESP8266 is rebooted into its regular data-serving mode. Also, web page display is now a standard feature.
It was something much different than I was used to, but I completed my first 2nd prototype IoT mini weather station (for a look at my 1st prototype version, see here). In this 2nd version, the weather station is composed of two components:
After ordering the various pieces from eBay, I finally took the time to figure out how to program (in LUA computer language) the NodeMCU ESP8266 wifi SoC (system-on-a-chip) devkit running XTOS. These devices are even simpler than the popular SBC (Single Board Computers) like the Raspberry Pi and C.H.I.P., which run a full Linux operating system i.e. the NodeMCU/ESP8266 is a SB/MC (Single-Board-MicroController) with only has 20k of memory and 4mb of storage! Like the Raspberry Pi/C.H.I.P. systems, the NodeMCU/ESP8266 is powered by a regular 5v cell phone charger.
The particular make/model of NodeMCU ESP8266 I purchased is of the ESP-12E form factor and made by LoLin, but there are many other manufacturers and form factors available with different features. I picked the one I did due to its cost, and the fact that it was a 'development' board with a USB power/data connection and lots of pins available. The pinout (but not exactly the board layout) of my board is this:
In order to actually create a mini-weather-station, I also picked out some environmental sensors -- DHT22 temperature/humidty, BMP180 temperature/pressure, and BME280 temperature/humidity/pressure. The BME280 is superior in all aspects, and I used it in the outside box, but since I had them anyways, I used the DHT22/BMP180 in the indoor box. I also ended up getting a SSD1306 128x64 pixel OLED for a display on the indoor weather box.
Here is what I used for pin connections:
The NodeMCU ESP8266 requires customized firmware to be generated, and NodeMCU Build is the site to do this. For my purposes, in addition to the defaults selected (file/GPIO/net/node/timer/UART/WiFi), I also chose BMP085 (for the BMP180, which is fully compatible with BMP85), DHT (for the DHT22), BME280 (for the BME280), U8G & I2C (for the SSD1306 OLED), but also the options MQTT for future purposes (even though it is very easy to generate new firmware):
You successfully commissioned a NodeMCU custom build from the master branch. You selected the following 14 modules:
Once the firmware was generated and downloaded to my Linux machine, I used ESPTool to upload it to the NodeCMU ESP8266 using the following command (where 'ttyUSBx' is whatever USB address the NodeMCU ESP8266 has at the time):
Here is the LUA computer code that I use for the transmitter box:
Here is the LUA computer code that I use for the receiver box:
LUATool was then used to upload these code sections to both NodeCMU ESP8266 devices using the following command (where 'ttyUSBx' is whatever USB address the NodeMCU ESP8266 has at the time):
Here is the parts list for this project:
If working, the most recent weather reading will be presented below directly from the mini weather station! Note that I have not yet been able to get the BMP180 sensor data to work with the SSD1306 OLED display -- for reasons that totally escape me.