Also script is in user dir

Nev

On Friday, March 3, 2017 at 11:10:10 AM UTC+10, Neville Davis wrote:
>
> Frank also this in weewx.conf
>
>    
>     #station_type = Simulator
>
>     station_type = PiWeather
>
>
>
> #############################################################################
>
> [PiWeather]
>     loop_interval = 2.5
>     driver = user.piweather
>
>
> ############################################################################
>
> Neville
>
> On Friday, March 3, 2017 at 11:02:36 AM UTC+10, Neville Davis wrote:
>>
>> Frank
>>
>> I use the following has been faultless for months on Pi3 with data from 
>> i2C and other sensors
>>
>> #
>> #    $Revision: 1 $
>> #    $Author: Nickolas McColl $
>> #    $Date: 2014-08-16 $
>> #    Initial information from above author further edits by Nev Davis
>> #    Latest edit 12 Dec 2016 by Nev Davis reconfigured to place in user 
>> dir
>>
>> """Raspberry Pi driver for the weewx weather system"""
>>
>> from __future__ import with_statement
>> import math
>> import time
>> import weewx.units
>> import weedb
>> import weeutil.weeutil
>> import weewx.drivers
>> import weewx.wxformulas
>>
>> DRIVER_NAME = 'PiWeather'
>> DRIVER_VERSION = "1.8"
>>
>> def loader(config_dict, engine):
>>     return PiWeatherDriver(**config_dict[DRIVER_NAME])
>>        
>> def confeditor_loader():
>> return PiWeatherConfEditor()
>>
>> class PiWeatherDriver(weewx.drivers.AbstractDevice):
>>
>>     def __init__(self, **stn_dict):
>>         self.loop_interval = float(stn_dict.get('loop_interval',2.5))
>>
>>     def genLoopPackets(self):
>>         while True:
>>             start_time = time.time()
>>
>>             # Create Loop packet
>>             f = open('/var/ramdisk/wxdata.csv')
>>             input = f.readline()
>>             f.close()
>>
>>             data = input.split(',')
>>             if len(data) == 13: # data line is complete, process
>>                 for i in range(1, (len(data))):
>>                     try:
>>                         data[i] = float(data[i])
>>                     except ValueError:
>>                         data[i] = None
>>            
>>                 raw_time =time.strptime(data[0], "%Y-%m-%d %H:%M:%S")
>>             
>>                 _packet = {'dateTime': int(time.mktime(raw_time)),
>>                       'usUnits' : weewx.METRIC,
>>                       'outTemp' : data[1],
>>                       'outHumidity' : data[2],
>>                       'pressure' : data[6],
>>                       'extraTemp1' : data[7],
>>                       'windSpeed' : data[3], #use 3 second average
>>                       'windGust' : data[4], #use 3 second average
>>                       'windDir' : data[5],
>>                       'radiation' :data[11],
>>                       'inTemp' : data[8],
>>                       'inHumidity' : data[9],
>>                       'UV' : data[10],
>>                       'farsSpeed' : data[12]
>>                       #'referenceVoltage' : data[12]
>>                       #'UV' : data[11]
>>                           }
>>                 _packet['dewpoint'] = 
>> weewx.wxformulas.dewpointC(_packet['outTemp'], _packet['outHumidity'])
>>                 #_packet['barometer'] = 
>> weewx.wxformulas.sealevel_pressure_Metric(_packet['pressure'], 
>> self.altitude, _packet['outTemp'])
>>                 #_packet['altimeter'] = 
>> weewx.wxformulas.altimeter_pressure_Metric(_packet['pressure'], 
>> self.altitude)
>>                 _packet['heatdeg'] = 
>> weewx.wxformulas.heating_degrees(_packet['outTemp'], 18.333)
>>                 _packet['cooldeg'] = 
>> weewx.wxformulas.cooling_degrees(_packet['outTemp'], 18.333)
>>                 _packet['heatindex'] = 
>> weewx.wxformulas.heatindexC(_packet['outTemp'], _packet['outHumidity'])
>>  
>>                 yield _packet
>>      
>>             sleep_time = (start_time - time.time()) + self.loop_interval
>>             #sleep_time = self.loop_interval
>>             if sleep_time > 0:
>>                   time.sleep(sleep_time)
>>
>> class PiWeatherConfEditor(weewx.drivers.AbstractConfEditor):
>>     @property
>>     def default_stanza(self):
>>       return
>>            
>>     
>> Neville
>>
>> On Thursday, March 2, 2017 at 8:53:45 AM UTC+10, mwall wrote:
>>>
>>>
>>>
>>> On Wednesday, March 1, 2017 at 2:32:28 PM UTC-5, Frank Johnson wrote:
>>>>
>>>> ok now im confused (big time) here is my log file and looks like it 
>>>> should work so what is it looking for...
>>>>
>>>  
>>> frank,
>>>
>>> the code i posted is not tested, and in fact is not correct.  this is 
>>> closer:
>>>
>>> with open(filename) as f:
>>>     line = f.readline()
>>>     values = line.split(',')
>>>     record['inTemp'] = float(values[0])
>>>     record['inHumidity'] = float(values[1])
>>>     record['barometer'] = float(values[2])
>>>
>>> but there is no error-checking, and you still need to check 
>>> record['usUnits'] to see whether you need to do any unit conversions.
>>>
>>> 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