Giter Site home page Giter Site logo

kaulketh / greenhouse Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 0.0 55.88 MB

Control a greenhouse by using Telegram app (Bot API) and a RaspberryPi.

Home Page: https://kaulketh.github.io/greenhouse/

License: The Unlicense

Python 91.41% Shell 8.59%
python shell linux raspberry-pi plants greenhouse electric telegram telegram-bot

greenhouse's Introduction

My Greenhouse

Control a greenhouse by using Telegram app and a Raspberry Pi. I did not reinvent the wheel.

Thank you for inspiring me, Stefan Weigert and Felix Stern


release size commit platform languages coverage license

This repository is used to gather and show information and experiences during the building of a smart control possibility. All code is written or adapted by myself and w/o any copyrights. I have tried to use no copyright protected stuff. Almost everything published already exists, to be found on the net, and was adapted and used only by me accordingly.

And please excuse the mistakes made and violations of any conventions, I am new to this matter. Do not be afraid to correct or improve me and inform me accordingly. Consider and refer Contributor Covenant Code of Conduct!

Table of Contents


Installation and usage

Currently no installation routine is planned. Feel free to use, adapt, download or copy all the published stuff. Main programming language is Python and shell scripting is used also.

Telegram app

Install the app and create bot
Name: 	ThK1220RealGreenhouse
TOKEN: 	<api_token>
ChatID:	<chat_id>

Raspberry Pi OS image

  • download latest stretch lite w/o desktop
  • prepare sd card / flash image, e.g. use Etcher
  • enable SSH access
    • As of the November 2016 release, Raspbian has the SSH server disabled by default. You will have to enable it manually.
    • For headless setup, SSH can be enabled by placing a file named "ssh", without any extension, onto the boot partition of the SD card.

Boot raspi and connect via ssh


Configure (static) IP

adapt /etc/dhcpcd.conf
sudo service dhcpcd status 
sudo service dhcpcd start // if not yet started 
sudo systemctl enable dhcpcd 
sudo nano /etc/dhcpcd.conf
sudo reboot

Retest and doublecheck network conection and settings before executing next steps!!!!!


Make updates and adapt main config

sudo apt-get update --yes && sudo apt-get upgrade --yes
sudo raspi-config
    Hostname:	greenhouse
    User:		pi
    Password:	******************
sudo rpi-update //update firmware
sudo reboot

Install and configure dyn dns client (ddclient)

ignore config let it empty e.g can be configured due next steps

sudo apt-get update
sudo apt-get install libio-socket-ssl-perl
sudo apt-get install ddclient

use e.g. FreeDNS and update ddclient.conf accordingly the dns provider


sudo nano /etc/ddclient.conf

other possible method could be e.g insert crontabs
0,5,10,15,20,25,30,35,40,45,50,55 * * * * sleep 31 ; wget -O - http://freedns.afraid.org/dynamic/update.php?******************************************** >> /tmp/freedns_greenhouse_my_to.log 2>&1 &
3,8,13,18,23,28,33,38,43,48,53,58 * * * * sleep 44 ; wget -O - http://freedns.afraid.org/dynamic/update.php?******************************************** >> /tmp/freedns_greenhouse_chickenkiller_com.log 2>&1 &

Install and configure remote ftp if required

sudo apt-get install pure-ftpd
sudo groupadd ftpgroup
sudo useradd ftpuser -g ftpgroup -s /sbin/nologin -d /dev/null
sudo mkdir /home/pi/FTP
sudo chown -R ftpuser:ftpgroup /home/pi/FTP
sudo pure-pw useradd upload -u ftpuser -g ftpgroup -d /home/pi/FTP -m
sudo pure-pw mkdb
sudo ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/60puredb 
sudo service pure-ftpd restart

Configure the live stream

install motion and update /etc/motion/motion.conf
sudo apt-get install motion -y
sudo nano /etc/motion/motion.conf   //additional: output_pictures off
sudo nano /etc/default/motion
mkdir /home/pi/Monitor
sudo chgrp motion /home/pi/Monitor
chmod g+rwx /home/pi/Monitor
sudo service motion start

Configure port forwarding in router accordingly the dns and port settings


Install required packages (python, python-telegram-bot, python-pip, telepot and wiringpi)

