Last active
March 31, 2017 08:51
-
-
Save mhubig/2ad0e6bf216cc038ec43b5157ec4bad9 to your computer and use it in GitHub Desktop.
Pseudocode Draft of an IFPVIS Logger application ...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# -*- coding: UTF-8 -*- | |
import time | |
import implib2 | |
import bravado | |
LOGGER_ID = 'LG001' | |
# Initialize the IFPVIS API Client | |
client = bravado.client.SwaggerClient.from_url('http://api.ifpvis.io/v1/swagger.json') | |
# Initialize the IMPBus2 | |
bus = implib2.Bus('/dev/ttyUSB0') | |
bus.sync() | |
# Search the bus for connected modules | |
modules = [imp.Module(bus, serno) for serno in bus.scan()] | |
# Start a measurement and post the results to the api | |
while True: | |
# get the measurement periode | |
periode = client.config.period.getByLoggerID(LOGGER_ID) | |
for module in modules: | |
serno = module.get_serno() | |
moist = module.get_moisture() | |
mtemp = module.get_measure(quantity='MeasTemp') | |
client.measuring.rawMeasurements.addByLoggerID(LOGGER_ID, (serno, moist, mtemp)) | |
time.sleep(periode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment