Replacement humidity sensor

255 views
Skip to first unread message

tadej.j...@gmail.com

unread,
Nov 6, 2023, 3:18:18 AM11/6/23
to weewx-user
Hello i have ws2300 station and my humidity sensor probably died. It only shows values from 70 to 80% .I cannot get replacement part anywhere because it is not in production anymore and I cannot buy whole new station because it will be complicated to get all things up running again.

I was thinking of getting external humidity sensor and hook it to arduino board and then read humidity values remotely  via crontabs in a txt file. Is is somehow possible to "trick" weewx to read this value instead of getting it from station because I am using weewx to calculate heat index and dew point.

michael.k...@gmx.at

unread,
Nov 6, 2023, 5:58:56 AM11/6/23
to weewx-user
Hi,


I solved the issue with the (since ever crappy) humidity value from the ws2300 with an extra sensor that emits the humidity per MQTT and installed MQTTSubribe add-on to replace the ws2300 humidity values with the ones from the sensor. The sensor is a homebrew ESP01-based SHT3x solar powered LTO-battery backup. You can the map this value to e.g. extraHumid1 and show this value instead of outHumidity. I should also be possible to replace it like this:

[StdCalibrate]
[[Corrections]]
outHumidity = extraHumid1 if extraHumid1 is not None else None


But I am not sure of this works (not tested). It should map your extraHumid1 to be stored as outHumidity (if extraHumid1 is there), if it is not there, it should drop outHumidity.

Mark Fraser

unread,
Nov 6, 2023, 12:32:59 PM11/6/23
to weewx...@googlegroups.com
Could you use something like BME280WX from here?
https://gitlab.com/wjcarpenter/bme280wx

michael.k...@gmx.at

unread,
Nov 6, 2023, 2:19:23 PM11/6/23
to weewx-user
Do not use a BME280 as an outdoor Sensor, it is not suited for this purpose. The operating range is only valid in non-condensing environments. In condensing environments, especially below freezing point, these sensors are proven unusable. Go for a SHT3x or SHT4x. 

vince

unread,
Nov 6, 2023, 2:41:08 PM11/6/23
to weewx-user
Another option is an ecowitt gateway and their outside T+H sensor, which integrates well into weewx.  

michael.k...@gmx.at

unread,
Nov 6, 2023, 3:03:39 PM11/6/23
to weewx-user
With the ecowitt gateway you need a second weewxd running, as a downside. But you can build a whole new station, step by step, around that gateway (which is probably way to go, sooner or later). 

gjr80

unread,
Nov 6, 2023, 3:08:54 PM11/6/23
to weewx-user
Not necessary, if the Ecowitt gateway driver can be used it can be run as a data service to augment an existing driver.

Gary

Message has been deleted

michael.k...@gmx.at

unread,
Nov 7, 2023, 6:36:26 AM11/7/23
to weewx-user
Thanks, I forgot about that! Then I would definitely prefer getting an Ecowitt Gateway + outdoor sensor over the replacement part. 

tadej.j...@gmail.com

unread,
Nov 8, 2023, 5:14:14 AM11/8/23
to weewx-user
I will try this one for now! I hope weewx will use it later to calculate dew point and heat index with this value.

[StdCalibrate]
[[Corrections]]
outHumidity = extraHumid1 if extraHumid1 is not None else None

torek, 7. november 2023 ob 12:36:26 UTC+1 je oseba michael.k...@gmx.at napisala:

tadej.j...@gmail.com

unread,
Nov 8, 2023, 12:28:20 PM11/8/23
to weewx-user
It is not working with StdCalibrate

[StdCalibrate]
    [[Corrections]]
        # For each type, an arbitrary calibration expression can be given.
        # It should be in the units defined in the StdConvert section.
        # Example:
        foo = foo + 0.2
        outHumidity = extraHumid1

I am getting correct values in extraHumid1 from replacement sensor. I checked database. But outHumidity is stil getting value from dead station sensor.

sreda, 8. november 2023 ob 11:14:14 UTC+1 je oseba tadej.j...@gmail.com napisala:
Message has been deleted

michael.k...@gmx.at

unread,
Nov 8, 2023, 1:19:05 PM11/8/23
to weewx-user
With this config you get both, outHumidity and extraHumid1 mixed.

Try, as mentioned above:

outHumidity = extraHumid1 if extraHumid1 is not None else None

tadej.j...@gmail.com

unread,
Nov 8, 2023, 2:01:45 PM11/8/23
to weewx-user
Still the same ..
SQL from database:
Screenshot_1.jpg

Screenshot from config:
Screenshot_2.jpg

And yes I have stopped and restarted weewxd several times.

sreda, 8. november 2023 ob 19:19:05 UTC+1 je oseba michael.k...@gmx.at napisala:

