Software setup and configuration information

Software Location

https://github.com/jhughes1010/weather

Release History

Version log on master branch and notable development commits

Date

Version

BRANCH

Comments/Known issues

Date

Version

BRANCH

Comments/Known issues

Aug 8, 2021

0.9

Master

Initial release for basic user testing and feedback.

Known issues:

  • Wind vane does not register all 16 positions (with 2 switch closure) on my wind vane. 2 entries are set to “000”

  • Thingspeak code not tested yet

Aug 8, 2021

1.0

Master

Thingspeak operational, low battery voltage code corrected.

Aug 13, 2021

1.1 (release candidate)

Develop

Math error corrected in wind speed measurement. IRAM_ATTR added in ISRs to move interrupt code processing to SRAM per ESP32 documentation. Testing now.

Aug 14, 2021

1.1 (release candidate)

Develop

Found an attribute to copy ISR to SRAM. Code is stable at 1000 boot cycles now. WDT code added for 60s watchdog.

Aug 14, 2021

1.1

Master

Develop merged to master for 1.1 release

Aug 25, 2021

1.2 RC1

Master

  • Refactoring weather.ino

  • I2C EEPROM support option for higher reliability

  • photoresistor support for Thomas Krebs designed PCB

  • offset added on WAKE timing to ensure fresh data reporting for display unit (MQTT subscriber)

Aug 25, 2021

1.2 RC2

Master

  • Resolved 2 missing directions (I never see these though)

Software Installation

Ensure you download from the MASTER branch. I’m actively working on DEVELOP.

  1. Create a folder called ‘weather’ where you keep your Arduino projects

  2. Download files from GitHub and place them all inside the weather folder

  3. rename sec.h to secrets.h

    1. this file contains WiFi details, api keys for internet data destinations, and configuration options

    2. I’m actively working on this project and secrets.h contain my specific information

Software Configuration

secrets.h

//=========================================== //Controls supression of the MonPrintf function to serial //=========================================== #define SerialMonitor

line #4 contains a flag that controls printing to the serial console. I use it for debug, but commenting this line out can save time when the processor is drawing high current by suppressing all serial printing.

WiFi and data destination parameters

 

//=========================================== //WiFi connection //=========================================== char ssid[] = "ssid"; // WiFi Router ssid char pass[] = "password"; // WiFi Router password //=========================================== //Blynk connection //=========================================== char auth[] = "Blynk_password"; const char* server = "api.blynk.com"; //=========================================== //Thinkspeak connection //=========================================== //const char* server = "api.thingspeak.com"; const char* api_key = "THinkspeak_API_key"; //=========================================== //MQTT broker connection //=========================================== //const char* mqttServer = "test.mosquitto.org"; const char* mqttServer = "your_MQTT_broker"; const int mqttPort = 1883; const char* mqttUser = "username"; const char* mqttPassword = "password"; const char mainTopic[20] = "MainTopic_for_MQTT_subtopics to reside/";

Units of measure

Comment this #define to use imperial measurements

//=========================================== //Metric or Imperial measurements //=========================================== #define METRIC

Frequency for station wake and sending of data

I’m publishing data to an e-ink display, so 15 min updates are fine for my needs. Set it to what you desire, but remember weather conditions do not change that rapidly.

Wind speed measurement

I had an interesting observation where my anemometer closes the switch we use to observe revolutions twice instead of once per revolution.

Setting IOT data destination

You need to chose Blynk or Thingspeak, but not both. MQTT is optional and can be commented out if not used.

Please be certain to comment out the #define MQTT if you are not using it. It may cause RESET issues with the ESP.

Battery Voltage Monitor Calibration

This is the calibration factor for the ADC pin that monitors the battery voltage via the voltage divider pin. There are non-linearities in the ADC and we are not supplying a reference voltage. Much easier to just make the math work.

  1. Measure voltage at the battery

  2. Locate the ADC reading via MQTT

  3. Divide battery voltage by ADC value

  4.  

Enabling of optional I2C NVM

I added an I2C based EEPROM for backup storage of rainfall history data. There are situations where the controller can RESET that are out of my control. For instance, if my MQTT broker goes offline, the unit will RESET. I decided to use EEPROM memory outside the ESP32 to absolutely ensure I do not run into write endurance concerns.