"An all-in-one ESP32 weather station monorepo, featuring a GO API, MQTT Broker, InfluxDB-Grafana for data visualization, server-side JavaScript, all orchestrated with a single start-up script."

.
├── api
│ ├── Dockerfile
│ ├── go.mod
│ └── main.go
├── docs
│ └── examples
│ └── publisherMQTT.sh
├── esp32-firmware
│ └── weather_station_authentication
│ └── weather_station_authentication.ino
├── influx-grafana
│ └── influx-grafana.yml
├── mqtt-broker
│ ├── mosquitto.conf
│ └── mqtt-broker.yml
├── server
│ ├── package.json
│ └── server.js
└── start-service.sh
If you want a more smooth-grained explanation, you can compile the technical documentation with the command
./start-service.sh build-docs
.It will generate areport.pdf
in the root directory. The next explanation is a more high-level overview of the project.
Contains the docker-compose file to run the influxdb and grafana. Contains Configurations for InfluxDB via environment variables.
Contains the docker-compose file to run the mqtt-broker. It has the mosquitto configuration file also.
Contains the .ino file to be uploaded to the esp32. The firmware is responsible to read the data from the sensors and publish it to the mqtt-broker.
Contains the server code to read the data from the topic weatherData
from the
mqtt-broker and store it in the database.
Contains the api code to get the data from the database and show it in the route
/weather
of the server.
Contains some useful scripts to test the system:
publisherMQTT.sh
: script to publish data to the mqtt-broker.
start-service.sh
is a script to run every part of the project.
- Docker and Docker-compose
- Platform to run the esp32 firmware
Then, we are using a shell script (start-service.sh
) to run every part of the
project.
We have this project structured by parts, so we can run every part separately
(so, we can run it in different machines).
# run the help and see the options
./start-service.sh -h
Note: the script uses docker-compose to run the containers. So, if you cannot execute docker without sudo, you need to add your user to the docker group.
sudo usermod -aG docker $USER
There is some useful scripts to help you in the direcotry docs/examples
.
# send data to the broker to test the topic
mosquitto_pub -h localhost -t weatherData -m '{"temperature": 22, "humidity": 50}'
# subscribe to the some topic of the broker
mosquitto_sub -h localhost -t weatherData
Note: For mocking the esp32, we are using the
publisherMQTT.sh
script in thedocs/examples
directory.
If you are using zsh, you can use the _start-service
file to have
the completions for the start-service.sh
script.
cp _start-service ~/.zfunc/
source ~/.zshrc
SELECT "temperature", "humidity" FROM "weather"
This is a simple guide to help you with docker commands in the project. How to Docker
There is no need to know docker to run the project. All is automated with the
start-service.sh
script.
Structure generated with command
tree -I node_modules -I package-lock.json -I go.sum -I README.md -I LICENSE -I _start-service -I TODO.md