from matplotlib import pyplot as plt
import requests
import streamlit as st
import time as time_module
# ESP32
ip = "Enter the IP provied for your teacher"
url = "http://" + ip + "/data.json"
# Get data
d = requests.get(url)
data = d.json()
timestamp = data["timestamp"]
sht = data["SHT"]
hc = data["HCSR04"]
temperature = sht["temperature"]
humidity = sht["humidity"]
distance = hc["distance"]
# Streamlit
st.title("ESP32 Sensor Dashboard")
tabs = ["?????????", "Temperature vs ????", "??????"]
tab1, tab2, ?????? = st.tabs(tabs)
with tab1:
st.text("??????? over time")
plt.xlabel("Time")
???????????("Temperature (°C)")
plt.plot(timestamp, temperature)
st.pyplot(plt.gcf())
plt.close()
with tab2:
st.text("Temperature vs ???????")
plt.xlabel("Temperature (°C)")
plt.ylabel("???????(%)")
????.scatter(temperature, humidity)
st.pyplot(plt.gcf())
plt.close()
with tab3:
st.text("Distance over time")
??????????("Time")
plt.ylabel("Distance (cm)")
??????.plot(timestamp, distance)
st.pyplot(plt.gcf())
????????????
# Update every 2 seconds
time_module.sleep(2)
st.rerun()
No hay comentarios:
Publicar un comentario