Converting data from HW that is in metric to display in US

172 views
Skip to first unread message

Randy Morlen

unread,
Aug 5, 2020, 12:21:43 PM8/5/20
to weewx-user
I am new to weewx.  I have data coming in from my device is coming in as metric (specifically, temp is C).  I want to display that data as US, F.  The default weewx skin is showing the data as metric values like 20F which is actually 20C whereas it should be 68F.  Where does this conversion happen or where do I chance the configuration?

Thank you
Randy 

Randy

unread,
Aug 5, 2020, 12:58:41 PM8/5/20
to weewx-user
I found that in weewx.conf that the section:
[StdConvert]
is set to US

Randy

unread,
Aug 5, 2020, 2:20:03 PM8/5/20
to weewx-user
If the DB settings are set to us and the data from the HW is coming in as metric, where is the conversion supposed to occur?


On Wednesday, August 5, 2020 at 12:21:43 PM UTC-4, Randy wrote:

John Kline

unread,
Aug 5, 2020, 3:57:45 PM8/5/20
to weewx...@googlegroups.com
See bin/weewx/engine.py:

class StdConvert(StdService):
    """Service for performing unit conversions.
    This service acts as a filter. Whatever packets and records come in are
    converted to a target unit system.                                                                                          
    This service should be run before most of the others, so observations appear
    in the correct unit."""

Also, see docs/devnotes.htm:

The general strategy is that measurements are converted by service StdConvert as they come off the weather station into a target unit system, then stored internally in the database in that unit system. Then, as they come off the database to be used for a report, they are converted into a target unit, specified by the skin.

On Aug 5, 2020, at 11:20 AM, Randy <rrm...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/66a2cfc1-98c2-44ea-b9e2-4ecf8543752bo%40googlegroups.com.

gjr80

unread,
Aug 5, 2020, 9:55:47 PM8/5/20
to weewx-user
Hi,

A couple of WeeWX basics might help. You may well find that different units are used by different parts of WeeWX depending on a number of things. The driver used to obtain data from your station may use metric or US customary units, this is dependent on your station and/or the driver. Once in WeeWX the data will be converted (if necessary) to the units used within your WeeWX database, this could be one of the Metric based unit systems supported by WeeWX or it could be US customary. The default is US customary and this is where the StdConvert service comes into play, StdConvert converts the data from the driver from whatever units the driver used to whatever units your database uses. Then you have the reporting system, the reporting system uses the Cheetah template engine and a system of tags that can be used to specify, among other things, the units for a given observation/metric you are displaying. Again there is a default and when you installed WeeWX you should have been asked what display units to use, eg:

Indicate the preferred units for display: ['us', 'metric']
units
[metric]:

Your answer here would have been used to set the defaults. So there are three broad areas where data exists within WeeWX and it is quite possible that each could be different, at the end of the day whether the data from station to WeeWX or within the WeeWX database is stored in US, metric or Martian units is mostly irrelevant, what most people are concerned with are what units are displayed on screen.

If you are using the skins packaged with WeeWX (Standard or Seasons) then you can alter the displayed units by changing config settings in weewx.conf, these settings will likely have been set at install but can easily be changed. You should find all you need in the How to change units section in the Customization Guide. If you are using some other skin then it is possible they follow a similar system or they could do things in their manner. Best to seek guidance from the skin author/maintainer.

Gary

Randy

unread,
Aug 6, 2020, 6:23:47 AM8/6/20
to weewx-user
I can change the unit in the skin without issue.  I guess the problem is that it appears the data in the database (which is set to US) is actually metric data.  So when I change the units in the skin, the data is displayed.  For example, the default skin for weewx shows my temp as: 30.4°F. When that temp is actually 30.4 C.  Maybe I should go set the DB to Metric (which I saw info on and the info indicated this was challenging).  Or maybe a clean reinstall.

Randy 

John Kline

unread,
Aug 6, 2020, 7:14:55 AM8/6/20
to weewx...@googlegroups.com
If the driver is incorrectly setting usUnits to ‘US’, one would see this behavior. What driver are you using? Perhaps you are missing a setting in weewx.conf to tell the driver the station is sending metric data.  BTW, do you know for sure if the data coming from the weather station is metric?

On Aug 6, 2020, at 3:23 AM, Randy <rrm...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Randy

