Strange extraTemp1 values stored using custom data_service

46 views
Skip to first unread message

Glenn O'Callaghan

unread,
Oct 4, 2023, 9:23:23 AM10/4/23
to weewx-user
Hi,

I'm using WeeWx V4.4.1 and MySQL V8.0.20 with a Davis Vantage Pro 2 and have an RPi measuring my roof space Temp and Humidity and am planning to store the data in extraTemp1 and extraHumid1.

I've successfully created a data_service and am simply writing static values initially as a test. extraHumid1 works (I get the same value I put in out the end) but when I set extraTemp1 I'm getting strange values when viewed in MySQL Workbench. 40 becomes 4.4', 50 = 10. 60 = 15.5', 70 = 21.1', numbers around 30 and below become negatives. But I am yet to see a pattern or find a reason why. extraTemp2 does the same thing (haven't tested any other fields, and they all appear to be typed "double").

My code is below and any help would be greatly appreciated. I've checked and there are no StdCalibrate entries in my configuration.

Thanks,
Glenn.

import syslog
import weewx
from weewx.engine import StdService

class AddRoof(StdService):

    def __init__(self, engine, config_dict):

      # Initialize my superclass first:
      super(AddRoof, self).__init__(engine, config_dict)

      # Bind to any new archive record events:
      self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record)

    def new_archive_record(self, event):

roofTemp = float("50")
roofHumid = float("9.1")

event.record['extraTemp1'] = roofTemp
event.record['extraHumid1'] = roofHumid

syslog.syslog(syslog.LOG_INFO, "AddRoof: Temperature %s, Humidity %s" % (roofTemp, roofHumid))

michael.k...@gmx.at

unread,
Oct 4, 2023, 9:53:42 AM10/4/23
to weewx-user
It's a units issue:
40°F = 4.4°C
50°F = 10°C
and so on.

Glenn O'Callaghan

unread,
Oct 5, 2023, 2:58:25 AM10/5/23
to weewx-user
Hi All,

Thanks to Michael to pointing out it was expecting Degrees Fahrenheit in this context.

Based on the following comment and my config...

[StdConvert]
    # DO NOT MODIFY THIS VALUE UNLESS YOU KNOW WHAT YOU ARE DOING!
    target_unit = METRIC       # Default is 'US'

Apparently, I don't know what I'm doing so I've just changed my code as follows...

roofTempC = float("50") (This will be the Degrees Celsius from the RPi measuring the Roof) 
roofTempF = (roofTempC * 1.8) + 32
event.record['extraTemp1'] = roofTempF

Thanks,
Glenn.
Reply all
Reply to author
Forward
0 new messages