progress
This commit is contained in:
parent
02583b9497
commit
f2a9562f00
2 changed files with 23 additions and 11 deletions
20
main.py
20
main.py
|
@ -11,13 +11,21 @@ ser = serial.Serial('/dev/ttyACM0', baudrate = 9600, timeout = 1)
|
||||||
|
|
||||||
#time.sleep(3)
|
#time.sleep(3)
|
||||||
|
|
||||||
|
#ser.readline()
|
||||||
while 1:
|
while 1:
|
||||||
# { "command": "switch", "arg": "one", "state": "off", "ver":"1690931931"}
|
# ser.readline()
|
||||||
userInput = input('> ')
|
Data = ser.readline().decode('ascii')
|
||||||
ser.write(str(userInput).encode('ascii'))
|
print(Data)
|
||||||
arduinoData = ser.readline().decode('ascii')
|
outFile = open("arduino-fridge-powercontrol.json", "a")
|
||||||
print(arduinoData)
|
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():
|
##def getValues():
|
||||||
|
|
|
@ -58,8 +58,11 @@ void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
sensors.begin();
|
sensors.begin();
|
||||||
|
|
||||||
|
|
||||||
|
// little welcome
|
||||||
|
//Serial.println(".:: arduino-fridge-powercontrol by DeltaLima, 2023 ::.");
|
||||||
// locate devices on the bus
|
// locate devices on the bus
|
||||||
Serial.println("Locating devices...");
|
/*Serial.println("Locating devices...");
|
||||||
Serial.print("Found ");
|
Serial.print("Found ");
|
||||||
deviceCount = sensors.getDeviceCount();
|
deviceCount = sensors.getDeviceCount();
|
||||||
Serial.print(deviceCount, DEC);
|
Serial.print(deviceCount, DEC);
|
||||||
|
@ -87,6 +90,7 @@ void setup() {
|
||||||
Serial.print("°C, stop temp: ");
|
Serial.print("°C, stop temp: ");
|
||||||
Serial.print(LTemp2);
|
Serial.print(LTemp2);
|
||||||
Serial.println("°C");
|
Serial.println("°C");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
@ -138,12 +142,12 @@ void loop() {
|
||||||
|
|
||||||
StaticJsonDocument<96> jsonOut;
|
StaticJsonDocument<96> jsonOut;
|
||||||
//jsonOut["sensor"] = "1";
|
//jsonOut["sensor"] = "1";
|
||||||
jsonOut["sensor1"]["temp"] = tempSensor1;
|
jsonOut[0]["temp"] = tempSensor1;
|
||||||
jsonOut["sensor1"]["state"] = fetState1;
|
jsonOut[0]["state"] = fetState1;
|
||||||
|
|
||||||
//jsonOut["sensor"] = "2";
|
//jsonOut["sensor"] = "2";
|
||||||
jsonOut["sensor2"]["temp"] = tempSensor2;
|
jsonOut[1]["temp"] = tempSensor2;
|
||||||
jsonOut["sensor2"]["state"] = fetState2;
|
jsonOut[1]["state"] = fetState2;
|
||||||
serializeJson(jsonOut, Serial);
|
serializeJson(jsonOut, Serial);
|
||||||
Serial.println();
|
Serial.println();
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue