filename into var

This commit is contained in:
Marcus 2023-08-08 20:43:50 +02:00
parent 472d14b048
commit cfd6b2e289
2 changed files with 4 additions and 3 deletions

View File

@ -1 +1 @@
{"1":{"temp":20.625,"state":true},"2":{"temp":20.875,"state":true}}
{"1":{"temp":10.375,"state":false},"2":{"temp":-127,"state":false}}

View File

@ -1,5 +1,6 @@
#!/bin/python3
# script to write json received by serial into a file
# bookmarks
#
# threading: https://stackoverflow.com/questions/9848464/how-to-listen-to-http-requests-and-a-serial-channel-in-the-same-python-program
@ -8,7 +9,7 @@ import serial
import time
ser = serial.Serial('/dev/ttyACM0', baudrate = 9600, timeout = 6)
outfile = "arduino-fridge-powercontrol.json"
#time.sleep(3)
#ser.readline()
@ -16,7 +17,7 @@ while 1:
# ser.readline()
Data = ser.readline().decode('ascii')
print(Data)
outFile = open("arduino-fridge-powercontrol.json", "w")
outFile = open(outfile, "w")
outFile.write(Data)
outFile.close