Skip to content
crleblanc edited this page Nov 2, 2012 · 7 revisions

Overview

This project is still in early development, but it's currently in use controlling a heat pump from a Raspberry Pi. This page gives details on how to get all working.

This project does not decode the IR codes, it simply records and replays them. It is not related to LIRC or any other IR software. It's meant to be a quick way of recording and replaying IR codes much longer than other IR software can support.

Hardware

You will need the following items to make use of this project:

  • A Linux machine, although the Python code is portable and could work on Windows it hasn't been tested on that platform. My Linux box of choice is a Raspberry Pi because it's a low cost, low power Linux machine, and I wanted an excuse to get one.
  • An IR Toy, available from Dangerous Prototypes
  • A working net connection

Software

  • Once your Linux machine is setup, you'll need to install 'pip' and 'git'. On Ubuntu or Debian you would type "sudo apt-get install python-pip git"
  • With pip installed, install all of the required Python packages with the command "sudo pip install pyrfc3339 pyirtoy pyserial google-api-python-client httplib2". Some of these are only available for Python 2 so we'll be sticking with that.
  • Clone this project from git: "git clone https://github.com/crleblanc/hackPump.git hackPump"
  • Congratulations, you're getting close.
  • If you don't already have a google account, you'll need one so you can use your the Calendar.

#Calendar Setup

  • Login to your google account and create a new calendar for this project or use an existing one.
  • This project doesn't use authentication so we need to make the calendar public so we can poll it. Go to 'settings' (it's the gear icon in the upper right corner of the calendar interface).
  • In the settings page, click on the 'calendars' tab, then click on the calendar you intend to use.
  • If it's not already public, click the 'share this calendar' link, check the box that says 'make this calendar public' and save.
  • Now click on the calendar to see it's details. Look for the 'Calendar ID', it should look similar to Calendar ID: [email protected]. Keep this ID around, we'll need it as the calendar_id parameter in conf.py.

#Recording IR Codes

  • Use the utility hackPump/hackpump/record_codes.py to record the IR codes from your remote to a JSON file. Type "record_codes.py -h" for help, the main options are -d for device name and -o for output JSON file. This will create a file we will use as the ir_code_file in the conf.py file.
  • This utility will ask for the name of the IR code to save, and ask you to press that button (once only). It will continue doing this until you have recorded all the codes you want.
  • If you made a mistake when recording a code, you can always record it a second time. This will replace the old code with the new one.
  • You can test these recorded codes with the script transmit_codes.py. If you can control your device receiving the IR codes with the IR Toy then your codes are working properly.

#Configuration

  • Modify the settings under hackPump/hackpump/conf.py to fit your setup. You'll probably have to modify the serial_device, calendar_id, ir_code_file.
  • Give it a try by running hackPump/hackpump/hack_pump.py. If it failed, you'll see error messages in the log. If you're up and running you can put this script in a cron job.

#Scheduling a Job With Cron

  • We're using cron to poll the calendar every 5 minutes. Use the following syntax to made a text file we can use with cron. */5 * * * * /home/pi/hackPump/hackpump/hack_pump.py Put this in the crontab by typing "crontab cronjobs". See what's in the crontab by typing "crontab -l" and remove the crontab by typing "crontab -r". Type "man crontab" for more info.

#Known Issues

  • The IR Toy occasionally drops from off as a device, so all future calls using the irtoy module fail. I'm not sure why this is but I'm trying to find out and come up with a fix. The error "tty_port_close_start: tty->count = 1 port count = 0." is usually seen in dmesg when this happens.
Clone this wiki locally