Compatible USB>I2C adapter for RPi4


I’d like to attach 18 or more GPIO panels 1-3meter away from Raspberry 4, so I will need 2-3 USB>I2C adapters. (All together I need 128 I/O ports or more for my house.)

Is there any recommendation what USB adapter board should I buy to get more I2C buses?
What IC of that is OpenHABian will be compatible with?
Thanks for any recommendation!

I would use a different tech - Modbus over RS485 wired serial. Dozens of devices over hundreds of metres.

I’ve already bought lots of I2C boards: :blush:
-8x 8IO and
-2x of 16IO
They were cheap and directly available from stock at Hungary. (Sadly I don’t have time to wait 3 weeks for a shipment from China… my smarthome system died by a lightning and I can not control ANYthing in my house now :frowning: )

Currently I need a quick solution to screw everything together within 1-2 meter distance.
(My Pi4 is in the room near the ceiling to keep it in 25C enviroment, but all the cables are at the attick above.)

Later, I’d like to enhance the system with 1-Wire temp sensors, and maybe other things…

RS485 seems to be a really good choice, but did not find too much special sensors yet other than I2C.
(IR, movement, NFC, nearing, …)

I can recommend this firmware on a Digispark. Is recognized as a normal i2c device under Linux.
And are very cheap to build :slight_smile:

or a DIY Version:

1 Like

Thank you very much for the links!
I’ve found those too yesterday, but didn’t believe it would be stable / possible to do this way…
I’ve digged into it a bit more, and found 2 problems with this solution:

  • There are no ATTiny45 boards available any more, only ATTiny85 ones. (ca. 4$ inc. VAT)
  • it gives 5V output, instead of 3.3V !!!
    … So I would also need a 5V>3.3V I2C conversion board from a shop which has this on stock. (Usually sold for 10$!)

I wonder why isn’t there any robust, “ready to use” = Plug&Play version of this in Europe at all?

I assume from the information you have given that you are using Mcp23017 and MCP23008 devices. These have 8 addresses that are usable, so you don’t need any external hardware to connect them.

I recommend you use some kind of buffer or level shifter for this. 1-3m of wire could draw high amounts of current and damage your Pi. Though you have already stated you don’t want to buy such things, but I have warned you.

There are 2 I2C buses on a Raspberry Pi, I2C0 is used for the HAT memory chip but can still be used by software. Just connect some to one bus and some to the other and make sure your addresses are set correctly.

You will need to pay special attention when making your cables. Bring only the SDA and SCL lines from the Pi, along with ground. Twist SDA and a ground wire together the whole length, and do the same with SCL with a different ground wire. You will need to connect the ground wires at the remote end as well. Use power at the remote end, don’t bring it from the Pi.

Thank you for all those tips, but I think you have misunderstood me. Such things are exactly what I would like to avoid! :blush:

What I meant is, that I’d like to use a SAFE, nearly “industrial solution”: :ok_hand:

  • No tiny wires, twisted and soldered
  • No direct Pi4<>GPIO pins

but a simple USB cable with a Plug&Play adapter at the end with standard 3.3V output to plug all those board one after the other. (To connect to Opto-couplers.)

This way, If something goes wrong, (like an other lightning,) I could simply unplug the device, and replace it in 5 seconds. (Instead of 3 weeks.)
Something like this one: (Click link).
if I would get confirmation that such a device would work out of the box without special Firmware flashing or wiring or any other complication. :slight_smile:

Now I understand the goal. The board you like will work if you write some software for it. You might look at my MQTTany software, you could write a module for USB-I2C devices like this. I can assist, or write it if I have time.

1 Like

Maybe this product would still be something for you. Also recognized as an I2c device under linux and the voltage can be set.

Many thanks you looked for it! :slight_smile:
Currently I’m waiting for delivery for 3 Digispark USB panels based on ATTiny85 chip.
They are really cheap ($4). link…
So I will try to flash that firmware you have suggested earlier.
I’ve convinced myself, that a bit of soldering and flashing is not the end of the word… :sunglasses:

