From f2a9562f008761274eeafd63f28396bf91b65bd0 Mon Sep 17 00:00:00 2001 From: Marcus Date: Mon, 7 Aug 2023 01:07:42 +0200 Subject: [PATCH] progress --- main.py | 20 ++++++++++++++------ main/main.ino | 14 +++++++++----- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index 31c4795..4f05d9d 100755 --- a/main.py +++ b/main.py @@ -11,13 +11,21 @@ ser = serial.Serial('/dev/ttyACM0', baudrate = 9600, timeout = 1) #time.sleep(3) - +#ser.readline() while 1: - # { "command": "switch", "arg": "one", "state": "off", "ver":"1690931931"} - userInput = input('> ') - ser.write(str(userInput).encode('ascii')) - arduinoData = ser.readline().decode('ascii') - print(arduinoData) +# ser.readline() + Data = ser.readline().decode('ascii') + print(Data) + outFile = open("arduino-fridge-powercontrol.json", "a") + outFile.write(Data) + outFile.close + +##while 1: +## # { "command": "switch", "arg": "one", "state": "off", "ver":"1690931931"} +## userInput = input('> ') +## ser.write(str(userInput).encode('ascii')) +## arduinoData = ser.readline().decode('ascii') +## print(arduinoData) ##def getValues(): diff --git a/main/main.ino b/main/main.ino index 7a889be..c0d70d5 100644 --- a/main/main.ino +++ b/main/main.ino @@ -58,8 +58,11 @@ void setup() { Serial.begin(9600); sensors.begin(); + + // little welcome + //Serial.println(".:: arduino-fridge-powercontrol by DeltaLima, 2023 ::."); // locate devices on the bus - Serial.println("Locating devices..."); + /*Serial.println("Locating devices..."); Serial.print("Found "); deviceCount = sensors.getDeviceCount(); Serial.print(deviceCount, DEC); @@ -87,6 +90,7 @@ void setup() { Serial.print("°C, stop temp: "); Serial.print(LTemp2); Serial.println("°C"); + */ } void loop() { @@ -138,12 +142,12 @@ void loop() { StaticJsonDocument<96> jsonOut; //jsonOut["sensor"] = "1"; - jsonOut["sensor1"]["temp"] = tempSensor1; - jsonOut["sensor1"]["state"] = fetState1; + jsonOut[0]["temp"] = tempSensor1; + jsonOut[0]["state"] = fetState1; //jsonOut["sensor"] = "2"; - jsonOut["sensor2"]["temp"] = tempSensor2; - jsonOut["sensor2"]["state"] = fetState2; + jsonOut[1]["temp"] = tempSensor2; + jsonOut[1]["state"] = fetState2; serializeJson(jsonOut, Serial); Serial.println(); /*