Exemplo n.º 1
0
    print("Starting growlab")

    config = {}
    try:
        with open("./config.json") as f:
            config = json.loads(f.read())
    except Exception as e:
        sys.stderr.write("Error: {}".format(e))
        sys.exit(1)

    print("Loaded config, saving images every {} seconds to {}".format( config["images"]["interval_seconds"], config["images"]["output_directory"]))

    sensor = None
    sensor_type = os.getenv("SENSOR_TYPE", "bme280")
    if sensor_type == "bme280":
        sensor = growbme280()
    if sensor_type == "bmp280":
        sensor = growbmp280()
    elif sensor_type == "none":
        sensor = grownosensor()

    readings = sensor.get_readings()
    print(readings)

    cam = camera(config["images"])
    frame = cam.get_frame()
    print(frame)

    pwd = os.getcwd()
    output_path = pwd + "/html"
Exemplo n.º 2
0
import time
import os, json
from sensors import growbme280
import requests
from datetime import datetime

bme280 = growbme280()

function_url = os.getenv("FUNCTION_URL")  # change this on each Pi
sensor_name = os.getenv("SENSOR")
sample_duration = 30  # seconds

if function_url == None:
    sys.stderr.write("env-var FUNCTION_URL is required i.e. http://192.168.0.21:8080/function/submit-sample")
    os.exit(1)

if sensor_name == None:
    sys.stderr.write("env-var SENSOR is required i.e. shed1")
    os.exit(1)

def get_cpu_temp():
    path="/sys/class/thermal/thermal_zone0/temp"
    f = open(path, "r")
    temp_raw = int(f.read().strip())
    temp_cpu = float(temp_raw / 1000.0)
    return temp_cpu

try:
    while True:
        print("Gathering sensor data.")
        temp_cpu = get_cpu_temp()