GardenPi: Sensing with the Pi

(I found this great article about garden automation at Atomic Object and writen by Shawn Anderson )


Phase one GardenPi has been running well for a while now (aside from some wifi connectivity issues). I can legitimately say that my garden waters itself everyday, unless the forecast calls for rain. However, there are definitely improvements to be made. Let’s take a look at how to add analog sensor to the Raspberry Pi for soil moisture and light.


Unlike the Arduino, the Raspberry Pi doesn’t have any built-in support for converting an analog signal to a digital reading. An ADC must be wired up to the GPIO pins on the Pi. Given the plan of having multiple sensors, I went with a 4-channel ADC from Adafruit. Now it just needs sensors: I used a cheap photo-resistor for light, but soil moisture sensors are quite expensive ($20-$100). I decided to follow this guide for building one myself for a fraction of the cost.

Required parts: (approx. cost ~$15)


I’ve updated the code to pull in the sensor data and log it every five minutes. It writes that out to a sqlite database for later reporting.

Unfortunately, the soil readings have not been clean and consistent enough to rely on. So soil moisture readings are not factored into the watering decision just yet. I will be changing the soil sensor to be encased in gypsum soon to increase consistency.


  • Attach the sensors to and ADC per the schematic below. I used screw terminals to allow me to easily connect/disconnect the sensors.
  • Pull the latest code from garden_pi_waterer on Github.
  • Install Sqlite on the Pi.
  • Bundle install in the repository directory; the god configuration from Phase one should not need to be changed.


I can still water my garden based on the daily timer and weather forecast; this feature alone saved my garden while I was on vacation. In addition to that, the GardenPi’s database now tracks the light and moisture readings as well as the time that watering starts and stops.

The charts show the difference between the light sensor working well, and the moisture sensor giving very unreliable readings. The next steps will be to improve my soil moisture readings and factor them into the decision process.

I do have to say, even if I have to use SSH for now, it’s pretty cool to water your garden from your phone. More on that in phase three.

Soil Moisture for Two Days


Light Intensity for Approximately One Day


Updated Schematic


GardenPi: Garden Care with Raspberry Pi

GardenPi Prototype

(I found this great article about garden automation at Atomic Object and writen by Shawn Anderson )

Like any good “lazy programmer,” I’m always looking for ways to automate. This spring’s project: monitoring and watering my garden. I had a wifi-enabled Raspberry Pi laying around and decided to put it to good use. For this project I wanted to do better than just a glorified timer. The goal: An automated watering system that can use the weather forecast, soil, light, and temperature sensors to keep my garden looking great all summer. Continue reading GardenPi: Garden Care with Raspberry Pi

Raspberry Pi Thermostat Part 3: Software Release

Raspberry Pi Home Automation Termostate Software

(I found this article at The Nooganeer and publish it here with his permission)

I’ve finally found the time to release my software.  However… I am extraordinarily busy with Georgia Tech’s OMSCS program, so I will not have time for now to write a tutorial on using the source code.  This is my very first web development project.  Since its inception I have already learned enough to know that there are some things that could be done better–it is my goal to improve the code as I have time.

If you are an experienced web developer, you will most likely laugh at what you see.  Rather than be hateful, please feel free to fork the repo, make my idea better, and submit a pull request.

Whether you are a web developer or not, rest assured that this code base has been running my thermostat for 3 months at the date of this post with exactly zero failures.


To begin, the software consists of four major components which will run on 3 separate pieces of hardware.
  • MySQL Database — Runs on the web server but could run on separate machine
    • The whole system is driven by the database, which should make it easy to expand control methods beyond just the web application.
    • Contains sensor data and HVAC status logs
  • Flask Web App — Runs on web server
    • Displays statuses and plots data from database
    • Allows user to manipulate the state of the thermostat
    • Contains url scheme to add sensor data to the MySQL database when GET request is received from a Spark Core
  • Thermostat Control Daemon — Runs on Raspberry Pi
    • Controls the HVAC system itself and updates the system status on the MySQL database
    • Also acts as a temperature sensor and inserts data into the database
  • Remote Sensor Daemon — Runs on Spark Core
    • Reads data from DALLAS TEMP SENSOR, and sends a GET request containing the sensor ID and temperature reading to the Flask app.

Eventually, I will create posts for how to set up each piece of hardware, but for now, you’re stuck with the README files in the Bitbucket repos.

Feel free to contact me with any troubles you have and I will try to assist you. Eventually I may have some real issue tracking set up.

Raspberry Pi Thermostat Part 2: Hardware Overview

Raspberry Pi Home Automation Thermostate  HardwareCover