What does it mean “DIY” version?


Just to save time for others who find this topic:

1.) gpio readall
will not work on Openhabian out of the box.

2.) Even if you success to install it from the original author:
… you will realized, it’s not maintained since 2019.aug:
So it will NOT work with newest RPi boards, like my Pi4B version 17.

3.) Found an alternative:
… but the newest version (74) can not be installed (compile error)

4.) Standard (repo) install works:
sudo apt-get update
sudo apt-get install pigpio python-pigpio python3-pigpio
… but that’s only version 71

5.) Found a Phyton script that should list my available ports:
… but is does not, because it has a syntax error at line 41.


That I’ve decided to give a try to MQTT … see my next post…

Dear Ivan,

I’m extremely impressed by your code and documentation! :sunglasses:

  • I wonder: Why isn’t it listed as ‘1 click installable binding’ at OH2 ?
  • What is the difference between the other MQTT bindings listed there?

After reading everything I had to realize:

  • it does not seem to support PCF8574 8GPIO I2C expansion boards. :frowning:

So I did not install it yet.

How much work would it be to enhance your code to be able to handle this board too?
Is it possible that you could do it and I would pay for it? If yes, how much would it cost me?
I’m not a rich guy at all (my programming rate is 10-15$/hour) but I don’t like to ask for favours for free.

Why those boards?

  1. Very cheap
  2. easy to connect 8 of them in a row
  3. has jumpers easy to change Address IDs 0-7
  4. Available at my County from stock
  5. Already bought 8 (need 64+48 I+O port. Later maybe more…)

Thank you! This is the first piece of software I’ve shared so I’m still learning, but I wanted to do it right.

It is not a binding, and not meant to be. It started as a small script to allow me to read and control GPIO pins on a Pi that was not running openHAB and has grown from there.

Probably not much. The code already exists for the MCP230xx chips so I would just need to copy that and change the parts that actually communicate with the chip.

I can do it no problem, but as for payment your help in testing the code will be enough. I probably won’t have time to do it until next weekend though.

1 Like

Dear Seers,
Today I was finally able to flash all 3 of the USBs.

I’ve plugged in 1 of them so far + a PCF8563 real-time-clock board + 1 pcf8574 board (8 I/O ports)

  • what’s next?
  1. Tried to edit /etc/modules-load.d/modules.conf
  2. but could not upload it back via SFTP :frowning:
  3. is that enough ? dtparam=i2c=on
  4. also tried to type into SSH promt:
    but “command not found”

out of ideas… toooo many infos on google, but all of them use RPi built-in pins.
Do not know how to step forward, please help! :wink:

The command is i2cdetect :wink:

:blush: yes, I know.! Mistyped here… but I’ve tried with the right syntax.
Can you maybe help me with the real problem? :wink:

… also I wanted to ask you about:

  • isn’t this MQTT thing slow?

Because I would like to use my 64 swiches for

  • dimmer LEDs up-down-up in real time by pressing it continouosly!
  • and use long-click on other things to execute different logic/behavior.
    (Maybe also double-click.)

For example:

  1. short click => FAN on for 10 minutes
  2. long click (>800ms) => FAN on forever

So it has to be able to handle these things in realtime on multiple Input ports on the same bus.

I’m not sure why the program wasn’t found, I thought it came pre installed in raspbian. Google would be the best place to find installation instructions for it.

Relatively speaking, yes. What you describe will not be possible. MQTT is not real-time like you need for that, but then again neither is openHAB.

That sound very bad! Obviously that would be the most important thing to accomplish.
Everything else is just “extra”.
Do you know about any “real scenarios”, how much delay it takes to handle long-dimming?

sudo apt install i2c-tools
The answer to your next questions is no, OH is not a real-time system. To handle long, short, double clicks etc. you may use microcontrollers or PLC.