unread,
Aug 6, 2020, 7:05:08 PM8/6/20
to weewx-user
I am using this driver:  https://github.com/captain-coredump/weatherflow-udp and specifically the settings for the tempest here: https://github.com/captain-coredump/weatherflow-udp/blob/master/sample_Tempest_sensor_map.  The docs for the tempest UDP indicate the data is metric.  Also, I grabbed packets using WIreShark and was able to confirm metric.  Looking at the Python code for the drive I see " 'usUnits' : weewx.METRICWX}"

Randy

To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.

Tom Keffer

unread,
Aug 6, 2020, 7:23:51 PM8/6/20
to weewx-user
Assuming you have not made any modifications, here are some things to try

1. Run weewxd directly from the command line. It will print out LOOP packets and archive records. What unit system do they use? Do the values make sense?

2. If that doesn't help, double check your copy of weewx.conf. What is the value for target_unit.?

3. Instead of guessing what's in your database, see what is actually in it. Here are a couple of queries to try. This assumes your database is at /var/lib/weewx/weewx.sdb

$ sqlite3 /var/lib/weewx/weewx.sdb
# Make sure there aren't mixed units in the database:
sqlite> select min(usUnits), max(usUnits);
# Print out the last 20 records:
sqlite> select datetime(dateTime, 'unixepoch', 'localtime'), outTemp, usUnits from archive order by dateTime desc limit 20;

Do these values look reasonable?

4. Finally, when all else fails, send the log

-tk





To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/82b6fe11-9b6f-4e19-9996-f4abf30c5debo%40googlegroups.com.

Randy

unread,
Aug 7, 2020, 5:34:44 PM8/7/20
to weewx-user
Running weewxd directly nothing weird except a python error with weather34 and I am not looking at that.  I have the default skin.

    target_unit = US
which was the default.

 select min(usUnits), max(usUnits);
No such column usUnits

I can list tables.  A bunch with the name archive.

select datetime(dateTime, 'unixepoch', 'localtime'), outTemp, usUnits from archive order by dateTime desc limit 20;
2020-08-05 08:50:00|30.3946778669233|1
2020-08-05 08:45:00|30.4855480335825|1
2020-08-05 08:40:00|30.5857060224786|1
2020-08-05 08:35:00|30.6951041638333|1
2020-08-05 08:30:00|30.8136903900564|1
2020-08-05 08:25:00|30.9414082605267|1
2020-08-05 08:20:00|31.0781969884552|1
2020-08-05 08:15:00|31.2239914698158|1
2020-08-05 08:10:00|31.3787223143316|1
2020-08-05 08:05:00|31.5423158785006|1
2020-08-05 08:00:00|31.7146943006468|1
2020-08-05 07:55:00|31.8957755379769|1
2020-08-05 07:50:00|32.0854734056296|1
2020-08-05 07:45:00|32.2836976176936|1
2020-08-05 07:40:00|32.4903538301798|1
2020-08-05 07:35:00|32.6378788638721|1
2020-08-05 07:30:00|32.2300093984879|1
2020-08-05 07:25:00|32.4344265298156|1
2020-08-05 07:20:00|32.609169593389|1

Not sure why I have no data coming in right now.  That might be the issue.

I am attaching syslog file.

Thank you
Randy
syslog

Greg from Oz

unread,
Aug 7, 2020, 7:10:05 PM8/7/20
to weewx-user
Maybe just go metric..... :-)
There are only 3 countries officially not metric in the world.

Tom Keffer

unread,
Aug 7, 2020, 7:23:55 PM8/7/20
to weewx-user
On Fri, Aug 7, 2020 at 2:34 PM Randy <rrm...@gmail.com> wrote:
Running weewxd directly nothing weird except a python error with weather34 and I am not looking at that.  I have the default skin.

What do you mean by "nothing weird?" That packets and records were in the METRICWX system (usUnits=17) and the values were consistent with metric units?

-tk

Glenn McKechnie

unread,
Aug 7, 2020, 8:18:55 PM8/7/20
to weewx...@googlegroups.com
@Randy, (and later @Tom) and anyone else with input !

Nothing to do with your units problem, but that weather34 error is
possibly why you have no data coming in. The cluttered log shows you
have 2 weewx processes running.