(I found this article at The Nooganeer and publish it here with his permission)


 Hardware “BOM”

  • Raspberry Pi with 1000mA Power Supply and Wifi Dongle
    • All pure “thermostat” logic runs on the Pi
  • Makeatronics Solid State Relay Board (More on this later)
    • Allows the Pi to switch the 24v AC signals for the HVAC system
    • I found that a 330Ω resistor behaves better in place of the 560Ω resistors.  Possibly because for my heatpump system, I sometimes have to drive all three circuits at once.
  • iPhone 4 and 3D printed wall dock (optional)
    • Mounts in place of the old thermostat to allow for “normal” interaction with the thermostat (for guests, etc.)
  • Spark Core Wifi enabled microcontroller (optional)
    • Remote wireless sensors
  • DS18B20 One-Wire temperature sensor (at least one, but the more the better!)
    • Pair one with your Pi, and then one per Spark Core.
    • I got the enclosed waterproof type which was probably unnecessary
  • Web Server
    • I used an old computer to host the web app and MySQL database locally, but it should work just as well on a cloud server
  • Wall Access Panel
    • Due to my Mechanical Engineerness, my electronics hardware work should be hidden from the light of day.
  • Jumper wires, resistors, etc.

Continue reading Raspberry Pi Thermostat Part 2: Hardware Overview

Raspberry Pi Thermostat Part 1: System Overview

Raspberry Pi Home Automation Thermostat Demo Fig1

(I found this article at The Nooganeer and publish it here with his permission)


Home automation has always been a fascination of mine.  How much time and irritation would I save if I didn’t have to worry about turning things on and off, or wonder in which state they were left?  How much more efficient would my home be?  Wouldn’t it be cool to always know the state of every power consumer in my home, and then be able to record and analyze that data as well?  With my brain nearly exploding with dreams of home automation, my wife and I bought our first home in May 2014.

The starting point for my home automation system (which of course will be DIY and open source) is a thermostat.  I needed to control the biggest energy hog in my house first!  I had a  Raspberry Pi laying around that I had done some tinkering with, and after some Googling, I decided it would be the perfect brain for my project.

I used and as a springboard to get started.

Why Am I Doing This?

Besides that I love automation and efficiency, I think this project could be a contributor to the “good” part of the Internet of Things revolution.  It is amazing how technology has brought us to the point that we are able to connect almost anything to the internet and access it from anywhere in the world.  In my eyes, one of the most valuable components of this technological advancement is the data.  Unfortunately, if you decide to purchase an IOT device, you may not be the owner of all/any of the data that device is generating.  There may be restrictions on how you can view/analyze the data, and it may be difficult or impossible to get to it in a raw form. Continue reading Raspberry Pi Thermostat Part 1: System Overview

Raspberry Pi Home Automation project – the best

This article about home automation with a Raspberry Pi is probably the best one I saw on how to do something different than just switch on lights from your cellphone in the field of Raspberry Pi home automation.

Electronichamsters is a dog lover and a few years ago when he became a dog owner he doesn’t want to put his dog in a kennel during the day and watching him on a webcam wasn’t a solution either.

The next step for him was to start reading and that leads to tinkering and that leads to this great Raspberry Pi home automation project.

You can read about the whole project here.

Here is a nice collage/overview that electronichamsters created of the project.raspberry pi home automation

Why this is a great project

In electronichamsters own words (and I agree with him) here is a list of reasons why his Raspberry Pi Home Automation is a lot different than other projects.

  • Cheap – each sensor node is less than $20, including the wireless transceiver.
  • Flexible – I’m providing the design for wall-powered sensors as well as energy efficient battery powered sensors that can run for a year on 4xAA batteries.
  • Best wireless solution – the RFM69HW in this project is energy efficient and has great range. Many other wireless solutions make compromises. Bluetooth is energy efficient, but poor range. Wifi has ok range, but can’t be battery powered for a year.
  • Attractive and secure user interface – the OpenHAB UI is available as a mobile app (Android and iPhone), but is also accessible through any web browser. And the communication between the display device and the Raspberry Pi is done using encryption and authentication. So your home automation system stays private. It’s also pretty easy to use considering the sophistication and features.
  • Controls commercial products: If you happen to have Sonos speakers, Insteon lights/plugs, or z-wave at home, you can use OpenHAB to control those devices too. OpenHAB isn’t just for this Arduino project.
  • Allows you to integrate any sensor to your automation needs. Commercial home automation system might not provide the niche sensing “thing” for which you have a need, maybe because your needs are unique.

raspberry pi home automation