Git Product home page Git Product logo

rossdrew / greenhouse-telemetry Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 1.0 645 KB

Greenhouse telemetry. Monitoring the greenhouse and the weather with a view towards automation

Home Page: https://dev.to/rossdrew/technology-choices-in-monitoring-a-greenhouse-2ppf

Python 100.00%
telemetry influxdb automation greenhouse-monitoring grafana adafruit-drivers greenhouse-telemetry python weather am2302

greenhouse-telemetry's Introduction

Greenhouse Telemetry

Some code experimenting with greenhouse telemetry and featured in my Greenhouse blog series

Grafana Screenshot Sample

Controller

  • Rasberry Pi 3 Model B v1.2
  • Programmed in Python (may change later)

Progress

Using Trello to keep track of work

Temp/Humidity

We are using the AM2302 wired as follows

VCC -> Pi Pin 1
GND -> Pi Pin 6
DATA -> Pi Pin 7

and the Adafruit Python Drivers which can be set up as follows

(1) Clone the drivers repo

git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT

(2) Make sure python is up to date

sudo apt-get upgrade
sudo apt-get install build-essential python-dev

(3) Install the Adafruit drivers

sudo python setup.py install

(4) Run the test to make sure it worked

cd examples
sudo ./AdafruitDHT.py 2302 4

Local Temp/Humidity

Local weather data is retrieved from OpenWeatherMap API and recorded to DB for each reading for comparison.

Recording

Data is recorded to a local InfluxDB

Sample Weather JSON Data

{
	"coord": {
		"lon": -0,
		"lat": 0
	},
	"weather": [
		{
			"id": 500,
			"main": "Rain",
			"description": "light rain",
			"icon": "10d"
		}
	],
	"base": "stations",
	"main": {
		"temp": 10.49,
		"pressure": 1014,
		"humidity": 66,
		"temp_min": 8,
		"temp_max": 12.22
	},
	"visibility": 10000,
	"wind": {
		"speed": 3.1,
		"deg": 240
	},
	"clouds": {
		"all": 75
	},
	"dt": 1559121266,
	"sys": {
		"type": 1,
		"id": 1442,
		"message": 0.0063,
		"country": "GB",
		"sunrise": 1559101162,
		"sunset": 1559162573
	},
	"timezone": 3600,
	"id": 1,
	"name": "Location",
	"cod": 1
}

Setup

Install InfluxDB:
curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
lsb_release -a

And with the Linux release codename

sudo apt install apt-transport-https
echo "deb https://repos.influxdata.com/debian <CODENAME> stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt update
sudo apt-get install influxdb
Start InfluxDD
sudo service influxdb start

or automatically run on startup

sudo systemctl enable influxdb
Install Grafana
wget https://dl.grafana.com/oss/release/grafana_6.6.0_armhf.deb
sudo dpkg -i grafana_6.6.0_armhf.deb
Start Grafana
sudo systemctl start grafana-server

or automatically run on startup

sudo systemctl enable grafana-server

Should be running on :3000

Setup a Python environment
python3 -m venv .venv
.venv/bin/pip3 install -r requirements.txt

Developing / Debugging

Install sshfs, link development machine to Pi by mounting the source directory and open in development environment

dnf install sshfs
mkdir /mnt/pi/gh
sshfs pi@<PI_IP>:/mnt/pi/gh /home/src/pi/gh

Running

Setup config

You will need to fill config.properties with

[Deploy]
name = "my deployment name"

[AM2302]
pin = <pin thhat AM2302 is attached to>

[Weather]
location = <location for querying>
open_weather_map_app_id = <your personal app.id>

Setup Database

Delete and recreate a new InfluxDb database

python init_db.py

Running Telemetry

Run the peripheral read loop

python read_cycle.py

which will start to fill up a specified InfluxDB

Running in a test environment (not on a Raspberry Pi with a AM2302 sensor) will require swapping out the used of TestClimateDataSource for the AM2302DataSource. I'm yet to figure out a nice way to automate this.

Experimental Control

There's a simple control cycle in place in run_greenhouse.py. This will turn a light on during daylight hours and keep track of soil moisture. It also has the ability to turn on water which hasn't been included in the cycle quite yet.

Plans

  • Add power generation and usage monitoring
  • Add light sensors, window state/control and perhaps automated watering
  • Add camera

greenhouse-telemetry's People

Contributors

rossdrew avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ozguryilmaz07

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.