Re: [weewx-development] Pressure resolution and BMP280

2018-08-21 Thread David Moore
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 out as he's 
running it as a service:

I then took his file, bmp280.py amd put it in /usr/share/weewx/user/
I then added to weewx.conf as above.

However i ALSO had to add this to the engine services part:

archive_services = weewx.engine.StdArchive, user.bmp280.bmp

(I was getting errors before that)

So, now weewx runs without error

In the logs I can see this:

Aug 21 17:27:38 WeatherPi weewx[1589]: manager: Daily summary version is 2.0
Aug 21 17:27:38 WeatherPi weewx[1589]: engine: Using binding 'wx_binding' 
to database 'weewx'
Aug 21 17:27:38 WeatherPi weewx[1589]: manager: Starting backfill of daily 
summaries
Aug 21 17:27:38 WeatherPi weewx[1589]: engine: Finished loading service 
weewx.engine.StdArchive
Aug 21 17:27:38 WeatherPi weewx[1589]: engine: Loading service user.bmp280.
bmp
Aug 21 17:27:38 WeatherPi weewx[1589]: engine: Finished loading service user
.bmp280.bmp
Aug 21 17:27:38 WeatherPi weewx[1589]: engine: Loading service weewx.restx.
StdStationRegistry
Aug 21 17:27:38 WeatherPi weewx[1589]: restx: StationRegistry: Registration 
not requested.
Aug 21 17:27:38 WeatherPi weewx[1589]: engine: Finished loading service 
weewx.restx.StdStationRegistry

However, nothing is getting written to db.

I tried this to check everything on the sensor was ok:

git clone https://github.com/adafruit/Adafruit_Python_GPIO.git
cd Adafruit_Python_GPIO 
sudo python setup.py install 
cd ../ 
git clone https://github.com/adafruit/Adafruit_Python_BME280.git 
cd Adafruit_Python_BME280 
python ./Adafruit_BME280_Example.py 
 

Temp  = 29.053 deg C 
Pressure  = 890.79 hPa 
Humidity  = 0.00 %



So, I'm stumped now.  Will let you know if I get it working, however I feel 
I'm going to need some help...









On Tuesday, 26 June 2018 20:15:21 UTC+2, Tim Urberg wrote:
>
> I know it's been a while, but just wondering if there's any update on 
> this, I was thinking of using this and wanted to make sure it worked before 
> buying one.
>
> Thanks!
> Tim
>
> On Saturday, April 8, 2017 at 6:35:33 AM UTC-5, Craig Thom wrote:
>>
>> 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.
>>
>

Re: [weewx-development] Pressure resolution and BMP280

2018-08-21 Thread gjr80
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 loop packets and/or 
archive records, data has already been saved to database and hence your data is 
effectively lost. Your service needs to be called before StdArchive.

If you have a look at the [Engine] [[Services]] stanza in weewx.conf you will 
see the are a number of config options that list the services WeeWX will run. 
Have a read of the User's Guide covering this 
(http://www.weewx.com/docs/usersguide.htm#[Engine]). Whilst it does not really 
matter, you would be better off including your service as a 'data' service 
(hmm, just noticed data services are not covered in the User's Guide - need  to 
fix that). Data services should be adding data to the packets/records being 
produced by the driver, data services are called before any of the process 
services (and archive services) that calibrate/convert etc the data. Try 
something like:

data_services = user.bmp280.bmp

Gary


Re: [weewx-development] Pressure resolution and BMP280

2018-08-21 Thread David Moore
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 calibration and manipulation is in his file, 
so, given there's standard libraries for reading from BMP280 I will just 
use those and write a shorter, and hopfully simpler service.

Thanks!

Dave

On Tuesday, 21 August 2018 22:24:59 UTC+2, gjr80 wrote:
>
> 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 
> loop packets and/or archive records, data has already been saved to 
> database and hence your data is effectively lost. Your service needs to be 
> called before StdArchive.
>
> If you have a look at the [Engine] [[Services]] stanza in weewx.conf you 
> will see the are a number of config options that list the services WeeWX 
> will run. Have a read of the User's Guide covering this (
> http://www.weewx.com/docs/usersguide.htm#[Engine]). Whilst it does not 
> really matter, you would be better off including your service as a 'data' 
> service (hmm, just noticed data services are not covered in the User's 
> Guide - need  to fix that). Data services should be adding data to the 
> packets/records being produced by the driver, data services are called 
> before any of the process services (and archive services) that 
> calibrate/convert etc the data. Try something like:
>
> data_services = user.bmp280.bmp
>
> Gary
>
>

Re: [weewx-development] Pressure resolution and BMP280

2018-08-21 Thread gjr80
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 adding your data to) before adding it 
to the current loop packet/archive record (a common pitfall is to add 
temperature data in say F when all the temperatures in the existing 
packet/record are in C, hence the need to observe usUnits). That way 
StdConvert, StdCalibrate can do all their converting and calibrating and 
produce sensible results.

