Skip to content

Latest commit

 

History

History
229 lines (185 loc) · 6.55 KB

README.md

File metadata and controls

229 lines (185 loc) · 6.55 KB

MIT License LinkedIn


Logo

Temperature Monitor

An indoor temperature and humidity monitoring project.


View App · Demo Video · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. License
  5. Contact
  6. Acknowledgements

About The Project

Product Name Screen Shot This is a hobby project in which sensor data is being published to a heroku database and can be visualized using a dash web app. This project can be repurposed to visualize any type of numeric data from sensors.

Built With

Getting Started

Prerequisites

To get started with this project you will need:

  1. Arduino UNO
  2. DHT11 Sensor

Install

  1. Install python requirements
pip3 install -r requirements.txt
  1. Install Heroku

Schematic

Build the circuit according to the schematic. Image

Arduino

After completing the hardware part upload temperature_monitor.ino to the arduino.

App

First we need to create a heroku app. Ensure you have installed heroku by running heroku -v. To create an app follow these steps:

  1. Login to heroku.
heroku login
  1. Create a heroku app.
heroku create app-name
  1. Once the app is created, we have to add the Heroku Postgresql add-on.
heroku addons:create heroku-postgresql:hobby-dev
  1. After adding the add-on, we have to create a table on the app database.
heroku pg:psql -a app-name
CREATE TABLE dht_data (
  reading_id serial not null,
  created_on timestamptz not null,
  temperature numeric(4,2) not null,
  humidity numeric(4,2) not null
);

This wil create a table named 'dht_data' with columns created_on, logged_on, temperature and humidity. We can now push data to our database from our temperature logger script.

Logger

To setup the logger to push data to our database, create a file database.ini in the logger folder and fill it with with the database details. Template for database.ini file -

[postgresql]
dbname=
host=
port=
user=
password=
sslmode=require

You can get the details by running

heroku pg:credentials:url -a app-name.

Once your are done with this you can adjust the timezone, time between readings and arduino port number in the temperature_logger.py file. You can get your time zone name from here. Example -

TIMEZONE = "Asia/Calcutta"
TIME_BETWEEN_READINGS = timedelta(minutes=1)
DEVICE_PATH = '/dev/ttyACM0'

If you want other durations you can use this

timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)

Usage

Logging

To log sensor data:

  1. Check the DEVICE_PATH is set correcly in temperature_logger.py
  2. Run python3 temperature_logger.py (Be sure to run it from the /logger folder)

Deploying

We are only deploying the App folder of the project on Heorku. To do this, we make use of the subtree command in git. Run this to push the App to heroku

git subtree --prefix App push heroku main

Once the app is deployed, it will print a url like http://temperature-monitor.herokuapp.com which you can visit to view the app.

Running Locally

Running locally is required to test changes before deploying the app. Here is how to do it.

  1. cd to App folder and copy Heroku config vars to local .env file.
heroku config:get DATABASE_URL -s  >> .env
  1. Run the app.
heroku local

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Ammaar Solkar - asketch8@gmail.com

Project Link: https://github.com/ammaar8/temperature-monitor

Acknowledgements