The Raspberry Pi takes over a greenhouse

First Test

The first test of the trial construction used a current version of Raspbian plus I2C drivers and I2C tools on the Raspberry Pi. The driver comes from the WiringPi library. (See the box titled "Installing WiringPi." You should get the I2C tools from the usual package sources for the system by entering:

sudo apt-get install i2c-tools

Installing WiringPi

The WiringPi Project [9] offers a library to access the Rasp Pi GPIO. The individual pins of the interface can be read and written using simple commands and a C API. Additionally, WiringPi has a driver for the I2C bus used in this project. However, this nifty library is not yet found in the package sources for Raspbian. It is a good idea when starting the project to download and compile the software sources from GitHub as set forth in Listing 1. Afterward, you can read all of the ports using a command such as gpio readall (Listing 2).

For some time now, it has been necessary to activate kernel support for the optional I2C module with the Raspberry Pi configuration tool. You can call this tool via sudo raspi-config and set the option under 8 Advanced Options | A7 I2C to Yes. Afterward, you should close the tool and restart the system with the command sudo reboot. To load the I2C driver and test whether the devices connected to the bus report correctly, enter:

gpio load i2c
i2cdetect -y 1

In the example from Listing 3, the PCF8574 (0x3f) and the two LM75 temperature sensors (0x48 and 0x49) respond quickly. To test the digital inputs, you can read them every two seconds with:

The bit will be set to 1 depending on which input has voltage. The inputs correspond to the four lower value bits. To test the outputs, you should set the higher value bits to 0. In this way, you can gradually turn on the outputs (Listing 4).

Reading the two LM75 sensors requires a little more work and has already been described in detail in a previous article [10]. That article contains a full description of how the LM75 works with the Raspberry Pi, as well as tips for control and testing.

Conclusion

The RPi-ified greenhouse gets all new hardware with this update. Even though the upgrade does not bring additional functionality to the first design described in 2014, the new project makes it easier to expand the hardware. This means there is ample opportunity to develop this project further. For instance, controlling the greenhouse could be addressed in a home automation scenario. Look for new greenhouse projects in future articles.