Exemple #1
0
tca9545.write_control_register(TCA9545_CONFIG_BUS0)

anenometerPin = 23
rainPin = 24

# constants

SDL_MODE_INTERNAL_AD = 0
SDL_MODE_I2C_ADS1015 = 1

#sample mode means return immediately.  THe wind speed is averaged at sampleTime or when you ask, whichever is longer
SDL_MODE_SAMPLE = 0
#Delay mode means to wait for sampleTime and the average after that time.
SDL_MODE_DELAY = 1

weatherStation = SDL_Pi_Weather_80422.SDL_Pi_Weather_80422(
    anenometerPin, rainPin, 0, 0, SDL_MODE_I2C_ADS1015)

weatherStation.setWindMode(SDL_MODE_SAMPLE, 5.0)
#weatherStation.setWindMode(SDL_MODE_DELAY, 5.0)

################

# DS3231/AT24C32 Setup
filename = time.strftime("%Y-%m-%d%H:%M:%SRTCTest") + ".txt"
starttime = datetime.utcnow()

ds3231 = SDL_DS3231.SDL_DS3231(1, 0x68, 0x57)
#comment out the next line after the clock has been initialized
ds3231.write_now()
################
#import dependencies
sys.path.append('./dep')
sys.path.append('./dep/Adafruit_ADS1x15')
import dht11, SDL_DS3231
import SDL_Pi_Weather_80422 as SDL80422

#variables
pinAnem = 23
pinRain = 24
DHTpin = 14

#initialize the GPIO for the DHT11 & set modes for wind/rain sensors
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.cleanup()
windrain = SDL80422.SDL_Pi_Weather_80422(pinAnem, pinRain, 0, 0, 1)
windrain.setWindMode(0, 5.0)

#sqlite
conn = sqlite3.connect('wxdata.db')
c = conn.cursor()
c.executescript('''
CREATE TABLE IF NOT EXISTS data (
    id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
    datetime TEXT UNIQUE,
    temp TEXT, 
    pres TEXT,
    hum TEXT,
    dewpoint TEXT,
    windspeed TEXT,
    windgust TEXT,