Skip to content

parinazmoeini/iot-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IoT Project

This project shows how I connected an ESP32 with MQTT, saved the data in InfluxDB, and used Flask to make a small web page for control and charts.

Authors: Majid Hosseinia & Parinaz Moeini

Features

  • ESP32 firmware (WiFi + MQTT via PubSubClient)
  • Python backend (Flask) with InfluxDB 2.x client and MQTT publisher/subscriber
  • Simple HTML template for front-end controls
  • Data analysis helpers (Pandas/Numpy)
  • Ready-to-fork repo with MIT license, .gitignore, requirements.txt, and .env.example

Repository structure

. ├── codes/ │ ├── analyse.py # script for analyzing sensor data │ ├── conection.py # Flask + MQTT + InfluxDB backend │ └── templates/ │ └── index.html # web UI template ├── sketch_feb10a.ino # Arduino sketch for ESP32 ├── requirements.txt # Python dependencies ├── .env.example # example env vars (no secrets) ├── LICENSE # MIT license ├── CONTRIBUTING.md # contribution guidelines └── README.md # main documentation

Requirements

Python 3.10+, InfluxDB 2.x, MQTT broker (like Mosquitto), Arduino IDE with ESP32.

Quickstart (local)

  1. Clone & create environment

    git clone <your-fork-url>.git iot-project
    cd iot-project
    python -m venv .venv
    source .\.venv\Scripts\Activate.bat
    pip install -r requirements.txt
    cp .env.example .env
  2. Configure environment

    • Edit .env with your InfluxDB URL, token, org, and bucket.
    • Set your MQTT broker host/port/topic.
  3. Run the Flask app

    export FLASK_APP=codes/conection.py  # Windows: set FLASK_APP=codes/conection.py
    python codes/conection.py

    The app runs on http://localhost:5000 by default.

  4. InfluxDB setup

    • Create an organization and bucket named in your .env (or change .env).
    • Generate a read/write API token.
  5. ESP32 firmware

    • Open sketch_feb10a.ino in Arduino IDE.
    • Install libraries: WiFi, PubSubClient.
    • Update WiFi SSID/password and MQTT broker settings in the sketch.
    • Upload to your ESP32.
  6. (Optional) Analysis

    • Use codes/analyse.py as a starting point to query data from InfluxDB using Flux and analyze with Pandas/Numpy.

IMPORTANT

Don’t put real tokens in your code. I use a .env file for more safety.

How to publish on GitHub

  1. Initialize git and make the first commit

    git init
    git add .
    git commit -m "feat: initial public repo (Flask + ESP32 + InfluxDB)"
  2. Create a new GitHub repository (on github.com) named, for example, iot-project.

  3. Add the remote and push

    git branch -M main
    git remote add origin https://github.com/<your-username>/iot-project.git
    git push -u origin main

License

This project is licensed under the MIT License.
© 2025 Majid Hosseinia & Parinaz Moeini

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published