#time functions import time #record script runtime #start_time = time.time() #import labjack from labjack import ljm #to add element wise from operator import add #open labjack d = ljm.openS("ANY","ANY","ANY") #analog inputs to grab names = ["AIN0","AIN1","AIN2", "AIN4","AIN5", "AIN6","AIN7", "AIN8","AIN9"] numFrames = len(names) loopAmount = 25 i = 0 #initialize array result = [0,0,0,0,0,0,0,0,0] #run through loops a fixed number of times while i < loopAmount: #read names data = ljm.eReadNames(d,numFrames,names) #print(data) #sum result = map(add,result,data) #print(result) i = i + 1 time.sleep(1) #average data over i points r = [x / i for x in result] #print(r) #close labjack ljm.close(d) #file writing import csv #get time for data file time stamp now = time.strftime('%Y-%m-%d %H:%M:%S') #turn array into string for printing pr = ','.join(str(i) for i in r) #concatonate time with data and end of line string = now + "," + pr + "\n" #print(pr) #open file and write f=open('data.csv', 'a') f.write(string) #close file #print("--- %s seconds ---" % (time.time() - start_time)) # Import the ISStreamer module from ISStreamer.Streamer import Streamer #open streamer streamer = Streamer(bucket_name="HF Data", bucket_key="hf_data", access_key="") # send data #streamer.log("Message", "Stream Starting") streamer.log_object(r,"hf") #streamer.log("Heat Flux Temp Data",r) #streamer.log("Message", "Stream Done") streamer.close()