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:

Solar Radiation Shield under test

The D1M & D1S solar powered weather stations heat up in direct sunlight giving an incorrectly high-temperature reading. Early results from testing an Acurite solar radiation shield are very good.

The shield is available from several online vendors although it appears to be out of stock until August 14, 2017. Check around for a good price as the same item sells for $10 to $60 from different vendors.

I inserted a D1S shield-type station into the Acurite product and hot-melt glued the solar panel to the side of the solar shield. The shield comes apart by carefully prying small plastic tabs between each layer. This makes it easy to run wires into the shield.

On sunny days, the unshielded sensor heats up by more than 20ºC (36ºF).

Since product availablility is problematic, I am going to look into the possibility of building a DIY solar shield with dollar store components.


Permanent link to this article:

Temporary Weather Station at the beach thru June 26, 2017

I’ve temporarily set up one of the IoT Kits weather stations in Bethany Beach, Delaware while here on vacation for the next week and a half. Follow it at:
73 Karl W4KRL

Permanent link to this article:

Important Weather Kit Update 16 June 2017

Some builders have noted that the markings on the XH 2-pin connector leads do not conform to the instructions.  It appears that every pair has a different set of markings. Getting the polarity of the connectors wrong, particularly for the LiPo cell connector, can damage the TP4056 charger and D1 Mini microcontroller.
It is important to note the markings on the leads and identify the positive and negative leads when the connectors are mated. It is best to write down the markings and refer to your notes when soldering the leads to the solar panel and LiPo cell. You may wish to take an extra step and use a DMM to confirm that the positive and negative connections are correct before mating the connectors.
The latest assembly manual (Version 2.2 16 June 2017) has revised instructions for the cell and panel connectors:

Permanent link to this article:

Power supply measurements

Most electronic projects operate on low voltage direct current. This is often provided by a USB connection or a battery. There are several possibilities to power a project from the 120 Vac power line. A common way is to use a wall adapter (wall wart) and feed low voltage direct current to your project through a power connector. A good feature of this approach is that the project enclosure is smaller because it does not need to house a power supply.

If you have a project that controls line power, like a Wi-Fi controlled receptacle, it is more convenient to incorporate the power supply in the project enclosure so that you do not need to connect to both the power line and a wall adapter. The solution is to include the guts of a wall adapter into the project enclosure.

Rather than taking apart a wall adapter, you can buy a phone charger kit from eBay vendors. Try searching for “diy training phone charger kit”.

According to the eBay listings, the specification is 5 Vdc at 350 mA to 500 mA with an input of 100-220 V 50//60Hz 0.3 A. This should be adequate for many Arduino and ESP8266 projects. Sadly, the supply can barely meet 170 mA.

Next step is to modify the circuit to see if the output can be raised. Short out R7 and play around with R2, R3, and C2.

Permanent link to this article:

ThingSpeak Addins

Here is a selection of MATLAB Visualizations

ThingSpeak Addins


Permanent link to this article:

HacDC/W3HAC Meeting Presentation Announcement – April 12, 2017 at 7:30 pm

Some of our members recently purchased a solar powered, Arduino programmable, weather station kit from Karl, W4KRL at the Winterfest in Annandale, VA. Due to the popularity of this kit, I invited Karl to come to our next club meeting to give a presentation all about its development, how the station works, etc. Karl has graciously accepted the invitation.

You may be surprised to learn that this is a new venture for Karl. For most of his career, as an electrical engineer, he designed large power electronics converters for rapid transit car propulsion systems. The Arduino project is the crossover between these two ventures. Planned areas of discussion include a presentation that focuses on the origin of the development of the kit, the challenge of designing a circuit board, and some of the unique technical issues involved with the design of this project.

Because of the content of this meeting, this should be of interest to not just the members of the HacDC Amateur Radio Club, but also to the general “Hackerspace”, “builder” and “maker” communities as well. All are invited and encouraged to attend.

As is the case with all of our events, there is no cost to attend. We look forward to seeing you at the meeting.

Posted on by jeff dahn

Permanent link to this article:

Di Mini (ESP8266) Wi-Fi Status Codes

The ESP8266 using the Arduino Core reports Wi-Fi status with the WiFi.status() function. The D1M-WX1 Weather Station attempts to connect to Wi-Fi every 250 milliseconds until the “Connect” status is found. If this does not happen after 15 attempts, it prints the status to the Serial Monitor.

Normally, the LED on the ESP8266 flashes five or six times until the connection is made. The LED will be dark during the six or seven seconds it takes to post the weather data on the Internet.  It will flash three times before the station goes to sleep for 10 minutes. The code is in the logonToRouter() function of the weather station sketches.

If a Wi-Fi connection can not be made, the LED will flash 16 times and the exit code will appear on the Serial Monitor. The status codes are:

0 = Idle Status – WiFi.begin() is called and remains active until the number of attempts expires (resulting in CONNECT_FAILED) or a connection is established (resulting in CONNECTED)

1 = No SSID Available – Unit is too far from the Wi-Fi access point, the SSID and/or password is incorrect, or the SSID is for a 5GHz-band access point.

2 = Scan Completed – Scanning for available networks is completed.

3 = Connected – Success.

4 = Connection Failed – The opposite of success.

5 = Connection Lost

6 = Disconnected

255 = No Shield – Used for compatibility with the Arduino WiFi Shield – not relevant to the ESP8266.


Permanent link to this article:

Use 2.4GHz Wi-Fi for weather station

The weather station kit and other Wi-Fi-based projects use the ESP8266 system on a chip. This chip supports 2.4GHz Wi-Fi but not 5GHz. If your Wi-Fi works on both bands you probably have two SSIDs. The 5GHz band SSID often ends in 5G like this – “BlackCat-5G”. When you set up the config.h file for the D1M-WX1 weather station make sure you choose the SSID for the 2.4GHz band.

Permanent link to this article:

Suggested list of tools

Our first kit, the D1M-WX1 Solar Powered Weather Station, is very easy to build because it uses only “through hole” components. Although the breakout or daughter boards mounted to the printed circuit board do contain surface mount devices (SMDs), they are all pre-soldered. Only a few basic electronic shop tools are needed to assemble the kit. You probably have all the suggested tools if you have built kits before. For the new kit builder, this list is a good place to start acquiring the tools you will be using time and again when you build more kits. See the list at Tools Needed on the D1M-WX1 projects page.

Permanent link to this article: