Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

tritdm/ce232-mini-project-easy-iot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easy IoT application with ESP32-Espressif

This is my Wireless Embedded System Design Mini Project (CE232 in UIT).

Design an IoT system have the below requirements

Model of project

alt

ESP32 nodes task

  • Collect temperature and humidity data from sensor.
  • Show data on LCD.
  • Send data to MQTT Broker every 10 seconds.

Server task

  • Receive data from MQTT Broker.
  • Save data to SQLite.
  • Access from LAN.

End users (or web) task

  • Show data in graph mode and web auto update without refresh.

How to operate this project

Activate or set up a virtual environment and install neccessary packet

  • If you want to have an own virtual environment
$ python3 -m venv venv
$ source venv/bin/activate
$ python3 -m pip install -r requirements.txt
  • Or you can use my virtual environment
$ source tutorial-env/bin/activate

Flash code to ESP32 and keep it powered up

Deploy Flask app

  • Go to app folder
$ cd app
  • Initialize database or you can change to fit your need in sql file before initialize.
$ python init_db.py
  • Run Flask app
$ python app.py

Flask

localhost

LAN

  • If you want your Flask app can access over Internet, you can use ngrok.
  • You can go to the ngrok home or Miguel Grinberg's blog guide for more information.
  • By the way opening a parallel terminal and activate your virtual environment and run ngrok corresponding Flask app port.
$ source tutorial-env/bin/activate
$ ngrok http 5000
  • You can use the Forwarding address to access from any network.

ngrok terminal

  • You need to accept to visit the site

ngrok accept

  • The result

ngrok