I'm working an a RPi SPI service to read a BMP280.
The BMP280 can produce 16 to 20 bit values for pressure, depending on how
it's configured. With the default 16 bits it says it is accurate to within
2.62 Pa.
That's a lot finer resolution than anything I've seen reported. Is weewx
going to u
Weewx doesn't round anything. It just passes values on to the database.
How the database handles it depends on the type of database, driver, and
how it's configured.
-tk
On Sat, Apr 1, 2017 at 11:03 AM, Craig Thom wrote:
> I'm working an a RPi SPI service to read a BMP280.
>
> The BMP280 can p
Thanks. In the MySQL database it's a double, so the resolution is there.
My weewx is using American measures and putting inHg in the database. Do i need
to convert from Pascals before handing the data back?
The only thing that matters is that the packet yielded by the driver use a
consistent unit system. Doesn't matter what that unit system is, but all
measurements in the packet have to use it.
See the Appendix *Units
* for the
definitions of the three unit systems, US, METRIC, and METRICWX.
-tk
On
My goal is to use the existing SDR driver and to use a service to read the
pressure from the BMP280 and add it to the data the SDR driver is collecting.
On Saturday, April 1, 2017 at 5:29:16 PM UTC-4, Craig Thom wrote:
>
> My goal is to use the existing SDR driver and to use a service to read the
> pressure from the BMP280 and add it to the data the SDR driver is
> collecting.
craig,
handling the units in a service is slightly different that i
Perfect. Thanks.
I know I saw, somewhere, a way to call an existing weewx method to convert
units to whatever is needed, but I can't find it again. It may have been
in a service in the Wiki rather than in the documentation, because I can't
find it there.
Is there such a thing?
I didn't like how limited the A
Depends on exactly what you want to do. There are a bunch of conversion
programs in module weewx.units, mostly in the bottom third of the file.
-tk
On Thu, Apr 6, 2017 at 1:54 PM, Craig Thom wrote:
> I know I saw, somewhere, a way to call an existing weewx method to convert
> units to whatever
I want to convert from the native Pa and °C to whatever the user has configured
weewx to use when I add to either the LOOP or archive data.
I'll check there. Thanks.
Function weewx.units.convertStd() is what you want. For example, to convert
from Celsius to whatever unit system the LOOP packet is using:
new_valueTuple = weewx.units.convertStd((22.5, "degree_C",
"group_temperature"), packet['usUnits'])
If you haven't run into them yet, read up about "ValueTup
Thanks. I found that in units.py and was reading the comments about the
value tuples. I assumed that the "target units" was whatever was defined
in weewx.conf.
I am new to Python and objects, really, since it's been over twenty years
since I wrote anything. What it looks like to me, for the
>
> I am new to Python and objects, really, since it's been over twenty years
> since I wrote anything. What it looks like to me, for the service, is that
> weewx is going to create an instance of the class I define in the service
> file and call the function that's bound to my chosen event, right
OK, just so I'm understanding this. This starts at the bottom of the
__init__. col_press and col_temp are strings read from my [BMP280] section
of weewx.conf that contain where the data should go, like "barometer" and
"extraTemp1". And I divide the corrected pressure by 100 because it's in
P
That looks right. At least in theory. :-)
One thing I should note, and maybe you have already done this, but the main
weewx loop will block when it hits read_raw_data(). You need to make sure
it doesn't delay things too long. A second or two is fine, but you don't
want to be waiting half a minute
The data is sitting in six registers and I'm just reading it out, so there
won't be a delay.
The longest it should take to get a sample, with maximum resolution and
filtering, according to the data sheet, is under 50ms. The delay (in
normal mode) between samples is configurable, but only up
OK, all done. It took some tweaks. Keep in mind that this is my first
Python program and first programming of any kind in twenty-five years.
import time
import smbus
import syslog
import weewx
from weewx.engine import StdService
# Inherit from the base class StdService:
class bmp(StdService):
OK, take two. It works after some tweaking. This is my first program in
twenty-five years and first in Python ever, so I'm sure it's ugly. But it
works.
This goes into weewx.conf
[BMP280]
col_temp = extraTemp1
col_pres = barometer
pressure_oversampling = 4
temperature_oversa
col_pres should be "pressure. I read that part of the weewx documentation, but
I didn't remember it right.
The pressure from the BMP280 does not take elevation into account.
I am also interested in this, and here's what I've managed to do / not do.
I attached the sensor, and ran
sudo i2cdetect -y 1
to check it was there.
It was showing as position 0x77, which is decimal 119 just as in Craig's
post above.
These parts were missing above, and I eventually figured ou
Hi,
In this case order matters. The StdArchive service is the service that does the
final processing of archive records and ultimately saves the archive record to
database. You have placed your service after StdArchive so by the time your
service is obtaining data, and presumably adding it to l
Right.. ok, makes sense now.
The file from Craig Thom seems to do a lot of processing, and converting,
and filtering/massaging... so wasn't clear on that point
So I went back to the electricity example in the customizing guide, and it
sort of makes sense now!
I am not sure what all that ca
Yes, simple is best.
Converting, calculating etc is ok, though as with a driver a data service
should really just be getting raw data from a sensor, decoding it as required
and then making sure it is in the correct units (ie observing the usUnits field
in the loop packet/archive record you are
Thanks. I read above that Tom suggested
new_valueTuple = weewx.units.convertStd((22.5, "degree_C",
"group_temperature"), packet['usUnits'])
However packet is undefined in eg, the electricity example. (I get an error)
So I am doing
pres_tuple = weewx.units.convertStd((hectopascals, "mbar",
"g
Here's what I have working:
#!/usr/bin/env python
import syslog
import weewx
from weewx.wxengine import StdService
from Adafruit_BME280 import *
class PressureService(StdService):
def __init__(self, engine, config_dict):
super(PressureService, self).__init__(engine, config_dict)
Generally speaking if your service is based on StdService and it's properly
constructed then the 'event' parameter should have either event.packet or
event.record (depending on whether it is bound to NEW_LOOP_PACKET or
NEW_ARCHIVE_RECORD) which will give you access to the loop packet or event
r
So, thanks for all your help, here's what I finally have working.
It's a little more generic, as in I can specify in weewx.conf where my BMP
library is, what my sea level modifier is, and where I want to store the
values, if at all
weewx.conf
[BMP280]
col_pres = pressure
col_temp = ''
Looks good, one thing you can do to make your code a little more readable
is to make use the available properties of ValueTuple objects.
weewx.units.convertStd returns an object of type ValueTuple. ValueTuple
objects have 3 useful properties; .value, .unit and .group. In your code
you could rep
28 matches
Mail list logo