New Bethany version firmware for Weather Stations

July 11, 2017

It has been gratifying to hear from the weather station builders. I took a break from hardware development while on a beach vacation in June but made some important firmware upgrades between taking the sun and eating blue crabs. A few of the changes improve the reliability of the solar power supply, fix a non-fatal error with the blinkLED routine, and provide some additional diagnostic messages. Other changes add a few enhancements to APRS and ThingSpeak and make a lot of internal cosmetic changes. New builders should use the new firmware. Users who have the kit up and running can choose to continue with the existing software, but read the changes to decide. The changes affect both the IoT‑only version and the APRS version.

Before installing the new firmware, update your Arduino IDE to the latest version. Version 1.8.3 has added a nice feature of identifying the opening curly brace “{“ when you place a cursor over a closing brace. This can help you track down the source of odd compile failures. See

Click here to download the new firmware: D1M-WX1_Weather_Station_Bethany (11 July 2017)

As always, you can follow all kit developments on the home page at

Changes in version Bethany:

  1. Corrected the digital pin for the internal LED. The LED now flashes a certain number of times to indicate status.
  2. Added verbose WiFi exit codes to logonToRouter(). The serial monitor shows the codes in plain English if the unit fails to connect. This is a good time to remember that you must use a 2.4 GHz WiFi channel.
  3. Improved logonToRouter() response to a WiFi connection failure. It will now go to sleep for one minute before retrying. Previously, it continually retried which could drain the LiPo cell if it never connected.
  4. Added averaging to readSensors(). This didn’t have as much effect as I had hoped but it seems like a good idea. The routine now averages three samples taken at 50 ms intervals.
  5. Added Fahrenheit and inches-Mercury to the serial monitor output. See item 12.
  6. Reduced the transmission of APRS telemetry definitions from every instance to a selectable span. This greatly reduces the amount of data loaded onto APRS-IS. APRS gurus say that the telemetry channel definitions need be sent only once but I find this hard to believe. The firmware now defaults to once every hour. APRS_TELEM_SPAN is set to 3600 / SLEEP_INTERVAL in the “Defaults” section of the sketch but you can change this, if you wish.
  7. Corrected a mathematical typo in the APRSpadBaro() routine. Also expanded the range of the routine to handle barometric pressure from 0 to 9999 mb, the full range allowed by APRS.
  8. Improved getNTPtime(). APRS telemetry requires a sequence number from 0 to 999 for each transmission. The number is generated by requesting a time from a random Net Time Protocol server. After some research, I found that the NTP service took more than 10 seconds to return a time in one out of 68 requests. However, the average response time was just 47 ms. There were never two consecutive failures. It was a simple matter to add a loop to try a request up to three times. The routine has been rock solid since this change.
  9. Made use of the status field of ThingSpeak to report some internal diagnostics. Instructions for using this follow.
  10. Changed the order of operations to connect to APRS-IS before ThingSpeak. This enables ThingSpeak to report APRS connection failures in the status window.
  11. Expanded the diagnostic messages shown on the serial monitor and made them uniform. Now all messages start with “APRS”, “ThingSpeak”, etc.
  12. Finally, I succumbed to the reality that we are stuck in the non-metric world. I had really hoped that sometime in my professional career we would go metric but it’s not going to happen. ThingSpeak field 8 now reports temperature in Fahrenheit so you can see this on your channel feed without any conversion routine.

Loading the New Firmware (Bethany version)

The new firmware is D1M-WX1_IoT_Bethany.ino for the ThingSpeak-only version and D1M-WX1_IoT-APRS_Bethany.ino for the APRS version. Download a combined zip file at:

This zip file contains Arduino sketches in three folders:

  • D1M-WX1_Calibration – used to test the installation of the Arduino software and calibrate the voltage sensor
  • D1M-WX1_IoT_Bethany – transmits your weather sensor data to the ThingSpeak IoT server
  • D1M-WX1_IoT-APRS_Bethany – transmits your weather sensor data to the ThingSpeak IoT server and the Amateur Radio Automatic Packet Reporting System – Internet Service (APRS-IS)

Download the zip file to your PC’s download folder and extract the contents to your Arduino sketch folder. This is usually \Documents\Arduino.

Record or print out the data in your old config.h file and manually transfer it to the new config.h file. Some default items have been moved to the main sketch and the capitalization of some variables has also changed so you must manually fill-in the config.h file.

Compile and upload the version you want to the D1 Mini in your weather station. Remember to set the PROG/RUN switch to PROG, and be sure to plug the Mini USB cable into the D1 Mini, not the TP4056. Set the switch to RUN when done.

After the firmware is uploaded, look at the output in the serial monitor (CTRL-SHIFT-M) for your interest.

Modifying your ThingSpeak channel

  • Login to ThingSpeak and select your channel.
  • Go to the Channel Settings tab and enable Field 8. Name the field “Temperature °F”. Change the label for field 1 to “Temperature °C”.
  • Enable “Show Status” and click on Save Channel.
  • Go to either your Private View or Public View and add a visualization for field 8.

Purely for Entertainment

The new sketch has many cosmetic changes – the comments are expanded and the capitalization of constants has been (somewhat) regularized. Fans of “Silicon Valley” on HBO will recognize the reason for these changes:

Permanent link to this article:

Leave a Reply