Exemplo n.º 1
0
#! /usr/bin/python
#*************************************************************************************************************
#[email protected] disclaimer bla bla bla don't use for control of neuclar reactors
#*************************************************************************************************************
import serial
from cosm import Cosm
FEED = "68554"
API_KEY = 'Din Cosm nøgÃle her'

cosm = Cosm( FEED, API_KEY )

ser = serial.Serial('/dev/ttyACM0', 9600)

def is_number_ok( nval ):
	try:
		if( float(nval) < 50 and float(nval) > -50 ):
			return True
		else:
			return False
	except ValueError:
		return False

while 1:
	a = ser.readline().rstrip()
	if( is_number_ok(a) ):
		#print a
		info = [
			("10", a )
		]
		try:
			cosm.put( info )
Exemplo n.º 2
0
def append_to_log_file(filename, date, response):

    file = open(filename, "a")
    file.write(str(date))
    file.write("=")
    file.write(str(response))
    file.write("\n")
    file.close()

# open up the USB serial port to get data transmitted to xbee
ser = Serial(SERIALPORT, BAUDRATE)
xbee = XBee(ser)

print "Connected to XBee at " + SERIALPORT

cosm = Cosm(cosm_config.FEED_ID, cosm_config.API_KEY)

# Continuously read and print packets
while True:
    try:
        response = xbee.wait_read_frame()

        now = datetime.now()
        print "======", now

        print "XBee Frame", response

        append_to_log_file(LOG_FILENAME, now, response)

        sourceAddress = getSourceAddress(response)
        print "Source:", sourceAddress
Exemplo n.º 3
0
from log import err
import arduino
import objects
import ds18s20

glob = objects.Vars()
glob.set('terminate', False)
glob.set('threads', list())
hole_motion = objects.MotionSensor()
room_motion = objects.MotionSensor()
IR_codes = dict()  # Binded funcitions on IR codes
repeatable_IR = {b'FFE01F', b'FFA857'}  # This IR codes can be repeated
last_IR = ''  # Last IR received code
ultra = Ultra()
cron = objects.Crontab(glob=glob)
cosm = Cosm(cosm_config.FEED_ID, cosm_config.API_KEY)
alice = Alice(glob=glob)
hole_night_light = objects.gpioLight(11, mode=objects.LIGHT_MODE_AUTO)
hole_light = objects.nooLite(0)  # USB NooLite on channale 0


def signal_handler(signal, frame):
    log('Time to terminate. Exit')
    print('Time to terminate. Setting the terminate flag\n')
    print("Active threads: ", threading.active_count())
    glob.set('terminate', True)
    for i in xrange(10):
        print("Active threads: ", threading.active_count(),
              ". Wait more %d seconds" % (10 - i))
        if threading.active_count() == 1:
            break