Introduction: Raspberry Pi Beekeeping Server
Beekeeping (or apiculture, from Latin: apis "bee") is the maintenance
of honey bee colonies, commonly in hives, by humans. A beekeeper (or apiarist) keeps bees in order to collect their honey and other products that the hive produces (including beeswax, propolis, pollen, and royal jelly), to pollinate crops, or to produce bees for sale to other beekeepers. A location where bees are kept is called an apiary or "bee yard".
Depictions of humans collecting honey from wild bees date to 15,000 years ago. Beekeeping in pottery vessels began about 9,000 years ago in North Africa. Domestication is shown in Egyptian art from around 4,500 years ago. Simple hives and smoke were used and honey was stored in jars, some of which were found in the tombs of pharaohs such as Tutankhamun. It wasn't until the 18th century that European understanding of the colonies and biology of bees allowed the construction of the moveable comb hive so that honey could be harvested without destroying the entire colony. This is one of my hobbies. My job is electronic engineer so, I decided to automate the beekeeping process, sort of. It very important when harvesting to have the right informations like temperature, humidity, honey quality and weight chart, to make the decision to stay or move on to a different zone. My system is based on Raspberry Pi and Arduino. Arduino board is connected to DHT humidity and temperature sensor, LCD display and HX711 amplifier with scale, reads the values and print it to the LCD display and to Serial port. DHT sensor is used for outdoors and will be mounted outside the projects case. The load scale sensor is from a a weight scale, already has a frame, and will be mounted at the bottom of a beehive. Raspberry Pi reads the serial port and stores the values in database, then a web server is opened and displays charts with temperature, humidity and weight of the hive, along with statistics, Min, max, average and a selection for information (6, 12, 24 hours).
Step 1: BOM
Gathering the parts:
1 x Raspberry Pi B+
1x Arduino Nano
1x HX711 Scale amplifier board
1x Load Cell (mine is from a scale, and it's max 300 KG)
1x DHT Humidity and Temperature sensor
1x LCD display for Arduino
1x 4.7k Resistor
2x 10k Resistors
2x Push Buttons
1x Wifi Dongle
Step 2: Begin
First, you need to install Raspbian. More information here: https://www.raspberrypi.org/documentation/installation/installing-images/
To connect to ssh, you need the Pi's Ip address. I used a cool tool for Mac called PiFinder (https://learn.adafruit.com/the-adafruit-raspberry-pi-finder/finding-and-connecting) which finds all the Raspberry Pi's connected to the network. You can connect the Pi to a display, open the Terminal and run:
The inet Ip address is the Pi connection to the network. Next step is to connect via ssh either through Putty on Windows, or from Terminal via Linux or Mac.
I ran the command from terminal:
ssh firstname.lastname@example.org (where pi = user and 192.168.1.23 = Ip address of the PI)
Do an update of the system. Open the terminal,or ssh, and run:
sudo apt-get update sudo apt-get upgrade -y sudo reboot
Install the software for comunnicating with the Arduino via serial: sudo apt-get install ino
Install the database software: sudo apt-get install sqlite3
Install the web server: sudo apt-get install apache2
Step 3: Setting Up the Arduino
Next step is to setup the Arduino environment: https://www.arduino.cc/en/Main/Software
Install Arduino IDE and then install the libraries from the links below.
Connect your Arduino board and upload the sketch: ArduinoRaspberryPiHive.ino located in the Git repository.
Connect DHT sensor to digital pin 10, LCD display to SCL and SDA, HX711 board to A1 and A0, button for reset scale to pin 11 and button for backlight on to digital pin 12. Also, all extensions have 5v and Ground. I did a split and soldered directly to my Arduino's usb, a screw on terminal, for 5V and GND. I figured if I used the 5v pin on the Arduino I would get about 4.5v.
Now we proceed with configuring Raspberry Pi.
Connect the Arduino via USB cable to Arduino.
Step 4: Prepare the Enclosure
Solder wires to the push buttons and 10k resistors as in the schematic attached.
Drill holes to the enclosure box and add the buttons, DHT sensor, Load scale cable and Lcd Display.
I also glue the DHT sensor to the box and added an On/Off switch.
One of the push buttons is for lighting up the LCD backlight.
The other one is for setting the scale to 0 Kg.
Step 5: Back to Raspberry Pi
Connect the Arduino via USB cable to Arduino.
Open the terminal and run:
You will be prompted with a serial reading from the Arduino. If not you did something wrong.
Close the window and open another Terminal.
Create the database by runing the following command: This creates a database called templog.
Add tabels weight and temps: This query creates 2 tables called temps (having a coluimn for date and time called timestamp, and a numeric column called temp) and weight (having a coluimn for date and time called timestamp, and a numeric column called Kg)
CREATE TABLE temps (timestamp DATETIME, temp NUMERIC);
CREATE TABLE weight (timestamp DATETIME, Kg NUMERIC); Commit;
Make sure to add ; after each query.
If you run -tables you should be prompted with two tables, temps and weight.
Quit the Terminal, and run the following commands: FIrst will copy the templog.db to folder /var/www/. The second command changes the file's owner.
sudo cp templog.db /var/www/ sudo chown www-data:www-data /var/www/templog.db
Now it's time to import code from git. In the Terminal window, run:
git clone https://github.com/vpetrache/Raspberry-Pi-Web-Application-Temperature-Reading.git
This will create a folder called Raspberry-Pi-Web-Application-Temperature-Reading with monitor.py and webgui.py in it. Go to the directory:
cd Raspberry-Pi-Web-Application-Temperature-Reading cp monitor.py /usr/lib/cgi-bin/ cp webgui.py /usr/lib/cgi-bin/
Change the file ownership: sudo chmod +x /usr/lib/cgi-bin/monitor.py sudo chmod +x /usr/lib/cgi-bin/webgui.py sudo chown www-data:www-data /usr/lib/cgi-bin/monitor.py
Step 6: Starting the Server
To add the python script to run as a job:
sudo crontab -u www-data -e
Add the follwing line at the end of the www-data file:
*/15 * * * * /usr/lib/cgi-bin/monitor.py
Next step, enable the Apache web server to run the script:
sudo leafpad /etc/apache2/sites-enabled/000-default &
Navigate to line:
< Directory "/usr/lib/cgi-bin" >...
< /Directory >
Add the following line:
AddHandler cgi-script .py
And restart the Apache server:
sudo service apache2 reload
Restart the Raspberry Pi:
Go to any browser and connect to http://YourPiIpAddress/cgi-bin/webgui.py and you should see something like this (with a few data):
Step 7: Wrap Up
When the season comes, I have a functional load scale and more knowledge about honey harvesting.
Here are the repositories used in this project:
Also, a short video.
We have a be nice policy.
Please be positive and constructive.
hello. i am starting with the arduino board.
but it seems to be the libs are not ok
the IDE cannot find
I also cannot find it on github