Pi Project Update

Over the last few years, I decided to make my “Outdoor automation” a little more permanent and indoors. The Pi lived outside in my garage or screwed to a floor joist in my basement. My goat was to provide the same functionality but in a safer case, and have it permanently installed. The tasks the solution needed to perform were as follows.

  1. Water the lawn during the summer
  2. Control the Christmas lights during the winter
  3. Play music for Halloween on Oct 31.

I controlled the watering with a 4 bank relay. My plan was to have the ability to control 4 watering zones. I still only have the one water valve but I do want the ability to add up to 4.

During the month of December, I wanted to control the Christmas lights. 1 relay for the eve lights and 3 more for the floodlights on the lawn. The floods alternate colour ever 30 seconds.

The Hardware & Software

Pi Model B

I already owned most of the hardware for the Pi. It was the outdoor box to house the outlets and pipe. I also wanted a box inside to mount the relays, transformer and the Pi.

I used an 8 channel relay board. I soldered 4 relays together for the 25V AC side and the other 4 for the 120V AC side. If at any point I need to change the board, I will be replacing this one with 2 x 4 channel boards. This will then separate the high and low voltage.

Relays are wired up.

The Pi was always the best candidate for these tasks. The Christmas lights and Sprinkler projects were built in Python3. You can find the code for these here.

The Halloween project just plays some scary music to a speaker I place just near the door. I ordered a 15′ 3.5mm cable extension to get the audio from the Pi out to the front lawn. This cable I run through the window because it’s used once a year for one day. The code for this is available here.

Photos

Setting up the layout.
High voltage is hooked up.

Installing MyBB 1.8.12 on Ubuntu Server

