This commit is contained in:
Marcus 2023-08-07 01:07:42 +02:00
parent 02583b9497
commit f2a9562f00
2 changed files with 23 additions and 11 deletions

20
main.py
View file

@ -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():

View file

@ -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();
/*