DH22 is really DHT22

On Friday, April 7, 2017 at 5:23:02 PM UTC-5, Tommy Denton wrote:
>
> I have a custom hardware setup.. the DHT22 and BME280 are outputting data 
> las they should..(best I can tell)
>
> For my own quick and dirty webpage I did some maths to get pascals to inHg 
> but now I want to do this in weewx and with some expert help on this forum 
> I am like 98 percent there.. I have learned a lot but have hit the wall I 
> always hit when I can't find some code to read or I don't know what code I 
> am reading. Now I have read the manual and each time I get over one of 
> these hurdles more of that manual changes from greek to english...but alas 
> I am blocked by my own ignorance..
>
> So.. here is what I am doing for my own webpage..
>
> #Setup and pull data from the Sensor
> #bme280
> from Adafruit_BME280 import *
> sensor = BME280(mode=BME280_OSAMPLE_8)
> temperature = sensor.read_temperature()
> pascals = sensor.read_pressure()
>
> #Setup and pull data from the Sensor
> #AM2303
> import Adafruit_DHT
> sensor = Adafruit_DHT.AM2302
> pin = 17
> humidity, degrees = Adafruit_DHT.read_retry(sensor, pin)
>
> #Setup Time
> #time
> import time
> from datetime import datetime
> from time import strftime, localtime
>
> #Load up Converter
> #calcs
> from meteocalc import dew_point, heat_index
> temp = degrees*9/5+32
> baro = pascals/3386.389
> dewpoint = dew_point(temperature=degrees, humidity=humidity)
> heatindex = heat_index(temperature=degrees, humidity=humidity)
>
>
> My sensor puts out Pa
> I divide PA by 3386.839 and that gets me to inHg
>
> I output this to a file and it comes in to the right range and matches 
> other weather stations around me plus or minus .10 inHg, so I feel like I 
> have things setup correctly.
>
> Now this leads me to the error I am getting.
> The error I get is because the reading is outside the QA range limits.. So 
> I have to tried to back into the number some to figure out what is going 
> on....engine: 2017-04-06 23:10:39 CDT (1491538239) LOOP value 'pressure' 
> 85.32306 outside limits (24.0, 34.5)
>
> 85.32306... Where the heck did that number come from?  Well that 
> is 85.32inHg/.029 = 2942.06896hPa*100 = 294206.8965517Pa
> Since hPa = mBAR there is no conversion there..
>
> The math is wrong in weewx.units?.. but I don't believe that either.. it 
> has to be me messing up the math.. but I am not sure where to go from here 
> to put in a custom conversion into extensions.py... I just have not been 
> able to figure out the code to do so..
>
> or I am otherwise all wet.. 
>
> My driver looks like this.. (Expertly written by a very nice MWall)
>
> !/usr/bin/python
>
> import time
> import Adafruit_BME280
> import Adafruit_DHT
> import weewx.drivers
> from weewx.units import INHG_PER_MBAR
>
> 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() * 
> weewx.units.INHG_PER_MBAR
>                 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)
>             time.sleep(10) # wait 60 seconds before getting next set of 
> data
>
>
>
>
>

-- 
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.

Reply via email to