-
Notifications
You must be signed in to change notification settings - Fork 1
Raspberry Pi
Install your favorite text editor.
sudo apt-get install vim
wget https://gist.githubusercontent.com/salekd/1ebae93b5d237daebaf2dfc101b92e19/raw/81d74c53f6ccc1db9f41433a678d4696a7663196/.vimrc
Install Python 3.
sudo apt-get install python3 python3-dev python3-pip libglib2.0-dev
Install Git and clone the plant monitor repository.
sudo apt-get install git
git clone https://github.com/salekd/plant_monitor_rpi.git
Xiaomi Mi plant sensor is used to take measurements.
http://www.huahuacaocao.com/product
Get the Python package for reading the sensor data and install.
git clone https://github.com/open-homeautomation/miflora.git
cd miflora
git checkout v0.2.0
sudo python3 setup.py install
and read further information here https://github.com/open-homeautomation/miflora.git
Get the Python package for accessing Bluetooth Low Energy devices.
https://github.com/IanHarvey/bluepy
sudo pip3 install bluepy
Run the following command to find out the MAC address of your device.
sudo hcitool lescan
At some point you should see a line like this
C4:7C:8D:65:BD:76 Flower care
This is an example code for reading the sensor data. You will need to specify the MAC address of your device.
from miflora.miflora_poller import MiFloraPoller
from miflora.backends.bluepy import BluepyBackend
poller = MiFloraPoller('C4:7C:8D:65:BD:76', BluepyBackend)
poller.fill_cache()
poller._parse_data()
There is a script in this repository for reading the sensor data and uploading the measurement to the database located in AWS. Change to the project directory
cd /home/pi/plant_monitor
specify the device MAC address and the REST API URL in the raspberrypi.cfg
configuration file and run the python script.
python3 read_miflora.py
Taking measurements automatically can be scheduled using cron jobs. Edit crontab
crontab -e
and add the following line to schedule taking measurements twice a day, at 6am and 6pm.
0 6,18 * * * cd /home/pi/plant_monitor_rpi && /usr/bin/python3 read_miflora.py
Raspberry Pi NoIR Camera Board v2 is used to capture images of plants.
Run sudo raspi-config
and choose in the menu to enable the pi camera and reboot.
You can take a snapshot from the command line like this
raspistill -o `date "+%Y%m%d%H%M%S"`.jpg
Information about the Python interface can be found here https://www.raspberrypi.org/documentation/usage/camera/python/README.md
Install the following packages.
sudo apt-get update
sudo apt-get install python3-picamera
This is an example Python code to take a snapshot.
import picamera
camera = picamera.PiCamera()
camera.capture('image.jpg')
Similar to taking measurements using the plant sensor, there is a Python script in this repository to take snapshots and upload the images to AWS.
python3 take_photo.py
The script uses a unique identifier as part of the image name. The unique identifier you wish to use for your Raspberry Pi can be configured in raspberrypi.cfg
. One of the options is to use the serial number. It can be obtained in the following way.
cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2
Taking snapshots automatically can be scheduled using cron jobs. Edit crontab
crontab -e
and add the following line to schedule taking measurements every hour during a day.
0 6-18 * * * cd /home/pi/plant_monitor_rpi && /usr/bin/python3 take_photo.py
Get the Python package for reading the sensor data and install.
git clone https://github.com/THP-JOE/Python_SI1145.git
cd Python_SI1145
sudo python3 setup.py install
python3 read_SI11145.py
https://www.raspberrypi-spy.co.uk/2016/07/using-bme280-i2c-temperature-pressure-sensor-in-python/ https://pypi.python.org/pypi/RPi.bme280 https://github.com/rm-hull/bme280
sudo pip3 install RPi.bme280
python3 read_BME280.py
You will need to generate new App password for 2-Step Verification in your Google account through https://security.google.com/settings/security/apppasswords and specify both your e-mail address and the code in the raspberrypi.cfg
configuration file.
python3 send_email.py
https://projects.raspberrypi.org/en/projects/getting-started-with-the-twitter-api
sudo pip3 install twython
python3 send_tweet.py