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

**URL:** https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836
**Category:** General
**Created:** [23 June 2020 18:51 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836 "2020-06-23T18:51:52Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![nordseele](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nordseele/32/23927_2.png) [@nordseele](https://discourse.nodered.org/u/nordseele)
#### Post date: [23 June 2020 18:51 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836/1 "2020-06-23T18:51:52Z")

</div>

Hi,  
I understand that the [i2c-contrib](https://github.com/nielsnl68/node-red-contrib-i2c) 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](https://github.com/fivdi/i2c-bus/blob/master/doc/raspberry-pi-software-i2c.md)** 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 🙂

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [23 June 2020 22:10 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836/2 "2020-06-23T22:10:43Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![nordseele](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nordseele/32/23927_2.png) [@nordseele](https://discourse.nodered.org/u/nordseele)
#### Post date: [24 June 2020 11:31 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836/3 "2020-06-24T11:31:39Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [24 June 2020 11:38 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836/4 "2020-06-24T11:38:58Z")

</div>

great - thanks for the confirmation.

---

<div class="post-metadata">

### Author: ![nordseele](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nordseele/32/23927_2.png) [@nordseele](https://discourse.nodered.org/u/nordseele)
#### Post date: [24 June 2020 17:35 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836/5 "2020-06-24T17:35:07Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [24 June 2020 21:36 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836/6 "2020-06-24T21:36:21Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [24 June 2020 23:01 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836/8 "2020-06-24T23:01:24Z")

</div>

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

---

<div class="post-metadata">

### Author: ![nordseele](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nordseele/32/23927_2.png) [@nordseele](https://discourse.nodered.org/u/nordseele)
#### Post date: [25 June 2020 17:47 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836/9 "2020-06-25T17:47:39Z")

</div>

> [@dceejay](#):
>
> I meant start a new thread/topic here in this forum.

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.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [25 June 2020 22:07 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836/10 "2020-06-25T22:07:06Z")

</div>

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

---

<div class="post-metadata">

### Author: ![nordseele](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nordseele/32/23927_2.png) [@nordseele](https://discourse.nodered.org/u/nordseele)
#### Post date: [26 June 2020 17:52 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836/11 "2020-06-26T17:52:27Z")

</div>

Hi,  
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 );`).

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [26 June 2020 20:32 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836/12 "2020-06-26T20:32:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![nordseele](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nordseele/32/23927_2.png) [@nordseele](https://discourse.nodered.org/u/nordseele)
#### Post date: [27 June 2020 10:23 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836/13 "2020-06-27T10:23:41Z")

</div>

Hi, yes it's working with 0.7.1  
Thanks !

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [11 July 2020 10:23 UTC](https://discourse.nodered.org/t/node-red-contrib-i2c-can-it-work-with-a-i2c-gpio-bus/28836/14 "2020-07-11T10:23:42Z")

</div>

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