sudo apt-get install build-essential python-dev python-pip python-smbus python-openssl git --yes //python
sudo pip install python-telegram-bot
sudo pip install telepot
First check that wiringPi is not already installed.
gpio -v
If you get something, then you have it already installed. The next step is to work out if it’s installed via a standard package or from source. If you installed it from source, then you know what you’re doing – carry on – but if it’s installed as a package, you will need to remove the package first. To do this:
sudo apt-get purge wiringpi
hash -r
WiringPi is maintained under GIT for ease of change tracking. If required to install do it like described as followed.
sudo apt-get install git-core
sudo apt-get update
sudo apt-get upgrade
cd git
git clone git://git.drogon.net/wiringPi
cd ~/wiringPi
git pull origin
cd ~/wiringPi
./build

Add scripts in pi user directory

e.g in this case in scripts/TelegramBot

Make them executable and chown root:root!


Enable autostart of the bot application

Add the program as service. To enable autostart add it to the init.d directory, insert telegrambot.sh in /etc/init.d as root and execute commands as followed.
sudo chmod +x telegrambot.sh
sudo update-rc.d telegrambot.sh defaults
sudo reboot

Additional functionality

Add as required or wished
Crontabs examples
# update check every 10 minutes
0,10,20,30,40,50 * * * * bash /home/pi/scripts/TelegramBot/update_bot.sh <access token repository> <chat id> <api token>
	
# update check every hour
0 * * * * bash /home/pi/scripts/TelegramBot/update_bot.sh <access token repository> <chat id> <api token>

# backup bot every day at 1:30AM
30 1 * * * tar -zcf /home/pi/backups/greenhouse.tgz --exclude='*.pyc' /home/pi/scripts/TelegramBot/

# also move log backups to backup folder
31 1 * * * mv -v /*.gz /home/pi/backups/
Logrotate to compress and clear log files
sudo nano /etc/logrotate.conf
/update_bot.log {
	missingok
	daily
	rotate 1
	compress
	dateext
	create 644 root root
}

/greenhouse.log {
	missingok
	daily
	rotate 1
	compress
	dateext
	create 644 root root
}

License

license

greenhouse's People

Contributors

kaulketh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

greenhouse's Issues

Add and implement the measurement of temperature and humidity

git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo python setup.py install

[error handling] improvement

improve error handling to ensure closed valves if errors occur, like no connection and so on. maybe combine with automated restart

Multiple choice for channel selection

I as user wants the possibility of select more then one channel AND the further selected watering time will be used for the selected channels AND they will watered at the same time AND I am not restricted to select one of the displayed buttons only

Cards

Cards can be added to your board to track the progress of issues and pull requests. You can also add note cards, like this one!

Update error due Grouping is called and standby is triggered

Describe the bug
If grouping is called and any channels are selected and the standby timer is triggered and job to standby is called, an update error occurs

To Reproduce
Steps to reproduce the behavior:

  1. call 'grouping'
  2. select any channels
  3. wait until standby is initialized
  4. error occurs

Expected behavior
If grouping is called and any channels are selected and the standby timer is triggered and job to standby is called, bot should be properly set to standby

Standby timer

I as user wants after an activation of at least one channel, that the standby mode will activated automatically after a given time so its not required to do that manually when the bot notifies about a finished watering

open tasks of #11

I as user wants that accordingly all last changes following documents updated

  • README.md
  • HARDWARE.md

so I am always informed about all functionality and changes

Time units

make time units adjustable, as var in lib with given conversion factor and real name
e.g seconds = s => x1, minutes = min => x60

Welcome to GitHub Projects

We're so excited that you've decided to create a new project! Now that you're here, let's make sure you know how to get the most out of GitHub Projects.

  • Create a new project
  • Give your project a name
  • Press the ? key to see available keyboard shortcuts
  • Add a new column
  • Drag and drop this card to the new column
  • Search for and add issues or PRs to your project
  • Manage automation on columns
  • Archive a card or archive all cards in a column

Implement extern state LEDs in housing

  • Suggestion:

    1. heartbeat -> Pi is alive ;-) -> pink?
    2. mmc -> access to sd card -> orange
    3. cpu -> activity -> yellow
    4. gpio -> power on -> green
    5. input -> power supply low -> red
  • research

  • adapt hardware, drill holes in housing and build in LEDs

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.