Spaces:
Sleeping
Sleeping
fix topics
Browse files
app.py
CHANGED
|
@@ -9,6 +9,8 @@ import streamlit as st
|
|
| 9 |
st.title("RGB Command and Sensor Data Panel")
|
| 10 |
|
| 11 |
# MQTT Configuration
|
|
|
|
|
|
|
| 12 |
HIVEMQ_HOST = st.text_input(
|
| 13 |
"Enter your HiveMQ host:",
|
| 14 |
"248cc294c37642359297f75b7b023374.s2.eu.hivemq.cloud",
|
|
@@ -23,7 +25,10 @@ PORT = st.number_input(
|
|
| 23 |
)
|
| 24 |
|
| 25 |
# User input for the Pico ID
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
max_power = 0.35
|
| 29 |
max_value = round(max_power * 255)
|
|
@@ -84,12 +89,9 @@ def send_and_receive(client, command_topic, msg, queue_timeout=60):
|
|
| 84 |
|
| 85 |
# Publish button
|
| 86 |
if st.button("Send RGB Command"):
|
| 87 |
-
if not
|
| 88 |
st.error("Please enter all required fields.")
|
| 89 |
else:
|
| 90 |
-
command_topic = f"{pico_id}/neopixel"
|
| 91 |
-
sensor_data_topic = f"{pico_id}/as7341"
|
| 92 |
-
|
| 93 |
client = get_paho_client(
|
| 94 |
sensor_data_topic,
|
| 95 |
HIVEMQ_HOST,
|
|
|
|
| 9 |
st.title("RGB Command and Sensor Data Panel")
|
| 10 |
|
| 11 |
# MQTT Configuration
|
| 12 |
+
|
| 13 |
+
|
| 14 |
HIVEMQ_HOST = st.text_input(
|
| 15 |
"Enter your HiveMQ host:",
|
| 16 |
"248cc294c37642359297f75b7b023374.s2.eu.hivemq.cloud",
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
# User input for the Pico ID
|
| 28 |
+
PICO_ID = st.text_input("Enter your Pico ID:", "test", type="password")
|
| 29 |
+
|
| 30 |
+
command_topic = f"sdl-demo/picow/{PICO_ID}/GPIO/28/"
|
| 31 |
+
sensor_data_topic = f"sdl-demo/picow/{PICO_ID}/as7341/"
|
| 32 |
|
| 33 |
max_power = 0.35
|
| 34 |
max_value = round(max_power * 255)
|
|
|
|
| 89 |
|
| 90 |
# Publish button
|
| 91 |
if st.button("Send RGB Command"):
|
| 92 |
+
if not PICO_ID or not HIVEMQ_HOST or not HIVEMQ_USERNAME or not HIVEMQ_PASSWORD:
|
| 93 |
st.error("Please enter all required fields.")
|
| 94 |
else:
|
|
|
|
|
|
|
|
|
|
| 95 |
client = get_paho_client(
|
| 96 |
sensor_data_topic,
|
| 97 |
HIVEMQ_HOST,
|