Added "Import time" and boom we are collecting data..

now the next fun part..

The sensor outputs hectopascals so to convert that in the driver is going 
to be fun.

hectopascals = pascals / 100
baro = 0.02952998751*hectopascals



On Thursday, March 30, 2017 at 1:05:58 PM UTC-5, Tommy Denton wrote:
>
> gjr80 - mwall 
>
> Thank you all very much.. This is exactly the bridge I needed.. based on 
> this I totally understand the documentation now.
>
> I am getting this now..
>
> Traceback (most recent call last):
>   File "/usr/bin/weewxd", line 64, in <module>
>     weewx.engine.main(options, args)
>   File "/usr/share/weewx/weewx/engine.py", line 871, in main
>     engine.run()
>   File "/usr/share/weewx/weewx/engine.py", line 187, in run
>     for packet in self.console.genLoopPackets():
>   File "/usr/share/weewx/user/pihat.py", line 23, in genLoopPackets
>     packet['dateTime'] = int(time.time() + 0.5)
> NameError: global name 'time' is not defined
>
> Which means things are working!  I will solve the time issue and post the 
> fix here..
>
> I was so close so many times.. hope this helps others!
>
> T
>
> On Thursday, March 30, 2017 at 12:06:05 AM UTC-5, mwall wrote:
>>
>> you have a few options.  here are three.
>>
>> 1) use the fileparse driver to read the data that your existing python 
>> script is emitting.  start with the fileparse.py driver, but modify it to 
>> read comma-delimited values instead of name=value pairs.
>>
>> 2) modify your script to emit one name=value pair per line and use the 
>> fileparse driver as-is.  install fileparse like this:
>>
>> wee_extension --install examples/fileparse
>>
>> then weewx.conf will look something like this:
>>
>> station_type = FileParse
>>
>> [FileParse]
>>     driver = user.fileparse
>>     path = /var/www/html/weather/measurements.txt
>>
>> 3) create your own driver, using code similar to your existing python 
>> script.  to do this, create a file pihat.py and put it in the weewx user 
>> directory.  the pihat.py file should contain something like this:
>>
>> import Adafruit_BME280
>> import Adafruit_DHT
>> import weewx.drivers
>>
>> DRIVER_NAME = 'PiHat'
>> DRIVER_VERSION = '0.1'
>>
>> def loader(config_dict, engine):
>>     return PiHatDriver(**config_dict[DRIVER_NAME])
>>
>> class PiHatDriver(weewx.drivers.AbstractDevice):
>>     def __init__(self, **stn_dict):
>>         self._sensor1 = 
>> Adafruit_BME280.BME280(mode=Adafruit_BME280.BME280_OSAMPLE_8)
>>         self._sensor2 = Adafruit_DHT.AM2302
>>         self._pin = 17
>>
>>     def genLoopPackets(self):
>>         while True:
>>             try:
>>                 packet = dict()
>>                 packet['dateTime'] = int(time.time() + 0.5)
>>                 packet['usUnits'] = weewx.METRIC
>>                 packet['inTemp'] = self._sensor1.read_temperature()
>>                 packet['pressure'] = self._sensor1.read_pressure()
>>                 packet['outHumidity'], packet['outTemp'] = 
>> Adafruit_DHT.read_retry(self._sensor2, self._pin)
>>                 yield packet
>>             except IOError, e:
>>                 syslog.syslog(syslog.LOG_ERR, "get data failed: %s" % e)
>>
>> then in weewx.conf do this:
>>
>> station_type = PiHat
>>
>> [PiHat]
>>     driver = user.pihat
>>
>> hope that helps
>>
>> m
>>
>

-- 
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 weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to