Gary

Re: [weewx-development] Pressure resolution and BMP280

2018-08-21 Thread David Moore
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", 
"group_pressure"),weewx.US)

As my DB is in default US units. However there is probably a way to read 
this from the weewx.conf

But then I'm not sure why that's defined at packet level in the example, 
unless I am reading lots of data (eg from different devices with SDR, that 
have different formats).
But then, I'm not *adding *to one of those, this is sort of "standalone".

So not quite sure what to replace weewx.US with that will always work.

Finally, I am converting data to sea level pressure, is that the correct 
value to be storing?
Finally Finally, is there some way to calibrate the pressure? it's 5HPa off 
my acurite 5n1 reading, but closer to what the local weather service is 
saying.



On Tuesday, 21 August 2018 22:48:30 UTC+2, gjr80 wrote:
>
> 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 adding your data 
> to) before adding it to the current loop packet/archive record (a common 
> pitfall is to add temperature data in say F when all the temperatures in 
> the existing packet/record are in C, hence the need to observe usUnits). 
> That way StdConvert, StdCalibrate can do all their converting and 
> calibrating and produce sensible results.
>
> Gary
>
>

Re: [weewx-development] Pressure resolution and BMP280

2018-08-21 Thread Tim Urberg

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)
    self.bind(weewx.NEW_ARCHIVE_RECORD, self.read_sensors)

    def read_sensors(self, event):
    sensor = BME280(t_mode=BME280_OSAMPLE_8, 
p_mode=BME280_OSAMPLE_8, h_mode=BME280_OSAMPLE_8)

    degrees = sensor.read_temperature()
    pascals = sensor.read_pressure()
    event.record['inTemp'] = float((degrees*9/5)+32)
    event.record['pressure'] = float(pascals * 0.00029530)

It is reporting both pressure and indoor temp, I don't have the one that 
has humidity.


On 8/21/2018 11:18 AM, David Moore wrote:

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 out as he's 
running it as a service:


I then took his file, bmp280.py amd put it in /usr/share/weewx/user/
I then added to weewx.conf as above.

However i ALSO had to add this to the engine services part:

|
archive_services =weewx.engine.StdArchive,user.bmp280.bmp
|

(I was getting errors before that)

So, now weewx runs without error

In the logs I can see this:

|
Aug2117:27:38WeatherPiweewx[1589]:manager:Dailysummary version is2.0
Aug2117:27:38WeatherPiweewx[1589]:engine:Usingbinding 'wx_binding'to 
database 'weewx'
Aug2117:27:38WeatherPiweewx[1589]:manager:Startingbackfill of daily 
summaries
Aug2117:27:38WeatherPiweewx[1589]:engine:Finishedloading service 
weewx.engine.StdArchive

Aug2117:27:38WeatherPiweewx[1589]:engine:Loadingservice user.bmp280.bmp
Aug2117:27:38WeatherPiweewx[1589]:engine:Finishedloading service 
user.bmp280.bmp
Aug2117:27:38WeatherPiweewx[1589]:engine:Loadingservice 
weewx.restx.StdStationRegistry

Aug2117:27:38WeatherPiweewx[1589]:restx:StationRegistry:Registrationnotrequested.
Aug2117:27:38WeatherPiweewx[1589]:engine:Finishedloading service 
weewx.restx.StdStationRegistry

|

However, nothing is getting written to db.

I tried this to check everything on the sensor was ok:

|
git clone https://github.com/adafruit/Adafruit_Python_GPIO.git 


cd Adafruit_Python_GPIO
sudo python setup.py install
cd ../
git clone https://github.com/adafruit/Adafruit_Python_BME280.git 


cd Adafruit_Python_BME280
python ./Adafruit_BME280_Example.py


Temp=29.053deg C
Pressure=890.79hPa
Humidity=0.00%
|



So, I'm stumped now.  Will let you know if I get it working, however I 
feel I'm going to need some help...










On Tuesday, 26 June 2018 20:15:21 UTC+2, Tim Urberg wrote:

I know it's been a while, but just wondering if there's any update
on this, I was thinking of using this and wanted to make sure it
worked before buying one.

Thanks!
Tim

On Saturday, April 8, 2017 at 6:35:33 AM UTC-5, Craig Thom wrote:

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.





---
This email has been checked for viruses by AVG.
https://www.avg.com


Re: [weewx-development] Pressure resolution and BMP280

2018-08-21 Thread gjr80
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 
record just as Tim has done. There was no context in Tom's example and I 
suspect that is why there is the subtle difference.

Gary