# I2c on OrangePi Zero

**URL:** https://discourse.nodered.org/t/i2c-on-orangepi-zero/21777
**Category:** Hardware
**Created:** [16 February 2020 09:31 UTC](https://discourse.nodered.org/t/i2c-on-orangepi-zero/21777 "2020-02-16T09:31:46Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![dzairo](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@dzairo](https://discourse.nodered.org/u/dzairo)
#### Post date: [16 February 2020 09:31 UTC](https://discourse.nodered.org/t/i2c-on-orangepi-zero/21777/1 "2020-02-16T09:31:46Z")

</div>

Hi all.  
I'm new .  
On my OrangePi Zero install OLED LCD.  
if list all device on my i2c bus show this :

```auto
i2cdetect -y 0
     0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

```

![OrangePi_i2c](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/1/c1230d41b0218390c7b7169150da4c82fa39ee35.png)

I install node-red-contrib-i2c  
how I can list all devices on my i2c bus??  
some example pls ..  
my bus is used 0 not 1

thanks

---

<div class="post-metadata">

### Author: ![homeplayer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/homeplayer/32/12388_2.png) [@homeplayer](https://discourse.nodered.org/u/homeplayer)
#### Post date: [17 February 2020 07:31 UTC](https://discourse.nodered.org/t/i2c-on-orangepi-zero/21777/2 "2020-02-17T07:31:20Z")

</div>

![i2c](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/4/9431aac76321597af569395998aa66188e14dbd9.jpeg)

```auto
[{"id":"a296b2f6.143b6","type":"inject","z":"95f61204.15452","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":624,"y":600,"wires":[["f57e2b0c.6cf508"]]},{"id":"f57e2b0c.6cf508","type":"i2c scan","z":"95f61204.15452","x":756,"y":600,"wires":[["869fbda3.677f4"],["502204e0.c7244c"]]},{"id":"869fbda3.677f4","type":"debug","z":"95f61204.15452","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":914,"y":576,"wires":[]},{"id":"502204e0.c7244c","type":"debug","z":"95f61204.15452","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":914,"y":612,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![dzairo](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@dzairo](https://discourse.nodered.org/u/dzairo)
#### Post date: [17 February 2020 08:10 UTC](https://discourse.nodered.org/t/i2c-on-orangepi-zero/21777/3 "2020-02-17T08:10:40Z")

</div>

this is result :  
 ![i2c_scan](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/1/0111cdfb091b2762ff242485eed4bf8471c66bc3.jpeg)

then on what bus search ?? 0 , 1 , or 2 ??

---

<div class="post-metadata">

### Author: ![homeplayer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/homeplayer/32/12388_2.png) [@homeplayer](https://discourse.nodered.org/u/homeplayer)
#### Post date: [17 February 2020 08:21 UTC](https://discourse.nodered.org/t/i2c-on-orangepi-zero/21777/4 "2020-02-17T08:21:26Z")

</div>

you need bus 1 per [node-red-contrib-i2c 0.5.2](https://flows.nodered.org/node/node-red-contrib-i2c)  
"Downside my nodes work only for newer version where the i2c driver is on /dev/i2c-1"

This is something i still need to try, [I2C For Everyone](https://tech.scargill.net/i2c-for-everyone/)  
maybe this could help

---

<div class="post-metadata">

### Author: ![dzairo](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@dzairo](https://discourse.nodered.org/u/dzairo)
#### Post date: [17 February 2020 08:50 UTC](https://discourse.nodered.org/t/i2c-on-orangepi-zero/21777/5 "2020-02-17T08:50:28Z")

</div>

hi.  
Orange Pi zero have two TWI port , 0 and 1 .  
My LCD is connected to 0 , but if connect to 1 and test node-red then work..  
will be good if user can select want port want use ..I can redefine .. my code for LCD for port 1 .. but still will be good if user can select what bus want use ..

regards.

---

<div class="post-metadata">

### Author: ![homeplayer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/homeplayer/32/12388_2.png) [@homeplayer](https://discourse.nodered.org/u/homeplayer)
#### Post date: [17 February 2020 09:22 UTC](https://discourse.nodered.org/t/i2c-on-orangepi-zero/21777/6 "2020-02-17T09:22:01Z")

</div>

I have just tested -  
"This is something i still need to try, [I2C For Everyone](https://tech.scargill.net/i2c-for-everyone/)"  
and it works, So there is you solution it will work on both busses

Let me explain;  
cd ~/.node-red/  
npm install i2c-bus  
node-red-stop  
sudo nano ~/.node-red/settings.js  
functionGlobalContext: {  
// os:require('os'),  
// jfive:require("johnny-five"),  
// j5board:require("johnny-five").Board({repl:false})  
//underscore:require('underscore'),  
i2c:require('i2c-bus'),  
},  
cntr o  
enter  
cntr x  
enter  
node-red-start

```auto
var i2c=global.get('i2c');
i2c1 = i2c.openSync(0);

node.warn(as())
function as() {
var info = i2c1.readByteSync(3c, 255);
i2c1.closeSync();
return info;
}

```

---

<div class="post-metadata">

### Author: ![dzairo](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@dzairo](https://discourse.nodered.org/u/dzairo)
#### Post date: [17 February 2020 10:05 UTC](https://discourse.nodered.org/t/i2c-on-orangepi-zero/21777/7 "2020-02-17T10:05:59Z")

</div>

Hi. I do it ..  
try function but not response from bus .. return info not see on debug ..  
I'm new nad don't good understand how node-red work ..then sorry..

---

<div class="post-metadata">

### Author: ![homeplayer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/homeplayer/32/12388_2.png) [@homeplayer](https://discourse.nodered.org/u/homeplayer)
#### Post date: [17 February 2020 10:36 UTC](https://discourse.nodered.org/t/i2c-on-orangepi-zero/21777/8 "2020-02-17T10:36:50Z")

</div>

The example i used is to read a chip in this case a pcf8574,

I think you need to write data to the oled screen, not read data from it.  
maybe this can help you [Display temp (18b20) on oled with just pi and nodered](https://discourse.nodered.org/t/display-temp-18b20-on-oled-with-just-pi-and-nodered/5426)

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [17 February 2020 10:37 UTC](https://discourse.nodered.org/t/i2c-on-orangepi-zero/21777/9 "2020-02-17T10:37:38Z")

</div>

> [@homeplayer](#):
>
> sudo nano ~/.node-red/settings.js

Don’t run this line with sudo, a normal `nano ~/.node-red/settings.js` is fine. By editing as sudo, the file becomes owned by root after saving, meaning node-red running as the current user (as `~/.node-red` suggests) might have trouble reading it, thus leading to running node-red as root too to get around. Just don’t use sudo here.

---

<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: [17 April 2020 10:37 UTC](https://discourse.nodered.org/t/i2c-on-orangepi-zero/21777/10 "2020-04-17T10:37:43Z")

</div>

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