One - PID [1963] is caught up trying to get weather34 running (which
fails with a "Bad Request')

The others [3753] and then the last one at PID [4352] - try to run and
are then blocked
with a "OSError: [Errno 98] Address already in use" and I'd suspect
that's because weewx [1963] is holding it open

Can't help you with any of your main problem, but I'd suggest fixing,
or better yet just move weather34 out of the way so that it is not
interfering with the main engine,

Kill all weewxd instances. To find them...

ps aux | grep [w]eewxd

kill -9 1963

kill -9 XXXX

Disable the weather34 skin (Probably under [StdReport][[weather34]] ?)

@Tom,
I'm using my full quotient of brain cells on this log, but it appears
that when weewx does a forced restart, it does so without killing PID
[1963] which appears to be started by systemd at 07:14:28

Should this be dealt with by weewx on the forced restart?

Points of interest, from the syslog

Aug 7 07:14:28 raspberrypi systemd[1]:
[...]
Aug 7 07:14:32 raspberrypi weewx[1959] INFO __main__: PID file is
/var/run/weewx.pid
Aug 7 07:14:32 raspberrypi weewx[1963] INFO __main__: Using
configuration file /etc/weewx/weewx.conf


Aug 7 10:30:41 raspberrypi weewx[1963] ERROR user.weather34: [...]
Error: HTTP Error 401
[...]
Aug 7 10:34:51 raspberrypi weewx[3753] INFO __main__: Initializing
weewx version 4.1.1
[...]
Aug 7 10:40:40 raspberrypi weewx[1963] ERROR user.weather34: Failed
[...]
Aug 7 10:39:37 raspberrypi weewx[3753] CRITICAL __main__: ****
RuntimeError: can't start new thread
Aug 7 10:39:37 raspberrypi weewx[3753] CRITICAL __main__: **** Exiting.
[...]
Aug 7 10:41:46 raspberrypi weewx[4352] INFO __main__: Initializing
weewx version 4.1.1
[...]
Aug 7 10:45:40 raspberrypi weewx[1963] ERROR user.weather34: Failed

--


Cheers
Glenn

rorpi - read only raspberry pi & various weewx addons
https://github.com/glennmckechnie

Tom Keffer

unread,
Aug 7, 2020, 8:44:30 PM8/7/20
to weewx-user
In addition to Glenn's suggestions, you also have a sensor_map problem for your WeatherFlow instrument. You're using the serial number that was given as an example in the driver's documentation, instead of your own serial number. Normally, that would result in no LOOP packets getting emitted. 

I'm surprised you're seeing anything. So, again, please clarify what you mean by "nothing weird."

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAAraAzgifQQnqkbG%3DkjPoGib3nrKuGc_%2Btb4B-sUv5k0FXLHTA%40mail.gmail.com.
Message has been deleted

Randy

unread,
Aug 8, 2020, 1:08:12 PM8/8/20
to weewx-user
I wiped weewx and reinstalled from scratch (using apt-get install weewx).  Then installed the driver.  Did not install weather34.  Changed the settings for sensor map to include the unit SN (although I have not seen any docs on this).

Still seeing the same issue where the units in the DB are metric and the UI shows the metric data as F?

Thanks
Randy

Tom Keffer

unread,
Aug 8, 2020, 1:22:32 PM8/8/20
to weewx-user
Randy, help us to help you.

1. Please run weewxd directly, and tell me exactly what you see. It's not enough to hear that there is "nothing weird."

2. Now that you no longer have weather34 running, show us a clean log. Stop weewxd, make sure debug=1, restart weewx, post through the first report cycle. See Help! Posting to weewx-user for details on how to get a good log.

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/3e40a5d7-66be-423a-af59-afb9fa9c39f0o%40googlegroups.com.

Tom Keffer

unread,
Aug 8, 2020, 6:40:19 PM8/8/20
to weewx-user
On Fri, Aug 7, 2020 at 4:10 PM Greg from Oz <ubea...@gmail.com> wrote:
Maybe just go metric..... :-)
There are only 3 countries officially not metric in the world.

Greg from Oz

unread,
Aug 8, 2020, 7:45:31 PM8/8/20
to weewx-user
Yep. He was right. I have no idea what he was talking about.
I come from an engineering background and the best thing that happened was going metric. So much easier.
Anyway if he is building a boat he should be using cubits.....hahaha, oh that's building arks isn't it. :-)

Randy

unread,
Aug 14, 2020, 7:23:45 AM8/14/20
to weewx-user
After reinstalling everything from scratch and tweaking the driver configuration it is now working.  Thank you.

Tom Keffer

unread,
Aug 14, 2020, 8:43:36 AM8/14/20
to weewx-user
Glad to hear that it worked out, but could you give us more details about how you "tweaked the driver"? 

The WeatherFlow driver is an area of great interest right now. If there is a problem with it, we would like to know.

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/457b6bfb-3fed-43e7-bff0-90338a06b347o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages