There are two historical files that WUHU maintains.

“WUHU History.dat” is for internal use by WUHU.

It’s basically an image of the memory in case of power failure. It contains every reading your station has made in the past X hours where X is set in your general settings. You can specify up to 1 week of data that can be kept in memory. This setting effects how much data you can chart and display statistics for.

“History.dat”

For use with other programs, always use the history.dat file output by WUHU.

Here is the format of the history.dat file that is output by WUHU. This matches the file format output by the Heavyweather Pro application. The HW Pro application supports WS-36XX stations. We use the HW Pro application to graph the history files output by WUHU.

This format was chosen because it contains more fields than the old HW Beta 2.0 format.

New records are added to the end of the file, there is no header or trailing record.

The [X] field denotes the number of bytes in the field.

  1. 00 Double [8] Timestamp days from 12/30/1899 00:00:00 (GMT)
  2. 08 Float [4] Abs Pressure hectopascals (millibars)
  3. 12 Float [4] Relative Pressure hectopascals (millibars)
  4. 16 Float [4] Wind Speed meters/second
  5. 20 ULong [4] Wind Direction see below
  6. 24 Float [4] Wind Gust meters/second
  7. 28 Float [4] Total Rainfall millimeters
  8. 32 Float [4] New Rainfall millimeters
  9. 36 Float [4] Indoor Temp celsius
  10. 40 Float [4] Outdoor Temp celsius
  11. 44 Float [4] Indoor Humidity %
  12. 48 Float [4] Outdoor Humidity %
  13. 52 ULong [4] unknown – (Value is always 0)

Wind Direction

Wind direction is encoded as an integer between 0 and 15. To get the wind direction in degrees, multiply the value by 22.5. To get compass directions (moving clockwise) 0 is North, 1 is North-Northeast, 2 is Northeast, etc…

. 0 N
. 1 NNE
. 2 NE
. 3 ENE
. 4 E
. 5 ESE
. 6 SE
. 7 SSE
. 8 S
. 9 SSW
. 10 SW
. 11 WSW
. 12 W
. 13 WNW
. 14 NW
. 15 NNW

C data structure that mimics this format:

<span class="kw4"><span style="color: #993333;">struct</span></span> WeatherRecord3600 <span class="br0"><span style="color: #66cc66;">{</span></span>
<span class="kw4"><span style="color: #993333;">double</span></span> fTimeStamp<span class="sy0"><span style="color: #66cc66;">;</span></span>
<span class="kw4"><span style="color: #993333;">float</span></span> fOutdoorAbsolutePressure<span class="sy0"><span style="color: #66cc66;">;</span></span>
<span class="kw4"><span style="color: #993333;">float</span></span> fOutdoorRelativePressure<span class="sy0"><span style="color: #66cc66;">;</span></span>
<span class="kw4"><span style="color: #993333;">float</span></span> fOutdoorWindSpeed<span class="sy0"><span style="color: #66cc66;">;</span></span>
<span class="kw4"><span style="color: #993333;">unsigned</span></span> <span class="kw4"><span style="color: #993333;">long</span></span> ulOutdoorWindDirection<span class="sy0"><span style="color: #66cc66;">;</span></span>
<span class="kw4"><span style="color: #993333;">float</span></span> fOutdoorWindGust<span class="sy0"><span style="color: #66cc66;">;</span></span>
<span class="kw4"><span style="color: #993333;">float</span></span> fOutdoorTotalRainfall<span class="sy0"><span style="color: #66cc66;">;</span></span>
<span class="kw4"><span style="color: #993333;">float</span></span> fOutdoorNewRainfall<span class="sy0"><span style="color: #66cc66;">;</span></span>
<span class="kw4"><span style="color: #993333;">float</span></span> fIndoorTemperature<span class="sy0"><span style="color: #66cc66;">;</span></span>
<span class="kw4"><span style="color: #993333;">float</span></span> fOutdoorTemperature<span class="sy0"><span style="color: #66cc66;">;</span></span>
<span class="kw4"><span style="color: #993333;">float</span></span> fIndoorHumidity<span class="sy0"><span style="color: #66cc66;">;</span></span>
<span class="kw4"><span style="color: #993333;">float</span></span> fOutdoorHumidity<span class="sy0"><span style="color: #66cc66;">;</span></span>
<span class="kw4"><span style="color: #993333;">unsigned</span></span> <span class="kw4"><span style="color: #993333;">long</span></span> ulUnknown<span class="sy0"><span style="color: #66cc66;">;</span></span>
<span class="br0">}</span><span class="sy0">;</span>

The fTimeStamp is an odd field. It represents the days since a epoch time (12/30/1899 00:00:00) in UTC local time. The fractional part is used to obtain hours, minutes, and seconds. There are a few functions that are needed to convert back and forth between that timestamp format and the normal local time format, they are given below.

To convert from a normal time_t to this format you would use:

<span class="kw4"><span style="color: #993333;">time_t</span></span> t<span class="sy4">;</span>
WeatherRecord3600 wr3600<span class="sy4">;</span>

wr3600.<span class="me1"><span style="color: #006600;">fTimeStamp</span></span><span class="sy1">=</span>Convert_time_t_To_DateTime2<span class="br0"><span style="color: #66cc66;">(</span></span>ConvertLocalToUTCLocal<span class="br0"><span style="color: #66cc66;">(</span></span>t<span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>

To convert from this odd timestamp to a time_t:

t<span class="sy1">=</span>ConvertUTCLocalToLocal<span class="br0"><span style="color: #66cc66;">(</span></span>Convert_DateTime2_To_time_t<span class="br0"><span style="color: #66cc66;">(</span></span>wr3600.<span class="me1"><span style="color: #006600;">fTimeStamp</span></span><span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>

<span class="sy2">-----------------------</span>

<span class="kw4"><span style="color: #993333;">double</span></span> Convert_time_t_To_DateTime2<span class="br0"><span style="color: #66cc66;">(</span></span><span class="kw4"><span style="color: #993333;">time_t</span></span> vtime_t<span class="br0"><span style="color: #66cc66;">)</span></span>

<span class="br0"><span style="color: #66cc66;">{</span></span>
<span class="kw4"><span style="color: #993333;">double</span></span> fresult<span class="sy4">;</span>
<span class="co1"><em><span style="color: #808080;">// 25569 days from Saturday, December 30, 1899 to Sunday, January 1, 1970 (where time_t seconds counts from)</span></em></span>
<span class="kw4"><span style="color: #993333;">double</span></span> fDeltaDays <span class="sy1">=</span> <span class="nu0"><span style="color: #cc66cc;">25569</span></span> <span class="sy2">+</span> <span class="br0"><span style="color: #66cc66;">(</span></span>vtime_t <span class="sy2">/</span> <span class="br0"><span style="color: #66cc66;">(</span></span><span class="nu0"><span style="color: #cc66cc;">60</span></span> <span class="sy2">*</span> <span class="nu0"><span style="color: #cc66cc;">60</span></span> <span class="sy2">*</span> <span class="nu0"><span style="color: #cc66cc;">24</span></span><span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>
<span class="kw4"><span style="color: #993333;">double</span></span> fFractionDays <span class="sy1">=</span> <span class="br0"><span style="color: #66cc66;">(</span></span>vtime_t <span class="sy2">%</span> <span class="br0"><span style="color: #66cc66;">(</span></span><span class="nu0"><span style="color: #cc66cc;">60</span></span> <span class="sy2">*</span> <span class="nu0"><span style="color: #cc66cc;">60</span></span> <span class="sy2">*</span> <span class="nu0"><span style="color: #cc66cc;">24</span></span><span class="br0">)</span><span class="br0">)</span> <span class="sy2">/</span> <span class="br0"><span style="color: #66cc66;">(</span></span><span class="kw4"><span style="color: #993333;">double</span></span><span class="br0">)</span><span class="br0">(</span><span class="nu0"><span style="color: #cc66cc;">60</span></span> <span class="sy2">*</span> <span class="nu0"><span style="color: #cc66cc;">60</span></span> <span class="sy2">*</span> <span class="nu0"><span style="color: #cc66cc;">24</span></span><span class="br0"><span style="color: #66cc66;">)</span></span><span class="sy4">;</span>
fresult <span class="sy1">=</span> fDeltaDays<span class="sy2">+</span>fFractionDays<span class="sy4">;</span>
<span class="kw1"><span style="color: #b1b100;">return</span></span> <span class="br0"><span style="color: #66cc66;">(</span></span>fresult<span class="br0"><span style="color: #66cc66;">)</span></span><span class="sy4">;</span>
<span class="br0"><span style="color: #66cc66;">}</span></span>

<span class="co1"><em><span style="color: #808080;">//----</span></em></span>

<span class="kw4"><span style="color: #993333;">time_t</span></span> Convert_DateTime2_To_time_t<span class="br0"><span style="color: #66cc66;">(</span></span><span class="kw4"><span style="color: #993333;">double</span></span> fTime<span class="br0"><span style="color: #66cc66;">)</span></span>

<span class="br0"><span style="color: #66cc66;">{</span></span>
<span class="kw1"><span style="color: #b1b100;">return</span></span> <span class="br0"><span style="color: #66cc66;">(</span></span><span class="kw4"><span style="color: #993333;">time_t</span></span><span class="br0">)</span><span class="br0">(</span><span class="br0">(</span>fTime <span class="sy2">-</span> <span class="nu16">25569.0</span><span class="br0"><span style="color: #66cc66;">)</span></span> <span class="sy2">*</span> <span class="nu16">86400.0</span><span class="br0"><span style="color: #66cc66;">)</span></span><span class="sy4">;</span>
<span class="br0"><span style="color: #66cc66;">}</span></span>

<span class="co1"><em><span style="color: #808080;">//----</span></em></span>

<span class="kw4"><span style="color: #993333;">time_t</span></span> ConvertUTCLocalToLocal<span class="br0"><span style="color: #66cc66;">(</span></span><span class="kw4"><span style="color: #993333;">time_t</span></span> t<span class="br0"><span style="color: #66cc66;">)</span></span>

<span class="br0"><span style="color: #66cc66;">{</span></span>
<span class="co1"><em><span style="color: #808080;">// Aquire a local time and a gmt time.</span></em></span>
<span class="kw4"><span style="color: #993333;">struct</span></span> <span class="kw4"><span style="color: #993333;">tm</span></span> tm_localtime<span class="sy4">;</span>
<span class="kw3">memcpy</span><span class="br0"><span style="color: #66cc66;">(</span></span><span class="sy3">&amp;</span>tm_localtime,<span class="kw3">localtime</span><span class="br0"><span style="color: #66cc66;">(</span></span><span class="sy3">&amp;</span>t<span class="br0"><span style="color: #66cc66;">)</span></span>,<span class="kw3">sizeof</span><span class="br0"><span style="color: #66cc66;">(</span></span>tm_localtime<span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>

<span class="co1"><em><span style="color: #808080;">// Aquire UTC time.</span></em></span>
<span class="kw4"><span style="color: #993333;">struct</span></span> <span class="kw4"><span style="color: #993333;">tm</span></span> tm_gmtime<span class="sy4">;</span>
<span class="kw3">memcpy</span><span class="br0"><span style="color: #66cc66;">(</span></span><span class="sy3">&amp;</span>tm_gmtime,<span class="kw3">gmtime</span><span class="br0"><span style="color: #66cc66;">(</span></span><span class="sy3">&amp;</span>t<span class="br0"><span style="color: #66cc66;">)</span></span>,<span class="kw3">sizeof</span><span class="br0"><span style="color: #66cc66;">(</span></span>tm_gmtime<span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>

<span class="co1"><em><span style="color: #808080;">// Convert them back to time_t types.</span></em></span>
<span class="kw4"><span style="color: #993333;">time_t</span></span> t1<span class="sy1">=</span><span class="kw3">mktime</span><span class="br0"><span style="color: #66cc66;">(</span></span><span class="sy3">&amp;</span>tm_localtime<span class="br0"><span style="color: #66cc66;">)</span></span><span class="sy4">;</span>
<span class="kw4"><span style="color: #993333;">time_t</span></span> t2<span class="sy1">=</span><span class="kw3">mktime</span><span class="br0"><span style="color: #66cc66;">(</span></span><span class="sy3">&amp;</span>tm_gmtime<span class="br0"><span style="color: #66cc66;">)</span></span><span class="sy4">;</span>

<span class="co1"><em><span style="color: #808080;">// Subtract from local time the difference between local time and gmt time.</span></em></span>
t1 <span class="sy2">+</span><span class="sy1">=</span> <span class="br0"><span style="color: #66cc66;">(</span></span>t2<span class="sy2">-</span>t1<span class="br0"><span style="color: #66cc66;">)</span></span><span class="sy4">;</span>

<span class="co1"><em><span style="color: #808080;">// If daylight saving time in effect, subtract an hour.</span></em></span>
<span class="kw1"><span style="color: #b1b100;">if</span></span> <span class="br0"><span style="color: #66cc66;">(</span></span>tm_localtime.<span class="me1"><span style="color: #006600;">tm_isdst</span></span><span class="br0"><span style="color: #66cc66;">)</span></span>
t1 <span class="sy2">-</span><span class="sy1">=</span> <span class="nu0"><span style="color: #cc66cc;">60</span></span><span class="sy2">*</span><span class="nu0"><span style="color: #cc66cc;">60</span></span><span class="sy4">;</span>

<span class="kw1"><span style="color: #b1b100;">return</span></span><span class="br0"><span style="color: #66cc66;">(</span></span>t1<span class="br0"><span style="color: #66cc66;">)</span></span><span class="sy4">;</span>
<span class="br0"><span style="color: #66cc66;">}</span></span>

<span class="co1"><em><span style="color: #808080;">//----</span></em></span>

<span class="kw4"><span style="color: #993333;">time_t</span></span> ConvertLocalToUTCLocal<span class="br0"><span style="color: #66cc66;">(</span></span><span class="kw4"><span style="color: #993333;">time_t</span></span> t<span class="br0"><span style="color: #66cc66;">)</span></span>

<span class="br0"><span style="color: #66cc66;">{</span></span>
<span class="co1"><em><span style="color: #808080;">// Aquire a local time and a gmt time.</span></em></span>
<span class="kw4"><span style="color: #993333;">struct</span></span> <span class="kw4"><span style="color: #993333;">tm</span></span> tm_localtime<span class="sy4">;</span>
<span class="kw3">memcpy</span><span class="br0"><span style="color: #66cc66;">(</span></span><span class="sy3">&amp;</span>tm_localtime,<span class="kw3">localtime</span><span class="br0"><span style="color: #66cc66;">(</span></span><span class="sy3">&amp;</span>t<span class="br0"><span style="color: #66cc66;">)</span></span>,<span class="kw3">sizeof</span><span class="br0"><span style="color: #66cc66;">(</span></span>tm_localtime<span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>

<span class="co1"><em><span style="color: #808080;">// Aquire UTC time.</span></em></span>
<span class="kw4"><span style="color: #993333;">struct</span></span> <span class="kw4"><span style="color: #993333;">tm</span></span> tm_gmtime<span class="sy4">;</span>
<span class="kw3">memcpy</span><span class="br0"><span style="color: #66cc66;">(</span></span><span class="sy3">&amp;</span>tm_gmtime,<span class="kw3">gmtime</span><span class="br0"><span style="color: #66cc66;">(</span></span><span class="sy3">&amp;</span>t<span class="br0"><span style="color: #66cc66;">)</span></span>,<span class="kw3">sizeof</span><span class="br0"><span style="color: #66cc66;">(</span></span>tm_gmtime<span class="br0">)</span><span class="br0">)</span><span class="sy4">;</span>

<span class="co1"><em><span style="color: #808080;">// Convert them back to time_t types.</span></em></span>
<span class="kw4"><span style="color: #993333;">time_t</span></span> t1<span class="sy1">=</span><span class="kw3">mktime</span><span class="br0"><span style="color: #66cc66;">(</span></span><span class="sy3">&amp;</span>tm_localtime<span class="br0"><span style="color: #66cc66;">)</span></span><span class="sy4">;</span>
<span class="kw4"><span style="color: #993333;">time_t</span></span> t2<span class="sy1">=</span><span class="kw3">mktime</span><span class="br0"><span style="color: #66cc66;">(</span></span><span class="sy3">&amp;</span>tm_gmtime<span class="br0"><span style="color: #66cc66;">)</span></span><span class="sy4">;</span>

<span class="co1"><em><span style="color: #808080;">// Subtract from local time the difference between local time and gmt time.</span></em></span>
t1 <span class="sy2">-</span><span class="sy1">=</span> <span class="br0"><span style="color: #66cc66;">(</span></span>t2<span class="sy2">-</span>t1<span class="br0"><span style="color: #66cc66;">)</span></span><span class="sy4">;</span>

<span class="co1"><em><span style="color: #808080;">// If daylight saving time in effect, add an hour.</span></em></span>
<span class="kw1"><span style="color: #b1b100;">if</span></span> <span class="br0"><span style="color: #66cc66;">(</span></span>tm_localtime.<span class="me1"><span style="color: #006600;">tm_isdst</span></span><span class="br0"><span style="color: #66cc66;">)</span></span>
t1 <span class="sy2">+</span><span class="sy1">=</span> <span class="nu0"><span style="color: #cc66cc;">60</span></span><span class="sy2">*</span><span class="nu0"><span style="color: #cc66cc;">60</span></span><span class="sy4">;</span>

<span class="kw1"><span style="color: #b1b100;">return</span></span><span class="br0"><span style="color: #66cc66;">(</span></span>t1<span class="br0"><span style="color: #66cc66;">)</span></span><span class="sy4">;</span>
<span class="br0"><span style="color: #66cc66;">}</span></span>