Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import serial
- import datetime
- from time import sleep
- import atexit
- import os
- import time
- from time import ctime
- import datetime
- from bokeh.plotting import figure, output_file, show
- output_file("/var/www/html/index.html")
- p = figure()
- arduino_serial = serial.Serial(port='/dev/ttyACM1', baudrate=115200, parity='N', stopbits=1, timeout=1)
- data = []
- timea=[]
- humi = []
- temp = []
- location = 0
- def getdata():
- with open("log.txt","a") as file :
- arduino_serial.flushInput()
- arduino_serial.flushOutput()
- linet = arduino_serial.readline().decode('UTF-8')
- tmp = linet.strip('\n').split(' ')
- tmp = [datetime.datetime.now().minute,eval(tmp[0]),eval(tmp[1])]
- data.append(tmp)
- timea.append(datetime.datetime.now().minute)
- humi.append(tmp[1])
- temp.append(tmp[2])
- print(humi[0:len(humi)])
- #temp.append(eval(tmp[1]))
- #print("[ "+ctime()+" ] "+line)
- file.write("[ "+ctime()+" ] "+linet)
- # send = input("SEND TO ARDUINO: ")
- # arduino_serial.write(send.encode())
- print()
- p.line(timea[0:len(timea)],humi[0:len(humi)],line_width=2)
- p.rect(x=timea[0:len(timea)], y=humi[0:len(humi)], width=0.4, height=h, color="#CAB2D6")
- show(p)
- def _main_():
- print("Wait for Arduino...")
- time.sleep(1)
- file = open("log.txt","a")
- # if arduino_serial.is_open:
- line = arduino_serial.readline()
- print(line)
- inp = str(input("INPUT HERE: "))
- while (1):
- arduino_serial.write(inp.encode())
- time.sleep(2)
- getdata()
- # print("[ "+ctime()+" ] "+"exit !!\n")
- file.write("[ "+ctime()+" ] ")
- time.sleep(60);
- # exit()
- _main_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement