Code Monkey home page Code Monkey logo

ir2i2c's Introduction

I2C slave for IR decoding

License Build Status

Introduction

A simple I2C slave running at an attiny85 for decoding IR signals.

The idea came when I wanted to control using IR an arduino and I found out that IR decoding would take an extremely big amount of time. Thus I came up with using an attiny85 that would decode IR signals, buffer them, and would be controlled using I2C. There is also support for sending an interrupt whenever a new signal is decoded.

Compilation

There are several options that you can change.

  • PIN_IR: This is the pin where the signal output from your IR receiver is connected.
  • PIN_INT: This is the pin that will be brought high every time a new signal is decoded.
  • INT_DELAY: The amount of time in msec that the pin will be brought high.
  • BUF_LEN: The length of the circular buffer than will store received IR signals.
  • I2C_ADDR: The address of the I2C slave.

Most probably you will only need to change the address of the I2C slave, if there is another I2C slave with the same address.

If you only plan to use a specific type of remote, you can also change the supported decoders at lib/IRremote/IRremote.h.

Usage

There are 5 different registers you can read and write to perform different funtions:

  • 0x01: Reading from this register will return a single byte which is the amount of decoded signals in the buffer.
  • 0x02: Reading from this register will return the next signal. The signal is encoded as 5 bytes. The first byte is the type and the rest are the value sent with the most significant byte first. For type and value, also check the IRremote library
  • 0x03: Writing the value 0 to this register will disable sending an interrupt using pin PIN_INT, and any other value will enable it. By default interrupts are disabled.
  • 0x04: Whenever an interrupt is sent due to a received signal, a flag is set that will block more interrupts from being sent until a signal is read. Writing this register will allow you to clear this flag, and start sending interrupts again.
  • 0x05: Writing this register will reset the decoder.

Notes

I have made several tests, and I had no problems using this library. Some decoding errors were also there when using the IRremote library at an arduino.

Most of my tests showed that the device performs better when using an 16 Mhz clock. You can enable the internal high frequency PLL clock by setting the following values for the fuses:

  • lfuse: 0xc1
  • hfuse: 0xdf
  • efuse: 0xfe

For avrdude, you should add the following options:

-U lfuse:w:0xc1:m -U hfuse:w:0xdf:m -U efuse:w:0xfe:m

If you use a NEC remote control, the REPEAT code is translated to the previous IR received.

Furthermore, I found it to be more stable if you add a small delay after the endTransmission() and before the requestFrom() call. For example:

Wire.beginTransmission(0x10);
Wire.write(byte(0x01));
Wire.endTransmission();
delay(10);
Wire.requestFrom(0x10, 1);

License

The code is licensed under the BSD 3-clause "New" or "Revised" License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.