This is a simple IOT project using Raspberry pi (https://www.raspberrypi.com/products/raspberry-pi-3-model-b/)and DHT22 sensor(https://www.instructables.com/How-to-use-DHT-22-sensor-Arduino-Tutorial/).The data recieved is then publishes in the form of a table and bar graph using [Python Flask] (http://flask.pocoo.org/) and PostgreSQL.
- Raspberry Pi with Raspbian OS
- DHT22 Sensor
- Python 3.7+
- PostgreSQL
- Connect the DHT22 sensor to the Raspberry Pi:
- VCC to 3.3V
- GND to GND
- Data to GPIO pin (e.g., GPIO17)
- Clone the repository
git clone https://github.com/yourusername/raspberry-pi-dht22.git
- Navigate to the project directory
cd raspberry-pi-dht22 - Set up a Python virtual environment and activate it
python3 -m venv venv source venv/bin/activate - Install Python dependencies
pip install -r requirements.txt
- Set up the PostgreSQL database
sudo -u postgres psql CREATE DATABASE iot; CREATE USER pi WITH PASSWORD 'password'; GRANT ALL PRIVILEGES ON DATABASE iot TO pi; \q
- Update the database configuration in
config.pySQLALCHEMY_DATABASE_URI = 'postgresql://pi:password@localhost/sensor_data'
- Run the data collection script to read data from the DHT22 sensor and store it in PostgreSQL
python data_collector.py
- Run the Flask web application to display the data
python app.py
- Open a web browser and navigate to
http://<your-raspberry-pi-ip>:5000to view the data.
- Collects temperature and humidity data using a DHT22 sensor.
- Stores the data in a PostgreSQL database.
- Displays the data in a table and bar graph using a Flask web application.