All Projects → jeffmcfadden → PiThermostat

jeffmcfadden / PiThermostat

Licence: MIT license
Build a Raspberry Pi Thermostat

Programming Languages

ruby
36898 projects - #4 most used programming language
Haml
164 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
SCSS
7915 projects

README

The software to use a RaspberryPi as a Thermostat for just about any HVAC unit or component. Works great for window A/C units and space heaters as well as Central HVAC Units. If you can get access to the power or control wires for your device, you can probably wire it up.

Equipment

Do these things after boot:

sudo modprobe w1-gpio
sudo modprobe w1-therm
gpio mode 0 out
gpio write 0 1
gpio mode 1 out
gpio write 1 1
gpio mode 2 out
gpio write 2 1
gpio mode 3 out
gpio write 3 1

Unicorn

Start:

bundle exec unicorn_rails -c config/unicorn.rb -E production -D

Restart:

sudo kill -HUP `cat /www/thermostat/pids/unicorn.pid`

OR

sudo restart unicorn # If you're using upstart

Setting up the Pi:

sudo apt-get update

mkdir installs
cd installs
sudo apt-get install git wget
wget "https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.3.tar.gz"
cd ruby-2.3.3
sudo apt-get install autoconf
autoconf
sudo apt-get install gcc g++ make ruby1.9.1 bison libyaml-dev libssl-dev libffi-dev zlib1g-dev libxslt-dev libxml2-dev libpq-dev zip nodejs vim libreadline-dev
./configure && make clean && make -j4 && sudo make install

sudo apt-get install postgresql postgresql-contrib libpq-dev

# Install WiringPi: http://wiringpi.com/download-and-install/

sudo -i -u postgres
createuser -s -P rails
exit

sudo vim /etc/postgresql/9.4/main/pg_hba.conf

# change all the 'peer' to 'md5' NOT THE LOCAL ONE, LEAVE TO TRUST OR EVERYTHING BREAKS

sudo service postgresql restart

sudo mkdir /www
sudo chown pi:pi /www
cd /www
sudo git clone https://github.com/jeffmcfadden/PiThermostat.git
mv PiThermostat thermostat
cd thermostat
echo "install: --no-rdoc --no-ri" >> ~/.gemrc
echo "update:  --no-rdoc --no-ri" >> ~/.gemrc
sudo gem install bundler
bundle install
RAILS_ENV=production bundle exec rake db:create
RAILS_ENV=production bundle exec rake db:migrate

sudo apt-get install nginx

# install the thermostat.conf
# install the crontab

sudo nginx
# After this I had to remove 'default' from /etc/init/nginx/sites-enabled

# this should work now:
rails c production

# setup your application.yml - see config/application.yml.sample for a sample

RAILS_ENV=production bundle exec rake assets:precompile

mkdir /www/thermostat/pids/

# RPi 2 (or any kernel 3.18.8 and higer)
# You have to edit your /boot/config.txt file and add this at the bottom:
# dtoverlay=w1-gpio

# reboot
sudo shutdown -r now

# If you want to run everything now:
bundle exec unicorn_rails -c config/unicorn.rb -E production -D

# Upstart - DONT DO THIS FOR NOW. WILL KILL YOUR PI

# sudo apt-get install upstart # Yes, it's okay, even given the warning. NOT ACTUALLY OK. DONT DO THIS

# Copy the unicorn.conf file to /etc/init
# Copy the setup_1_wire_bus.conf file to /etc/init

# Reboot for Upstart to take effect.
sudo shutdown -r now

# Once Running, follow the web based setup process by visiting http://[your raspberry pi]/

Upgrading

Upgrading from a previous version may involve these steps:

cd /www/thermostat
git pull
RAILS_ENV=production bundle install
RAILS_ENV=production bundle exec rake db:migrate
sudo shutdown -r now

Be sure to upgrade the homebridge plugin to the latest version as well

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].