Development guidance needed for a non-standard PWS

138 views
Skip to first unread message

Pieter Rautenbach

unread,
Oct 14, 2019, 12:13:58 PM10/14/19
to weewx-development
Hello

The software was super easy to install and set up and there are lots of good documentation. I am, however, quite new at experimenting with PWSs.

I would like to ask for some guidance though, as I can't seem to find the right information or determine the best approach.

I built a small module (for another purpose) that also houses a BME280 sensor for measuring temperature, humidity and air pressure, so that my module can double as a tiny PWS.

I have the WeeWX server running, hosted behind Nginx and I installed an extension for the BME280.

The server is currently running in simulation mode, so it's generating fake data. I can see from the logs that the LOOP for the BME280 is triggered and read.

Since this isn't a standard PWS, is my only option to write a custom driver? I was hoping something would've built a small implementation like this already, but I can't seem to find any. There are cases where someone uses a BME280 as an additional sensor with (e.g.) and AcuRite PWS, but my setup is different as I only have the BME280 sensor.

Otherwise, is there a neat trick in terms of setup that I'm missing? Can I imitate an existing PWS somehow (say, an AcuRite PWS) and have it's driver use only the extension for the BME280?

I would appreciate any pointers. I don't expect anybody to solve this for me: It's a new hobby, so quite happy to do the "hard" work if needed.

Regards
Pieter

Thomas Keffer

unread,
Oct 14, 2019, 4:15:21 PM10/14/19
to Pieter Rautenbach, weewx-development
Your best bet is to write a driver. But, don't let that intimidate you! At their most basic level, drivers are just a single function: genLoopPackets(). It uses the yield statement to return a dictionary containing the data. That's it.

Take a look at the directions in the Customizing Guide and see if you have any questions.

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/3ce73445-ecbb-4ded-9cb7-dcf98d610b20%40googlegroups.com.

Pieter Rautenbach

unread,
Oct 15, 2019, 1:58:13 AM10/15/19
to weewx-development
Thanks a mil, Tom.

This is exactly what I needed: The fileparser driver seems simple enough to base my code on.

Pieter Rautenbach

unread,
Oct 16, 2019, 2:06:38 AM10/16/19
to weewx-development
Out of interest, here is my project: https://github.com/parautenbach/WeeWX-BME280

It seems to be running so just monitoring to see if everything is fine.

Being able to test the driver from the command line was useful and helped me to sort out a few issues.

I'm pushing data to WU as IPARAD2.

If anybody sees something odd (about my code or the data it's generating or anything that's not in line with the PWS community's expectations) please let me know. :-)

Thomas Keffer

unread,
Oct 16, 2019, 7:33:15 AM10/16/19
to Pieter Rautenbach, weewx-development
See, that wasn't so hard! :-)

One suggestion: logging will change with WeeWX Version 4. See the Wiki article WeeWX v4 and logging. To insure that your driver will work under both WeeWX V3 and V4, take out the "import syslog", then put this near the top of bme280wx.py:

try:
# Test for new-style weewx logging by trying to import weeutil.logger
import weeutil.logger
import logging
log = logging.getLogger(__name__)

def log_debug(message):
log.debug(message)

def log_info(message):
log.info(message)

def log_error(message):
log.error(message)

except ImportError:
# Old-style weewx logging
import syslog

def _log_message(destination, message):
syslog.syslog(destination, "bme280wx: {}".format(message))

def log_debug(message):
_log_message(syslog.LOG_DEBUG, message)

def log_info(message):
_log_message(syslog.LOG_INFO, message)

def log_error(message):
_log_message(syslog.LOG_ERR, message)

-tk

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

Pieter Rautenbach

unread,
Oct 19, 2019, 12:36:10 AM10/19/19
to weewx-development
Thanks for the heads-up!
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-de...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages