Better cook parameter estimation + Defrost mode + Removed esp-wifi debugs + Orchestrator and microwave exchange
Build, push image, and notify Watchtower / build-image (push) Successful in 3m19s
Build, push image, and notify Watchtower / notify (push) Successful in 7s

This commit is contained in:
2026-07-27 17:14:05 +02:00
parent 81de985580
commit 0f17e9dce6
9 changed files with 335 additions and 64 deletions
+1 -1
View File
@@ -16,4 +16,4 @@ def do_connect(ssid, pwd):
print('network config:', sta_if.ifconfig())
# Attempt to connect to WiFi network
# do_connect("Smartwave-1", 'Smartwave-prot-1')
do_connect("Smartwave-1", 'Smartwave-prot-1')
+19 -12
View File
@@ -55,6 +55,21 @@ def on_mqtt_message(message):
# Unsubscribe from the hello topic since we got a response
mqtt_client.unsubscribe(config.MQTT_TOPIC_HELLO)
print("[MQTT Thread] Unsubscribed from topic:", config.MQTT_TOPIC_HELLO)
# Handle cooking messages
elif message['topic'] == config.MQTT_TOPIC_COOKING and payload_data and payload_data["id_microwave"] == DEVICE_ID:
# Cooking sensors init request
if not "cook_time_seconds" in payload_data:
print("[MQTT Thread] Cooking sensors init received from the orchestrator")
obj_temp = temperature_sensor.read_object_temp()
amb_temp = temperature_sensor.read_ambient_temp()
queue_publish(config.MQTT_TOPIC_SENSOR, payloads.mqtt_sensor_data(DEVICE_ID, obj_temp, amb_temp))
# Received cooking parameters from the orchestrator
else:
print("[MQTT Thread] Cooking parameters received from the orchestrator:", payload_data)
# Here you would handle the cooking parameters, e.g., start a cooking process
# For now, we just print them
print("[MQTT Thread] Message processing complete.")
mqtt_client.set_callback(on_mqtt_message)
@@ -86,7 +101,6 @@ def mqtt_background_thread():
mqtt_client.publish(topic, payload, qos=config.MQTT_QOS)
# 2. Check for incoming messages (non-blocking poll)
# Shortened timeout to keep the queue responsive
events = poller.poll(200)
if events:
mqtt_client.wait()
@@ -145,18 +159,18 @@ def uart_background_thread():
time.sleep(5)
# --- Launch background worker ---
# _thread.start_new_thread(mqtt_background_thread, ())
# _thread.start_new_thread(uart_background_thread, ())
_thread.start_new_thread(mqtt_background_thread, ())
_thread.start_new_thread(uart_background_thread, ())
# --- MAIN APPLICATION THREAD (Core 0) ---
print("[Main] Main execution path active.")
time.sleep(2) # Give the thread a moment to initial connect
mqtt_hello_sent_timestamp = -config.MQTT_HELLO_INTERVAL
# mqtt_client.subscribe(config.MQTT_TOPIC_HELLO, qos=config.MQTT_QOS)
mqtt_client.subscribe(config.MQTT_TOPIC_HELLO, qos=config.MQTT_QOS)
# Temperature sensor setup
temperature_sensor_i2c = I2C(scl=Pin(25, Pin.IN, Pin.PULL_UP), sda=Pin(26, Pin.IN, Pin.PULL_UP), freq=100000)
temperature_sensor_i2c = I2C(0, scl=Pin(25, Pin.IN, Pin.PULL_UP), sda=Pin(26, Pin.IN, Pin.PULL_UP), freq=100000)
# Scan to verify the sensor is connected and detected
print("Scanning I2C bus...")
devices = temperature_sensor_i2c.scan()
@@ -174,13 +188,6 @@ while True:
mqtt_hello_sent_timestamp = time.time()
pass
# Sensors
print(f"[Main] Reading temperature from sensor...")
obj_temp = temperature_sensor.read_object_temp()
amb_temp = temperature_sensor.read_ambient_temp()
if obj_temp is not None and amb_temp is not None:
print(f"Object: {obj_temp:.2f}°C | Ambient: {amb_temp:.2f}°C")
# 2. Example: Send data to the Heltec board every 5 seconds
# uart_device.send("Status Check: WiFi Active")
time.sleep(1)