Node-red-contrib i2c : can it work with a i2c-gpio bus?

I understand that the i2c-contrib node doesn't permit the use of another bus than the default one which is /dev/i2c-1 on a Pi3 .

This node only works for newer version of Pi where the i2c driver is on /dev/i2c-1, or /dev/i2c-0 for a Pi rev 1.

For various reasons, I need to use the i2c-gpio overlay on my RPI to communicate with an i2c device, by default it creates a new bus called /dev/i2c-3

I tried to de-activate the default hardware bus "1" and to assign to the "i2c-gpio bus" the number 1 but it doesn't seem to work. I'm getting the following error when I try to send to command to my follower device. I'm not sure yet if it's because the format of the message is wrong or because the bus config is wrong :
"Error: ENXIO, No such device or address"

Can node-red-contrib i2c work with a i2c-gpio bus ?
Or is there a way to override the fact it handles only the first i2c bus of a RPi? There's probably a good reason for that.

Thanks :slight_smile:

Hmm - I think at one time it was the underlying library that caused this limitation, but it seems newer versions do not... so for a manual check you could try editing the file node-red-contrib-i2c/i2c/26-i2c.js lines 10, 40 and 119 to point at bus 3 and let us know if that works... If so we can look at making it an option in the config instead.


Thanks for your reply. @dceejay Yes, now it's working.
I've changed the values as you suggested. They now point to the bus 3.

node.port = I2C.openSync( 3 );

Yes, it would be great to have this option in node-red-contrib-i2c if it's possible. Thanks again.

1 Like

great - thanks for the confirmation.

1 Like

Sorry, I'm new to this forum (and to Node-red as well).

I'm wondering:
For additional questions about Node-red-contrib i2c, is it preferable to create individual topics in this forum or is it ok to create a more general "Node-red-contrib i2c: help" topic perhaps ?
Or do you prefer if the questions are posted directly in the Github repo of this node ?

Hi Welcome to Node-RED. Just start a new topic here.

1 Like

Hah, sorry, I should have been more clear. I meant start a new thread/topic here in this forum. Not open an issue, and not add to this thread. Ho hum, I'll move it when I get a keyboard

1 Like

Oh, sorry. My mistake.

I've ordered a logic analyzer for troubleshooting this issue.
I managed to communicate with the follower device but I had to send an array containing twice the value msg.payload = [m.port, m.value, m.value] (msg.byte set to three).
I will report back if I can solve or at least understand the cause of the problem.

Hi @nordseele - version 0.7.0 in npm should now allow you to pick the bus number within the i2c nodes - please give it a try and report back. Thanks


Thanks but, no it's not working unfortunately.
I've tried different values (1, 2, 3, 4) just in case. And I've also tested that my bus (number 3) is still working when the bus number is hardcoded (node.port = I2C.openSync( 3 );).

hi - ok - think I have it now - please retry 0.7.1


Hi, yes it's working with 0.7.1
Thanks !

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.