In the following tutorial I will explain how to install MyBB 1.8.12 on Ubuntu Server. I will be doing this from the command line so no GUI needed.

  1. Download the MyBB package. You will want to get the latest version of MyBB.
  2. wget --content-disposition https://www.mybb.com/download/latest -O mybb.zip
    
  3. By default Ubuntu does not come with unzip. Install that now.
  4. sudo apt install unzip
    
  5. Unzip the MyBB zip file
  6. unzip mybb.zip
    

    2 folders should now be in your present working directory. Unload and Documentation.

  7. Install LAMP (Linux, Apache2, PHP and MySQL) Restart Apache after
  8. sudo apt install apache2 mysql-server php-mysql php libapache2-mod-php php-mcrypt
    sudo systemctl restart apache2
    

    This install will ask to create a root password for the MySQL database.

  9. Move MyBB files to the server folder
  10. cd /var/www/
    sudo mkdir mybb/
    mv ~/Upload/* /var/www/html/mybb/
    

    You should now see all the files in the www/mybb directory.

  11. Rename the inc/config.default.php
  12. sudo mv inc/config.default.php inc/config.php
    
  13. Now change permissions on the following files and directories
  14. sudo chmod 666 inc/config.php inc/settings.php inc/languages/english/*.php inc/languages/english/admin/*.php
    sudo chmod 777 cache/ cache/themes/ uploads/ uploads/avatars/ admin/backups/
    
  15. Login to MySQL and create Database.
  16. mysql -u root -p
    

    Enter the password that was create for MySQL.
    Now create the database and a user to have access to this database only.

    create database MyBB;
    grant all privileges on MyBB.* to 'MyBB'@'localhost' identified by "S0mePassw0rd";
    flush privileges;
    exit;
    
  17. Browse to the install page.
  18. You can now follow the step by step installer. Be sure to specify the database credentials you create above. Do not use the root account.

Go to your main web URL and you should see your new forum ready to go! If you have any questions please leave them below.

Installing VirtualBox Guest Addition Ubuntu Server 14.04.3

Because my office is currently under construction I didn’t have access to my primary desktop machine that runs VMware Workstation. I needed to spin up a Ubuntu Server box to do some testing. It has been a few years since running VirtualBox but I decided to give it a go on my Mac Book Pro.

Installing VirtualBox is straight forward. Follow the on screen steps and you should be up and running. I setup a new VM with the minimum requirements for Ubuntu Server 14.04.3 LTS. All of my Digital Ocean servers run Ubuntu Server 14.04 LTS so I figured I would stick with that.

After installing and updating the new machine, I need to install the guest additions.

  1. Install the required build tools and dependancies.
  2. sudo apt install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r)
    
  3. Restart VM.
  4. sudo shutdown -r now
    
  5. Mount the Guest Additions CD from the VirtualBox Menu.
  6. Devices -> Insert Guest Additions CD image

  7. Mount the CD in Ubuntu Server
  8. sudo mount /dev/cdrom /media/cdrom
    
  9. Change directory to CD
  10. cd /media/cdrom
    
  11. Guest Additions can now be installed
  12. sudo ./VBoxLinuxAdditions.run
    

    Ubuntu Server will give you an error about not finding X.org. Don’t worry about it. Guest additions get install anyways.

Restart the VM and that is it! VirtualBox Guest Additions have now been installed.

If you have any questions please let me know below!

Sprinkler Project

Final received my first Raspberry Pi. I have had an idea for years about what I wanted to do with one. Automated sprinkler system. 2 summers in a row my lawn has burnt to a frazzle. I have dealt with automated sprinklers before so why not build my own system!

What is needed:

  1. RaspberryPi
  2. Relay Board
  3. Water Valve
  4. 24 V AC transformer
  5. 1 LED (Yellow)
  6. 1 Locking switch

In this project, I started off with a Cana-Kit Raspberry Pi Ultimate Starter Kit. My dad had a 4 channel relay board he purchased for an Arduino project he was going to build but never started. So I borrowed that from him. You can find one here.

I also purchased an Orbit water valve for an in-ground sprinkler system. I used this one right here. I also found some adapters to connect this valve to a regular garden hose as I will not be burring the water line.

For power, these water valves normally run on 24V AC. To get this project going, I purchased a simple doorbell transform although I would recommend getting the correct 24V AC sprinkler transformer. (I will explain why later)

Building

Because this was my first Raspberry Pi project, I started by wiring the breakout board to 4 LEDs instead of going directly to the relays. This posed a problem later on so I would suggest wiring directly to your relay board.

The relay board uses a positive voltage coming from the GPIO pins to keep the relay open. When the voltage is removed the relay will then close. This is backwards to what is required for the LEDs but because I was an n00b with this, I scratched my head for a while.

I added an LED for a status indicator. This flashes differently based on different triggers. For example: if the cancel button is pressed then flash the LED or if the rain sensor is tripped leave the LED on until the sensor is no longer wet. This also halts the main loop until these trips are cleared.

Here is how the GPIO is wired to the Raspberry Pi:

Description GPIO IN/OUT
Zone 1 (Relay) 17 Out
Zone 2 (Relay) 27 Out
Zone 3 (Relay) 22 Out
Zone 4 (Relay) 23 Out
Water Sensor 18 In
Cancel Button 4 In
Status LED 12 Out

I had a 2″ x 4″ lying around so I used that to screw all the components to for now. I added a 120V wall switch and outlet. The 24V transformer and the outlet are both wired to the switch. The Raspberry Pi is plugged into the outlet. I have a 3 conductor power cord so I used that to feed power to the switch. Be careful with 120V wiring. You can cause yourself and your project serious damage. Consult a professional if you are unsure.

The output of the transformer is wired to one side of the relay. I added a heavy gauge wire between the relays. I highly suggest you test the posts on the relays before connecting the 24V AC. The other side of the transformer can be connected to the Orbit valve. The second wire from the valve can be connected to the first zone. Please see the photo below.

The great part about this relay bank is the LED indicators. We can create the program without having all the water valves. I would also suggest leaving the 24v transformer off while developing the code.

Code

I decided to write the code in Python. I had some experience writing Python code before but it was a few years back. The basics of this program are straightforward. We want to water each zone individually for a set amount of time. In my area, I have low water pressure so I only want to water one zone at a time. There is also a bylaw only allowing homeowners to water on an odd or even day of the week.

I also wanted the ability to log when each zone is triggered, when the water sensor has tripped and when the cancel but has been pressed. For this, I decided to use a MySQL database. The reason I chose this is that I already have MySQL running on my server in the basement. It handles my home Kodi environment. Setting up the database was simple. Create a new database and then create the one table we need right now. We could always add more later. See the SQL commands below to create the table.

CREATE TABLE tblLogs (
logID int NOT NULL auto_increment,
zone varchar(25),
logTime datetime DEFAULT NOW(),
description varchar(200) NOT null,
PRIMARY KEY (logID)
);

I am currently not doing anything with the logged data but maybe someday we will have reports.

Here is the main Python code. The script runs when the Raspberry Pi boots. You can accomplish this with Cron.

GitHub Page

You will need to make changes to your setup. The database function may not be required for you. You can find that in the dbLog function. I would suggest if this is your first project build your code from scratch. It’s the only way to learn.

Conclusion

I haven’t added “water” to this project yet. I am hoping to find some cheap hose I can cut up and make a few short runs. Next year I may add another 3 watering zones.

One problem I did notice, using the doorbell transformer, is the amount of heat it generates. I do suggest getting the proper transformer for these Orbit valves. If you’re running multiple valves at the same time I would look at the Orbit transformer.

I will continue to create more Blog posts when I update this project. I am already starting to think about Christmas lights!

If you have any questions, please leave them below.

Service Manager

Welcome to Service Manager v1.0.0. The following application allows a user to easily start and stop services as required. I built this tool a few years ago when I was developing database software. I would have issues with the service and need to restart it. It was much easier to build a program to do this instead of going into the Service MMC. I will be adding and updating this application.

Download:

SQL Status Project

If you have any questions please comment below.