Graham Eddy

unread,
Nov 8, 2023, 6:33:30 PM11/8/23
to WeeWX User
just looking at the intention of the code without having read the thread [always dangerous!]
i cannot quote the original python text here because unfortunately it was reported using a screenshot [please don’t do that]
but note that if extraHumid1 is undefined (not present in packet, as opposed to present but with value None) then the assignment fails (outHumidity is unchanged). maybe check if it is in locals() instead
⊣GE⊢

On 9 Nov 2023, at 6:01 am, tadej.j...@gmail.com <tadej.j...@gmail.com> wrote:

Still the same ..
SQL from database:
<Screenshot_1.jpg>

Screenshot from config:

gjr80

unread,
Nov 8, 2023, 9:53:49 PM11/8/23
to weewx-user
When merging sources it is often useful to run WeeWX directly, that way you can see exactly what is/is not in your loop packets. Frequently it is not what you may expect.

Gary

Message has been deleted

michael.k...@gmx.at

unread,
Nov 9, 2023, 12:59:22 AM11/9/23
to weewx-user

As I said: "something like" .... "not tested"

Then I'd give 

outHumidity = extraHumid1 if 'extraHumid1' in locals() else None

a try. Still: not tested, an I am just assuming that setting it to None when present it will be ignored when accumulating the value over an archive_interval. It might be as well necessary to remove it from locals, if possible. 

tadej.j...@gmail.com

unread,
Nov 9, 2023, 1:03:57 AM11/9/23
to weewx-user
Michael, when trying this I get value N/A for outHumidity so we are getting somewhere, but it is still not replaced with extraHumid1 value. What do you mean with removin it from locals? :)

michael.k...@gmx.at

unread,
Nov 9, 2023, 1:20:17 AM11/9/23
to weewx-user
Did run run weewxd directly, and check, how the loop packet drop in and what in there?

Also: what kind of sensor did you apply to augment your data and how does the data go into into you weewx? MQTT?

What I did:
With my ws23xx, I have a outHumidity Sensor that works well below 85%, but barely has readings above this value. Then I made a homebrew ESP8266 based Sensor that emits it's readings with MQTT. In weewx I use MQTTSubsbribe to get these values and mapped it to extraHumid1. Since my Sensor doesn't produce bad values all the time but only in a certain range, and my first homebrew sensor wasn't that rock-solid in terms of reliability, my approach was to used the extra sensors value only if there are current readings, if not, fall back to the stock sensor. I didn't solve this with a correction, but with litte user service, I called "usePrefered". This proofed to do the trick for me an is tested :D It doesn't come with an installer,  I hope I described everything necessary in the comments. You find the code there:

tadej.j...@gmail.com

unread,
Nov 9, 2023, 1:37:18 AM11/9/23
to weewx-user
For testing purpose I used esp32 with dht22 configured as web server. Every 10 minutes i use cron to wget value from esp32 to a .txt file. Then I use weewx user service to read this value into database.

Service:
# -*- coding: utf-8 -*-
import syslog
import weewx
from weewx.wxengine import StdService

class vlagaservice(StdService):
    def __init__(self, engine, config_dict):
        super(vlagaservice, self).__init__(engine, config_dict)
        d = config_dict.get('vlagaservice', {})
        self.filename = d.get('filename', '/usb/www/tla/vlaga.txt')
        syslog.syslog(syslog.LOG_INFO, "vlaga: using %s" % self.filename)
        self.bind(weewx.NEW_ARCHIVE_RECORD, self.read_file)

    def read_file(self, event):
        try:
            with open(self.filename) as f:
                value = f.read()
            syslog.syslog(syslog.LOG_DEBUG, "vlaga: found value of %s" % value)
            event.record['extraHumid1'] = float(value)
        except Exception, e:
            syslog.syslog(syslog.LOG_ERR, "vlaga: cannot read value: %s" % e)


četrtek, 9. november 2023 ob 07:20:17 UTC+1 je oseba michael.k...@gmx.at napisala:
Message has been deleted

michael.k...@gmx.at

unread,
Nov 9, 2023, 1:55:05 AM11/9/23
to weewx-user
It should work like this, when set the database column from above to outHumidity instead of extraHumid1. (And nothing in the Corrections)
Message has been deleted

tadej.j...@gmail.com

unread,
Nov 9, 2023, 2:47:59 AM11/9/23
to weewx-user
It works! In the end the solution was so simple. I also changed dewpoint from hardware to software calculation and it also works OK. Now I must only get one proper sensor instead dht22. 
Thank you all!

četrtek, 9. november 2023 ob 07:55:05 UTC+1 je oseba michael.k...@gmx.at napisala:
Reply all
Reply to author
Forward
0 new messages