Coder Social home page Coder Social logo

iot-stuff's Introduction

Scalable Weather Station for ESP32

"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."

esp32 design weather station

Structure

.
├── 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

Structure Explanation

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 a report.pdf in the root directory. The next explanation is a more high-level overview of the project.

1. influx-grafana

Contains the docker-compose file to run the influxdb and grafana. Contains Configurations for InfluxDB via environment variables.

2. mqtt-broker

Contains the docker-compose file to run the mqtt-broker. It has the mosquitto configuration file also.

3. esp32-firmware

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.

4. server

Contains the server code to read the data from the topic weatherData from the mqtt-broker and store it in the database.

5. api

Contains the api code to get the data from the database and show it in the route /weather of the server.

6. docs

Contains some useful scripts to test the system:

  • publisherMQTT.sh: script to publish data to the mqtt-broker.

7. start-service

start-service.sh is a script to run every part of the project.

How to Run

Pre-requisites

  • 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

Troubleshooting Commands

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 the docs/examples directory.

Miscelaneous

Completions for ZSH

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

Useful Queries

SELECT "temperature", "humidity" FROM "weather"

How to Docker

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.

Other How to's

References

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

mosquitto docker

influxDB docs

influxDB docker

grafana docs

grafana docker

iot-stuff's People

Contributors

martimolanes avatar lawunnkhaing avatar jessesillman avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.