Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import random
|
3 |
+
|
4 |
+
# Simulated Gas Sensor Data (You can replace this with real sensor integration)
|
5 |
+
def get_gas_data():
|
6 |
+
gas_data = {
|
7 |
+
"CO2 (Carbon Dioxide)": random.uniform(300, 500), # in ppm
|
8 |
+
"O2 (Oxygen)": random.uniform(19, 21), # in %
|
9 |
+
"N2 (Nitrogen)": random.uniform(78, 80), # in %
|
10 |
+
"CFC (Chlorofluorocarbons)": random.uniform(0, 0.5), # in ppm
|
11 |
+
"CO (Carbon Monoxide)": random.uniform(0, 10), # in ppm
|
12 |
+
"SO2 (Sulfur Dioxide)": random.uniform(0, 5), # in ppm
|
13 |
+
"NO (Nitric Oxide)": random.uniform(0, 5), # in ppm
|
14 |
+
}
|
15 |
+
return gas_data
|
16 |
+
|
17 |
+
# Streamlit App Layout
|
18 |
+
st.title("Gas Mixture Sensor")
|
19 |
+
st.write("This app simulates a sensor that detects the mixture of gases in the surrounding air.")
|
20 |
+
|
21 |
+
st.header("Detected Gas Levels")
|
22 |
+
gas_data = get_gas_data()
|
23 |
+
for gas, value in gas_data.items():
|
24 |
+
if gas in ["O2 (Oxygen)", "N2 (Nitrogen)"]:
|
25 |
+
unit = "%"
|
26 |
+
else:
|
27 |
+
unit = "ppm"
|
28 |
+
st.metric(label=gas, value=f"{value:.2f} {unit}")
|
29 |
+
|
30 |
+
st.sidebar.header("Settings")
|
31 |
+
st.sidebar.write("Adjust the simulation parameters below.")
|
32 |
+
refresh_rate = st.sidebar.slider("Refresh Rate (seconds)", 1, 10, 5)
|
33 |
+
|
34 |
+
st.sidebar.write("Note: Values are simulated and change on every refresh.")
|
35 |
+
st.sidebar.caption("This app is for demonstration purposes only.")
|
36 |
+
|
37 |
+
# Auto-refresh the app based on the slider value
|
38 |
+
st.experimental_set_query_params(refresh_rate=refresh_rate)
|
39 |
+
st.stop() # Prevents an infinite loop of refresh
|