Building a fully automated spacebucket using a Raspberry Pi 2 and Raspberry Pi Zero W.
Have a look at the wiki for a more detailed insight into the idea
For this project I'm using two Raspberry Pis, a Zero W (publisher) to capture sensor data and to pass it to the Pi 2 (subscriber). The Raspberry Pi 2 then processes the received data, controls fans and light accordingly and uploads the data to a database for later use (e.g. visualizing it in a graph).
Note: As of right now, the following part is not complete by any means and will be updated every now and then. How ever, I am listing useful ressources I used in the wiki for anyone who wants to try or has a similar project. Cheers!
The DHT11-sensor uses the Adafruit_Python_DHT library. To use it you have to install the python-dev module first:
sudo apt-get install build-essential python-dev
then download the library and install it
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT/
sudo python setup.py install
sudo pip3 install paho-mqtt
python3 -m pip install mysql-connector
To use the 433MHz transmitter install 433Utils by Ninjablocks:
git clone --recursive https://github.com/ninjablocks/433Utils.git
cd 433Utils/RPi_utils
make all
and then compile the outlet.cpp:
cd ../../
sudo g++ -DRPI /433Utils/rc-switch/RCSwitch.cpp outlet.cpp -o outlet -lwiringPi
sudo pip3 install paho-mqtt
python3 -m pip install mysql-connector
- mqtt_publisher.py
- pw.py
- mqtt_subscriber.py
- outlet.cpp
- emailinfo.py
- pw.py
Change the pw.py
on both devices to fit your database
If you've set up the software and the hardware correctly, start the software on both devices:
sudo python3 mqtt_subscriber.py
sudo python3 mqtt_publisher.py
When starting the scripts you can use command line arguments:
sudo python3 mqtt_subscriber.py -h
usage: mqtt_subscriber.py [-h] [-d]
optional arguments:
-h, --help show this help message and exit
-d, --debug Toggle debug output
With the publisher program running, you can also use commands to interven in the program:
To list all available commands type:
help
To read the current sensor data and send it to the subscriber, use
force measure
The cycle in which the software measures the data will not be shifted by this
You can manually adjust the fanspeed using:
fanspeed
followed by a number between 0 and 1000 in the next line.
With debug mode enabled, you can use
simulate temperature
and
simulate humidity
followed by a number of choice to simulate the corresponding value and send it to the subscriber