Skip to content

Commit 985075e

Browse files
committed
Add docker container support. Update readme.
1 parent cce11ab commit 985075e

File tree

4 files changed

+56
-5
lines changed

4 files changed

+56
-5
lines changed

Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# app/Dockerfile
2+
3+
FROM python:3.9-slim
4+
5+
WORKDIR /app
6+
7+
RUN apt-get update && apt-get install -y \
8+
build-essential \
9+
curl \
10+
software-properties-common \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
COPY ./.streamlit/ .streamlit/
14+
COPY ./requirements.txt requirements.txt
15+
COPY ./sb_client.py sb_client.py
16+
17+
RUN pip3 install -r requirements.txt
18+
19+
EXPOSE 8501
20+
21+
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
22+
23+
ENTRYPOINT ["streamlit", "run", "sb_client.py", "--server.port=8501", "--server.address=0.0.0.0"]

README.md

+27-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
11
# ESP32 Spectrum Analyzer using FFT
22

3-
## Componentns
3+
## Components
44

5-
**Beckend database**: Supabase
6-
**WebApp**: Streamlit
7-
**Wifi-based communication between ESP32 and PC**: Websocket client-server with simple json/text messages
5+
- **Beckend database**: Supabase
6+
- **WebApp**: Streamlit
7+
- **Wifi-based communication between ESP32 and PC**: Websocket client-server with simple json/text messages
8+
9+
## How to run
10+
11+
First, you need to prepare the hardware setup according to the scheme and upload the code to ESP32. Then, you need to run the Streamlit app and connect to the ESP32. The app will automatically connect to the Supabase database and start receiving data from ESP32. The app will also start the FFT analysis and display the results.
12+
13+
### Step-by-step guide
14+
15+
Upload the code to ESP32 using Arduino, or any other method you prefer. Pay attention on the problems with the `analogRead` function described in the documentation. Use the sketch in sketch_sample_rate do identify your sample rate and the maximum frequency you can sample.
16+
17+
Edit the .secrets.toml and secrets.h files in .streamlit and sketch_fft files respectively. You need to fill the Supabase API data and wifi adress + password.
18+
19+
Create a docker image of the Streamlit app using the `Dockerfile`:
20+
21+
```bash
22+
# Build the docker image using the Dockerfile
23+
docker build -t streamlit .
24+
# Run the docker container using the image
25+
docker run -p 8501:8501 streamlit
26+
```
27+
28+
After that you can use the IP address of the app, which is displayed in the terminal of the container, to connect to the app using your browser.
29+
30+
Then you can use the GUI to connect to the ESP32 and start the FFT analysis. It is also possible to connect to the Supabase database and display the data from the ESP32.

requirements.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
streamlit
2+
websocket-client
3+
plotly-express
4+
supabase
5+
pandas

sketch_fft/sketch_fft.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define AMPLITUDE 1000 // Depending on your audio source level, you may need to alter this value. Can be used as a 'sensitivity' control.
1414
#define AUDIO_IN_PIN 35 // Signal in on this pin
1515
#define NUM_BANDS 8 // Number of frequency bands to use
16-
#define NOISE 600 // Used as a crude noise filter, values below this are ignored
16+
#define NOISE 1000 // Used as a crude noise filter, values below this are ignored
1717

1818
unsigned int sampling_period_us;
1919
int bandValues[] = {0,0,0,0,0,0,0,0};

0 commit comments

Comments
 (0)