>
> please post your code for collecting data from the bme280 and for
> converting the resulting units.
>
> the SDR generates packets with different unit systems, depending on the
> sensors (and depending on the format - for example, for the 5n1 the old
> line format is METRIC whereas the JSON format is US). in fact, the 5n1
> JSON packets are US, but the tower packets (is that what you mean by
> "2-in-1"?) are METRIC.
>
> so if your bme280 code does not adapt to the unit system in each packet,
> then you will have problems such as those you report.
>
> m
>
Ah, this makes sense now, a great explanation of how SDR was crafting
packets - thank you! So when weewx was receiving the 5n1 packets it would
combine with the temp and pressure data resulting in a unit mismatch. But
with the 2in1 it was a happy potato.
I had attempted to create a python script to dynamically create loop
packets however my coding skills are a bit rusty so i went with pond.py and
this script I crafted - nothing identifies the what units are in the loop
packet. That will be a project for a rainy day.
sensorread.py: called via cron every 5 mins
#import syslog
#import weewx
import bme280
import smbus2
#import time
log_file = open("/var/ramdisk/bmelog.txt", "w")
port = 1
address = 0x76
bus = smbus2.SMBus(port)
calibration_params = bme280.load_calibration_params(bus, address)
data = bme280.sample(bus, address, calibration_params)
data.pressure = (data.pressure * 0.029529980164712)
data.temperature = ((data.temperature*1.8)+32)
log_file.write("inTemp=%f\r\n" % data.temperature)
log_file.write("pressure=%f\r\n" % data.pressure)
log_file.close()
#print (data.pressure)
#print (data.temperature)
and pond.py:
import syslogimport weewxfrom weewx.wxengine import StdService
class PondService(StdService):
def __init__(self, engine, config_dict):
super(PondService, self).__init__(engine, config_dict)
d = config_dict.get('PondService', {})
self.filename = d.get('filename', '/var/tmp/pond.txt')
syslog.syslog(syslog.LOG_INFO, "pond: 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, "pond: found value of %s" % value)
event.record['extraTemp1'] = float(value)
except Exception as e:
syslog.syslog(syslog.LOG_ERR, "pond: cannot read value: %s" % e)
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.