Documentation

 

Installing yieldbuddy

**Please note, this documentation is for v1.16 and lower; v1.17 and up uses SQLite and does not require setting up an SQL Server. This means you do no need to setup anything in: ‘/var/www/yieldbuddy/www/settings/sql/’ anymore. The camera settings are now setup using the ‘System’ page of the web-interface, so you can skip that section as well.**

There are four main components to yieldbuddy that need to be setup in order for it to operate.
  • Arduino Sketch
  • SQL Server
  • Raspberry Pi ‘yieldbuddy’ daemon service
  • Python Serial (Arduino / Raspberry Pi Communication Script)

 

Arduino Sketch

Your Arduino compatible MCU requires roughly 45kb of flash memory for the sketch.  First setup the DS1307 RTC (Real Time Clock). Connect VCC to VCC, Ground to Ground and SDA to SDA and SCL to SCL.  Install ‘Time’, ‘Pstring’ , ‘DS1307RTC’ , and ‘DHT’ libraries into your Arduino/Libraries directory.    Download Libraries
In the Arduino folder (in the yieldbuddy download), open ‘RTC_Set’ and upload this sketch to your MCU.  This sketch sets the RTC to your current computer time (at time of compiling).
Next, upload the yieldbuddy_arduino.ino sketch.  That’s it for this step.

 

SQL Server

This step is for your desktop machine (ie. not the Raspberry Pi) that you want to act as your SQL database server.  First, install apache using ‘apt-get install apache’ or go to apache’s website and download and install the current version if you’re on Windows. Next install MySQL using ‘sudo apt-get install mysql-server’ or go to MySQL’s website and download and install the current version if you’re on Windows.  Next, install phpMyAdmin.  Go to their website: http://www.phpmyadmin.net/ and get the current version.  If you’re on Linux, install to /var/www/phpMyAdmin, else, install to your site root.
Now that apache, MySQL and phpMyAdmin are all installed it’s time to import the default yieldbuddy SQL database. First, download the database here, then navigate to http://127.0.0.1/phpMyAdmin and login to your MySQL server.  Next, Import the database you just downloaded. You can run multiple yieldbuddy’s just by changing the database name.   Use something like ‘yieldbuddy-i’ where ‘i’ is the number representing the yieldbuddy you’re setting up.  This is also the time to add a new user with ‘ALL PRIVILEGES’.  By default, I chose username: ‘yieldbuddy’ password: ‘default’

 

Raspberry Pi ‘yieldbuddy’ Daemon

SD-Image:   Download the current version, and if you’re on linux use, ‘dd if=/path/to/image of=/dev/sdx’ where ‘sdx’ is the path to your SD card reader.  If you’re on windows use the tools as stated on the Official Raspberry Pi website.

 

Manual Install:   Download the zip to ‘/home/pi’ and unzip using ‘unzip filename.zip ./’  Now type ‘sudo su’ and cd into the Raspberry Pi/yieldbuddy/install/ folder.  Type ‘bash ./install.sh’  Follow the on-screen instructions and reboot the Raspberry Pi.  Before you login you should see, “Starting yieldbuddy daemon…” “Started.”    Login and run ‘top’ you should see ‘yieldbuddy.py’ running.  If it is not, try ‘sudo service yieldbuddy start’

 

Both Installs:   Change the settings for yieldbuddy in /var/www/yieldbuddy/www/settings/sql/    Type ‘sudo su’ first.  Navigate to the settings/sql folder and type ‘ls’.  You will see a list of files.  You need to change the strings in these files to match your SQL settings.  Just type, ‘sudo nano ./<filename>’  Change the settings to match the SQL server settings we setup before.

 

One folder back, in the ‘/var/www/yieldbuddy/www/settings/’ folder is a file containing your camera’s connect-back address.  This is the address that the camera applet, Cambozola (on the bottom of the overview.php page), will use to connect back to your webcam if it is in a remote location. So, if you have a dyndns account for example, use that address here so when your away from home you’ll be able to connect back to your webcam. You will probably want to set this up for your yieldbuddy anyways. I use ‘ddclient’ on my MySQL server to update my DynDNS account with my ISPs current IP address periodically. Then I don’t have to know my IP address, I only have to know my dyndns address.

 

Python Serial (Arduino / Raspberry Pi Communication Script)

Located at /var/www/yieldbuddy/yieldbuddy.py , this script does the serial talking between the Arduino and the Raspberry Pi.  Just like the PHP page, it also loads the settings for connecting to the MySQL server from /var/www/yieldbuddy/www/settings/sql/.
When a command is sent through the web interface, PHP updates the /var/www/yieldbuddy/Command file with the issued command.  The yieldbuddy.py python script reads this file often.  If the file is not empty, it reads the file and sends the command in question to the the Arduino through the serial interace.  Once the command has been sent, it clears the ‘Command’ file.

 

Restoring Defaults (Important)

Okay, so everything’s running…  What now?  The settings are stored in the Arduino’s EEPROM.  These need to be updated with the default values, or else you will probably have some issues.  Go to the ‘settings’ section of the web interface.  Click ‘Restore Defaults’ and as long as everything is setup and working, this will cause the Arduino to call the RestoreDefaults() function in the Arduino Sketch, thus setting up your EEPROM with the proper values.  Your web interface should now reflect the default values (ie. Check the ‘Set Points’ page and you should see the default values for the Set Points).

 

Setting Up A Camera

For the webcam, we will use a program called ‘motion’. To install type ‘sudo apt-get install motion’ The config file is stored in the ‘/etc/’ folder so you’ll have to edit the file with ‘sudo nano /etc/motion/motion.conf’.  In this file, change the following options:
daemon on
I change width to 640 and height to 480 for a better image. (Camera dependant)
framerate 2
auto_brightness on (Camera dependant)
output_motion off
ffmpeg_cap_new off
ffmpeg_cap_motion off
snapshot_interval 0
webcam_port 8081
webcam_quality 70 (Again, change this depending on preference)
webcam_localhost off <— Important!
Now you’ll have to check the ‘connectback_address’ in ‘/var/www/yieldbuddy/www/settings/connect_backaddress’ (using sudo nano again) and make sure that this address matches the route you want the java applet on the ‘overview’ page (Cambozola) to take when connecting to the camera. This would be: http://<Raspberry Pi’s IP Address>:8081
Since I use a dynamic ip service like dyndns, mine is: http://<private>.dyndns-ip.com:8081 so I can connect to the webcam over the internet (after changing my router settings to open port 8081 to the IP address on the Pi).

 

Once these changes have been saved, you should be able to start motion. I’ve already created the script to automate this, so all you should have to run is ‘sudo /var/www/yieldbuddy/start_motion’.

 

Questions/Feedback

Your questions and feedback are welcome on the forum.
Last Edited: Mar 28, 2013