Last active
August 2, 2017 07:46
-
-
Save jeznag/25b4b32885cbffb32c2a062d84e95aaa to your computer and use it in GitHub Desktop.
Send serial data to ada fruit IO
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
from Adafruit_IO import * | |
import sys, os, serial, threading | |
aio = Client('CLIENT_KEY') | |
def monitor(): | |
ser = serial.Serial('/dev/tty.usbmodem1411', 9600) | |
while (1): | |
line = ser.readline() | |
if (line != ""): | |
str_data = (line.replace("concentration = ", "").replace("pcs/0.01cf", "").strip()) | |
if (len(str_data) != 0): | |
data = float(str_data) | |
aio.send('AQ data', data) | |
print data | |
text_file = open("aq-data.log", "a") | |
text_file.write(str(data) + "\n") | |
text_file.close() # do some other things here print "Stop Monitoring" | |
""" ------------------------------------------- | |
MAIN APPLICATION | |
""" | |
print "Start Serial Monitor" | |
monitor() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment