I2C Encoder

Connect up to 16 encoders on Arduino or ESP8266 board on the I2C bus!

Similar projects worth following
The I2C Encoder is a small board where you can use a classical mechanical encoder with a I2C bus. The device includes also the possibility to add a bi-color LED and set luminosity trough the I2C bus. It’s possible to connect up to 16 boards in cascade and read all of them with the same I2C bus.

If you need to add some rotary encoder to your project, the I2C Encoder is the right choice!

Reading a rotary encoder is not easy task, you need at least 2 interrupt pins for each encoder. When you need to add more than one encoder, it becomes more complicated to achieve accurate reading.

I2C Encoder not only solves such problems, it also has more features as following:


  • I2C bus working up to 400kHz, with possibility to enable the pull-up resistor
  • Possibility to connect 16 encoders on the same I2C bus, by setting the addresses with 4 SMD jumpers
  • Possibility to add a bi-color LED and setting a 8 bit PWM value
  • Open-drain Interrupt output pin, so no need to continuously polling the devices 
  • Easily chainable thanks to the connectors on the left and right sides
  • Any type of rotary encoder fits
  • It can read in X1 and X2 modes. This can be useful with the encoder without detent
  • 32 bit counter with also MAX and MIN thresholds
  • Voltage range is 2.5V to 5V
  • Possibility to customize the internal FW

More details

The I2C Encoder is powered by the microcontroller PIC 16F15323. It is a cheap microcontroller but it has 2 very important pheripherals that are essential to this project. It has 4 CLC peripherals and dedicated I2C pheripheral.

The board dimension is just 26,2 x 30,2mm

There are 2.54mm of 5 pin headers on the right and on left sides. So it is possible to solder directly the wires or a connectors. There is the space for the encoder in the middle of the board. On the top of the encoder, there is the possibility to solder a LED: single color LED or a bi-color common anode LED.

On he bottom side of the board, there are the 4 SMD jumpers, A0 to A3 for selecting the address. There is also the SMD jumper P-UP for enable the I2C pull-up resistors, in case that your master I2C doesn't have one.

The I2C Encoder has 16 register that user can read and write:

0x00General configuration
0x02Counter Value Byte 4
0x03Counter Value Byte 3
0x04Counter Value Byte 2
0x05Counter Value Byte 1
0x06Counter Max Byte 4
0x07Counter Max Byte 3
0x08Counter Max Byte 2
0x09Counter Max Byte 1
0x0ACounter Min Byte 4
0x0BCounter Min Byte 3
0x0CCounter Min Byte 2
0x0DCounter Min Byte 1
0x0ELED A intensity
0x0FLED B intensity


I already prepared an Arduino library (soon on github), here is one simple example.

In this example, i want my variable counter between -10 and 10. When it reaches the limit the LED will blink red in case of minimum and will blink green when it reaches the maximum.

Here is the code:

#include <Wire.h>
#include "i2cEncoderLib.h"
const int IntPin = 12;
i2cEncoderLib encoder(0x30); //Initialize the I2C encoder class with the I2C address
int32_t counter;
uint8_t encoder_status;
void setup(void)
  pinMode(IntPin, INPUT);
  Wire.setClock(400000) ; //Set I2C speed at 400kHz
  Serial.print("Encoder Test!!\n");
  encoder.writeMax(10); //Set maximum threshold
  encoder.writeMin(-10); //Set minimum threshold
void loop() {
  if (digitalRead(IntPin) == LOW) {
    encoder_status = encoder.readStatus();
    if (encoder_status != 0) {
      if ((encoder_status & E_PUSH) != 0) {
        Serial.println("Encoder Pushed!");
      if ((encoder_status & E_MAXVALUE) != 0) {
        Serial.println("Encoder Max!");
      if ((encoder_status & E_MINVALUE) != 0) {
        Serial.println("Encoder Min!");
      counter = encoder.readCounterByte(); //Read only the first byte of the counter register
      Serial.print("Encoder: ");
      Serial.println(counter, DEC);

And here is the result:

I will put all the documents on github in these days. You can find product datasheet on this project file, and the product will be available on my Tindie Store...

Read more »

EncoderI2C HW v1.2.pdf

Datasheet update with the HW version 1.2

Adobe Portable Document Format - 4.61 MB - 11/22/2017 at 22:58


Adobe Portable Document Format - 3.92 MB - 10/22/2017 at 09:31


  • I2C Encoder V2 will come soon!

    Saimon04/08/2018 at 21:21 0 comments

    We are currently working on the second version of this board.

    Here there are more details:

  • New HW release!

    Saimon11/22/2017 at 22:57 0 comments

    First of all this product is on sale on Tindie !

    Second, i made a new HW release with the I2C pull-up issue resolved. 

    For resolving the problem i just split the P-UP jumper in two.
    I already update the documentation on GitHub.

    I also made a very useful bed of nails for programming and testing the boards.

    For the testing purpose i used an Arduino board that simulate the encoder rotation, the address jumpers and check the LED voltage.

  • I2C pull-up issue

    Saimon10/22/2017 at 09:38 0 comments

    Thanks to the community i found a problem on the i2c pull-up resistor.
    When the P-UP jumper is open, the two resistors are in parallel to the SCL and SDA pins, which causes problem on the bus. 
    The solution is simply remove them when pull-up resistors are not used.

    My appreciations to the hackaday community!

  • GitHub repository and Tindie insertion

    Saimon10/21/2017 at 16:02 0 comments

    I created a GitHub repository, here you can find all the documentation about the project.

    I'm selling this board on Tindie, everyone around the world is welcomed to buy it !

View all 4 project logs

Enjoy this project?



fpgiovanini wrote 05/10/2019 at 13:56 point

Hi Saimon 

You told me that pickit 3 is suitable to program the pic16f18345 for the i2c encoder.

when I tried to burn the pic the message NO SUPPORTED DEVICE (ID=3020) APPEARED.

Do you please have any sugestion about this.tks fernando-brazil

  Are you sure? yes | no

Saimon wrote 05/10/2019 at 14:13 point


I'm 100% sure that the pickit3 is supported because i'm using it with Mplab X last version. Check also here:

You are sure that you are using an original pickit 3 ? and not some clone or the pickit 2.
I have see some fake pickit 3 that are very similar to the original one.

  Are you sure? yes | no

rafununu wrote 10/19/2017 at 11:00 point

It isn't on your Tindie store !

  Are you sure? yes | no

Saimon wrote 10/20/2017 at 09:21 point

Hello, we already submitted on Tindie! I guess it'll be available this evening or tomorrow. Thank you for your interest!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates