Пример #1
0
pin_numbers = (0, 2, 4, 5, 12, 13, 14, 15)
PINS = OrderedDict((i, machine.Pin(i, machine.Pin.IN)) for i in pin_numbers)

#configure humidity/temperature sensor interface
try:
    from am2315 import AM2315
except ImportError:
    from mock_am2315 import AM2315

try:
    from micropython import mem_info
except ImportError:
    mem_info = lambda: None

ht_sensor = AM2315()
ht_sensor.init()


################################################################################
# APPLICATION CODE
#-------------------------------------------------------------------------------
@Router
class P5jsServer(WebApp):
    @route("/", methods=['GET'])
    def index(self, context):
        context.send_file("html/index.html")

    @route(regex="/(\w+)/?(\w+[.](js|html|png|jpg|svg))?", methods=['GET'])
    def file_resource(self, context):
        #this route handles all valid file resources under html directory
from grove_o2 import GroveO2
import logging
logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
handler = logging.FileHandler('/home/pi/openag_brain_box/ui/main.log')
handler.setLevel(logging.INFO)
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)

if __name__ == "__main__":
    shared = memcache.Client(['127.0.0.1:11211'], debug=0)
    mhz16_1 = MHZ16()
    am2315_1 = AM2315()

    with open('/home/pi/openag_brain_box/ui/config.csv',
              mode='r') as config_file:
        reader = csv.reader(config_file)
        config = {rows[0]: rows[1] for rows in reader}
        logger.debug(config)
        atlas_ph_id = None
        atlas_ec_id = None
        try:
            atlas_ph_id = config["atlas_ph_id"]
            atlas_ec_id = config["atlas_ec_id"]
            logger.debug("Atlas pH ID is: {}, Atlas EC ID is: {}".format(
                atlas_ph_id, atlas_ec_id))
        except:
            logger.error("Unable to parse config file")
Пример #3
0
#!/usr/bin/env python

from am2315 import AM2315

thsen = AM2315.AM2315()
print "T   ", thsen.read_temperature()
print "H   ", thsen.read_humidity()
print "H,T ", thsen.read_humidity_temperature()

try:
    from tsl2561 import TSL2561
    from bme280 import BME280, BMP280_I2CADDR
    from am2315 import AM2315
except Exception as e:
    print(e)
    led_error(step=3)

# declare le bus i2c
i2c = I2C(sda=Pin(4), scl=Pin(5))

# créer les senseurs
try:
    tsl = TSL2561(i2c=i2c)
    bmp = BME280(i2c=i2c, address=BMP280_I2CADDR)
    am = AM2315(i2c=i2c)
except Exception as e:
    print(e)
    led_error(step=4)

try:
    # annonce connexion objet
    sMac = hexlify(WLAN().config('mac')).decode()
    q.publish("connect/%s" % CLIENT_ID, sMac)
except Exception as e:
    print(e)
    led_error(step=5)

try:
    while runapp.value() == 1:
        led.value(1)  # eteindre pendant envoi
Пример #5
0
                       out_temp_topic, out_humid_topic,
                       raspicam_topic)


raspicam = ['raspistill', '-n', '-vf', '-hf',
            '-t', '1000', '-br', '55', '-o', '-']

bmp = BMP280()
bmp.set_acquisition_options(16, 16, 2)
bmp.set_config(1000, 16)

bme = BME280(alternativeAddress=True)
bme.set_acquisition_options(16, 16, 2, 16)
bme.set_config(1000, 16)

out = AM2315(bus=3)


def upload_bmp():
    try:
        BMPtemperature = bmp.temperature()
        BMPpressure = bmp.pressure(update_temperature=False)
    except BMP280Error:
        print('BMP280 Error')
        return
    publish(bmp_temp_topic, BMPtemperature)
    publish(bmp_press_topic, BMPpressure)


def upload_bme():
    try: