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.[2] 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

Power Banks

Enclosure box

Usb Cables

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:

ifconfig

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 pi@192.168.1.23 (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:

ino serial

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.

sqlite3 templog.db

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:

sudo reboot

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:

https://github.com/vpetrache/Raspberry-Pi-Web-Appl...

https://github.com/bogde/HX711

Also, a short video.

Comments

author
leovz (author)2016-06-26

Hello, I have the arduino running. Needed some tweeking in relation to the library's. Now this part is working.

The raspbian pi is not... the picture is the result after "ino serial" (maybe just a baud rate problem) But if I follow the instructions on how to get apache2 run the scripts I get lost.

Can you put me back on track?

thank you.

2016-06-26 14.40.17.jpg2016-06-26 14.44.15.jpg
author
leovz (author)leovz2016-06-29

Hai,

Starting to learn Python: Found a few bugs in monitor.py. Or using the wrong python version? (somthing with temperatura and function caling...

I am curious about your answer.

Thank you,

Leol.

author
leovz (author)leovz2016-06-27

I have now readable output (baudrate 9600!). Apache2 is showing the default page.

Questions:

wegui.py is webgui.py ?

In de file: monitor.py en webgui.py you place te database in /var/www/ In apache2 is this nou /var/www/html/?

If i browse to myip/cgi-bin/webgui.py The only text i see is: No data found (I find it in webgui.py but I do not program in py (jet))

thank you, Leo.

2016-06-27 15.33.58.jpg
author
leovz (author)2016-06-21

Hello, Nice project and I want to build it: Problem:

The command sudo apt-get install ino does not find "ino" There is "arduino" software. Is this right?

greetings Leo.

author
pvalyk (author)leovz2016-06-21

Try this:

https://github.com/amperka/ino

author
leovz (author)pvalyk2016-06-21

Thanks, that's it!

author
CatalinRO (author)2016-04-30

Did you try to check weight measurement variation? We did an experiment using HX711 and Arduino: we loaded 10 kg and let Arduino recording readings, we recorded +/- 800 grams over 24 hours which is too much for a bee hive.

author
CatalinRO (author)CatalinRO2016-04-30

PS: this was done outside, therefore temperature varied from +3 to +18

author
pvalyk (author)CatalinRO2016-05-02

Nope. Weight variation is too much to use it in productive environment. This project was first made as a school project and if it's relevant, as a . I was wondering if I can place the scale sensor in a vacuum chamber, will it still have those variations?

author
CatalinRO (author)pvalyk2016-05-03

Not sure what is actually influencing the weight measurement. Temperature, air moisture, cosmic radiation... Yes, in vacuum may be perfect, but not practical. I have no vacuum chamber to check.

author
XxsonicxX (author)2016-03-29

Can the Arduino Uno be used? I am almost positive it has the same ports, if not more.

author
gdsmit1 (author)2016-02-23

Nice 'ible.

I'm also a beekeeper and will be keeping an eye on this project to see if I can implement it into my setup.

Do you think that the weights will be accurate in measuring the amount of honey in there? As you know the weight of the bees can be pretty heavy when they have built up. Of course I may be misunderstanding the way that you will use these measurments.

author
pvalyk (author)gdsmit12016-02-26

Actually, my load scale has a max of 300 Kg. The hive might weight as much as 80 Kg, so it;s not much of a problem.

Reading error is +-0.1kg, so it's pretty accurate.

author
gdsmit1 (author)pvalyk2016-02-26

Actually what I meant was how do you know your honey measurement is accurate? The weight of the bees and pollen in the hive will fluctuate quite a bit as the season goes on. I feel certain the bees will be a fraction of the weight of the honey, but are probably heavy enough to throw off any calculations.

author
woodnboats (author)gdsmit12016-02-28

The usual use of a scale hive is to track weight gain over time as an indication of colony strength and the presence of an active honeyflow. One such scale hive in an outyard can serve to give information about the likely conditions in all the hives in the yard. Now, a wifi uplink to your home computer or smartphone would save visits to distant yards. Add a webcam, and you could watch bears tear up your hives from the comfort of your living room. ;-)

author
pvalyk (author)gdsmit12016-02-26

Let me know if you need help.

author
Tecwyn Twmffat (author)2016-02-24

Do you have to calibrate your scales every day due to creep?

author
pvalyk (author)Tecwyn Twmffat2016-02-26

Hey, Actually no.

The calibration takes place in void setup (once at boot). Outside temperature factor is not considered but I'm guessing won't make much of a difference as this is a simple configuration.

Look at this for more details :

https://hackaday.io/project/1741/logs.

author
advent (author)2016-02-24

This is a great application of the Pi and arduino. Unfortunately I will never be able to build it from the
instructions you have given. The scales construction is not discussed,
electronics is not clearly explained and at least one link is not working http://YourPiIpAddress/cgi-bin/webgui.py

Please give more detailed instructions on
the electronics,type of load cell and the construction of the scales itself.
This is not putting down you good work merely a request for more help. Pat.

author
pvalyk (author)advent2016-02-26

Hold up.
There's a phrase saying the scale was taken apart from a working weight scale and I'll update soon with pictures, Fritzing schematic and also how it looks like below a hive.

The link part is Your Pi Ip Address (ex.192.168.1.200). It;s dynamic.

The load cell came from China, not much information to add here.