--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
Perhaps I am missing something obvious but why not fix the issue at source; if the arduino is sending out the source rainfall data why not double it or calculate it there. If you follow the weeWX driver model it is the driver, ie the code that speaks direct to the station/source, that calculates how much rain occurs for each 'tip'. At least that way your data is correct as it propagates it's way through your system. If you want/need to set bucket size in a weewx.conf then you will need to modify the respective driver (which you may or may not wish to do). I don't imagine it would be easy to propagate bucket size from weewx.conf to arduino.
Gary
--
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+unsubscribe@googlegroups.com.
| # map the data into a weewx loop packet |
That could be it. weewx.METRIC has rainfall in cm, weewx.METRICWX in mm. See the Units appendix in the Customizing Guide.-tk
On Sun, Nov 26, 2017 at 8:02 AM, 'Christian Peters' via weewx-user <weewx...@googlegroups.com> wrote:
Tom,
thank you for that hint. So emitting in mm was the right change.
I just wonder why my temp values are ok but my rain data isn't!?
Just found that on the wxMesh driver:_packet = {'usUnits': weewx.METRIC}
# map the data into a weewx loop packet
So I think I have to switch to METRICWX.
Regards,
Christian
--
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 unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.
| #!/usr/bin/python |
| # |
| # weewx driver that reads data from MQTT subscription |
| # |
| # This program is free software: you can redistribute it and/or modify it under |
| # the terms of the GNU General Public License as published by the Free Software |
| # Foundation, either version 3 of the License, or any later version. |
| # |
| # This program is distributed in the hope that it will be useful, but WITHOUT |
| # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| # FOR A PARTICULAR PURPOSE. |
| # |
| # See http://www.gnu.org/licenses/ |
|
|
| # |
| # The units must be weewx.US: |
| # degree_F, inHg, inch, inch_per_hour, mile_per_hour |
| # |
| # To use this driver, put this file in the weewx user directory, then make |
| # the following changes to weewx.conf: |
| # |
| # [Station] |
| # station_type = wxMesh |
| # [wxMesh] |
| # host = localhost # MQTT broker hostname |
| # topic = weather # topic |
| # driver = user.wxMesh |
| # |
| # If the variables in the file have names different from those in weewx, then |
| # create a mapping such as this: |
| # |
| # [wxMesh] |
| # ... |
| # [[label_map]] |
| # temp = outTemp |
| # humi = outHumidity |
| # in_temp = inTemp |
| # in_humid = inHumidity |
|
|
| from __future__ import with_statement |
| import syslog |
| import time |
| import paho.mqtt.client as mqtt |
| import weewx.drivers |
|
|
| DRIVER_VERSION = "0.1" |
|
|
| def logmsg(dst, msg): |
| syslog.syslog(dst, 'wxMesh: %s' % msg) |
|
|
| def logdbg(msg): |
| logmsg(syslog.LOG_DEBUG, msg) |
|
|
| def loginf(msg): |
| logmsg(syslog.LOG_INFO, msg) |
|
|
| def logerr(msg): |
| logmsg(syslog.LOG_ERR, msg) |
|
|
| def _get_as_float(d, s): |
| v = None |
| if s in d: |
| try: |
| v = float(d[s]) |
| except ValueError, e: |
| logerr("cannot read value for '%s': %s" % (s, e)) |
| return v |
|
|
| def loader(config_dict, engine): |
| return wxMesh(**config_dict['wxMesh']) |
|
|
| class wxMesh(weewx.drivers.AbstractDevice): |
| """weewx driver that reads data from a file""" |
|
|
| def __init__(self, **stn_dict): |
| # where to find the data file |
| self.host = stn_dict.get('host', 'localhost') |
| self.topic = stn_dict.get('topic', 'weather') |
| # how often to poll the weather data file, seconds |
| self.poll_interval = float(stn_dict.get('poll_interval', 5.0)) |
| # mapping from variable names to weewx names |
| self.label_map = stn_dict.get('label_map', {}) |
|
|
| loginf("host is %s" % self.host) |
| loginf("topic is %s" % self.topic) |
| loginf("polling interval is %s" % self.poll_interval) |
| loginf('label map is %s' % self.label_map) |
| |
| self.payload = "Empty" |
| #self.payloadList = [payload] |
| self.client = mqtt.Client(client_id="XXX", protocol=mqtt.MQTTv31) |
|
|
| #self.client.on_connect = self.on_connect |
| self.client.on_message = self.on_message |
|
|
| self.client.username_pw_set("XXX", "XXX") |
| self.client.connect(self.host, 1883, 60) |
| self.client.subscribe(self.topic, qos=1) |
|
|
| # The callback for when a PUBLISH message is received from the server. |
| def on_message(self, client, userdata, msg): |
| self.payload = str(msg.payload) |
| logdbg("Got message %s" % str(msg.payload)) |
|
|
| def genLoopPackets(self): |
| while True: |
| self.client.loop() |
| # read whatever values we can get from the MQTT broker |
| logdbg("Working on payload : %s" % self.payload) |
| if self.payload != "Empty" : |
| data = {} |
| row = self.payload.split(","); |
| for datum in row: |
| (key,value) = datum.split(":") |
| data[key] = value |
| if( key=="TIME" and data[key] == "0"): |
| data[key] = str(int(time.time())) |
| logdbg("key: "+key+" value: "+data[key]) |
| |
| # map the data into a weewx loop packet |
| _packet = {'usUnits': weewx.METRICWX} |
| for vname in data: |
| _packet[self.label_map.get(vname, vname)] = _get_as_float(data, vname) |
|
|
| yield _packet |
| self.payload = "Empty" |
| |
| logdbg("Sleeping for %d" % self.poll_interval) |
| time.sleep(self.poll_interval) |
| self.client.disconnect() |
| @property |
| def hardware_name(self): |
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.