# Any idea ? raspberry4 with node-red-contrib-i2c gets different values on some registers

**URL:** <https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650>\
**Category:** General\
**Created:** [22 April 2022 16:06 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650 "2022-04-22T16:06:34Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![luck0r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/luck0r/32/60467_2.png) [@luck0r](https://discourse.nodered.org/u/luck0r)\
**Post date:** [22 April 2022 16:06 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/1 "2022-04-22T16:06:34Z")

</div>

Hey Guys,

maybe some one has an idea. I have some commands i send send out (2 of 20) and get the correct value from. If i use i2cget i get the correct value for all commands. Example 🙂  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/4/f4e79aeb0ef5a16ec2b43df5de59096bab2cf913.png)

The buffer is 0, 0 is this wrong:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/4/74e1d7a91000d63f3d4b03874d75027114f8554d.png)

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [22 April 2022 16:48 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/2 "2022-04-22T16:48:56Z")

</div>

Welcome to the forum!

Can you tell us which sensor you are reading, and also post your flow?

---

<div class="post-metadata">

**Author:** ![luck0r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/luck0r/32/60467_2.png) [@luck0r](https://discourse.nodered.org/u/luck0r)\
**Post date:** [22 April 2022 17:12 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/3 "2022-04-22T17:12:55Z")

</div>

im reading from an Battery Managementsystem over i2c (sm-bus) here is the flow:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/d/dd993295b1b80bd0c8330bec3d3566a12a87f3ff.png)

this is the same for all commands: in the node on the left thier is the command which goes in this code msg.command  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/e/ae1d17c7b17732cdbeabe070704cfc5c5263ab32.png)

if i use it on i2cget it works. but in node red only the top two, Temperature and Voltage gives me numbers which are correct

---

<div class="post-metadata">

**Author:** ![luck0r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/luck0r/32/60467_2.png) [@luck0r](https://discourse.nodered.org/u/luck0r)\
**Post date:** [22 April 2022 17:17 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/4 "2022-04-22T17:17:11Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/5/45717bd704a932f0ac5b65ab288b03ce405c82f6.png)

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [22 April 2022 17:19 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/5 "2022-04-22T17:19:23Z")

</div>

If the trigger nodes are all set to the same period you are probably getting conflicting requests on the i2c bus. Try querying the sensors one after the other, not in parallel.

---

<div class="post-metadata">

**Author:** ![luck0r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/luck0r/32/60467_2.png) [@luck0r](https://discourse.nodered.org/u/luck0r)\
**Post date:** [22 April 2022 17:22 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/6 "2022-04-22T17:22:01Z")

</div>

i did turn the interval off before, that didnt help. but i will restart the raspi and try without again.

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [22 April 2022 17:27 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/7 "2022-04-22T17:27:47Z")

</div>

You could also try deleting all the inject nodes except the first and connect the output of the first  
i2c node to the input of the second and so on so that the i2c nodes read in series.

---

<div class="post-metadata">

**Author:** ![luck0r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/luck0r/32/60467_2.png) [@luck0r](https://discourse.nodered.org/u/luck0r)\
**Post date:** [22 April 2022 17:37 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/8 "2022-04-22T17:37:10Z")

</div>

okay, good idea. But my problem stays the same, i remove the interval and clicked on the RSOC buttom, then i get 0,0. after that tryed temp buttom that worked. but on shell i get all the correct values

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/8/389aea72b9b6468c979a4949d215b9b018714661.png)

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [22 April 2022 17:40 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/9 "2022-04-22T17:40:04Z")

</div>

Is the i2c node connected to the RSOC inject node configured properly?

---

<div class="post-metadata">

**Author:** ![luck0r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/luck0r/32/60467_2.png) [@luck0r](https://discourse.nodered.org/u/luck0r)\
**Post date:** [22 April 2022 17:40 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/10 "2022-04-22T17:40:57Z")

</div>

Yes, they all the same:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/1401e52e2ddabe1b203c7ceb2522a4bdc59d07c6.png)  
they get msg.command from the injects

---

<div class="post-metadata">

**Author:** ![luck0r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/luck0r/32/60467_2.png) [@luck0r](https://discourse.nodered.org/u/luck0r)\
**Post date:** [22 April 2022 17:47 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/11 "2022-04-22T17:47:45Z")

</div>

i created an new flow with only one inject and one i2c. but still the same 😕

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [22 April 2022 18:00 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/12 "2022-04-22T18:00:05Z")

</div>

Instead if the i2c node try an exec node and send the command as you do from the command line using i2cget, see what you get back.

use **-y**

Disable interactive mode.

---

<div class="post-metadata">

**Author:** ![luck0r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/luck0r/32/60467_2.png) [@luck0r](https://discourse.nodered.org/u/luck0r)\
**Post date:** [22 April 2022 18:05 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/13 "2022-04-22T18:05:39Z")

</div>

yeah i had the same idea but its an ugly workaround isnt? But its working see here:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/6/f6e2cee0cb7e833d509c5a5b908fc9cf67e83a11.png)

---

<div class="post-metadata">

**Author:** ![luck0r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/luck0r/32/60467_2.png) [@luck0r](https://discourse.nodered.org/u/luck0r)\
**Post date:** [22 April 2022 18:07 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/14 "2022-04-22T18:07:14Z")

</div>

i want to read 10-15 values per second 😃 not sure if its good to exec that much prosecces with node red

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [22 April 2022 18:08 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/15 "2022-04-22T18:08:33Z")

</div>

I very much doubt that the sensor will react that quickly at all! Even not using node-red.

---

<div class="post-metadata">

**Author:** ![luck0r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/luck0r/32/60467_2.png) [@luck0r](https://discourse.nodered.org/u/luck0r)\
**Post date:** [22 April 2022 18:25 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/16 "2022-04-22T18:25:18Z")

</div>

i think i will raise a report issue on github, looks like the problem is in the i2c module / nodejs and not an i2c problem

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [22 April 2022 18:27 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/17 "2022-04-22T18:27:51Z")

</div>

Good, the exec node workaround will probably keep you going, but not at the speeds you quoted I suspect.

---

<div class="post-metadata">

**Author:** ![luck0r](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/luck0r/32/60467_2.png) [@luck0r](https://discourse.nodered.org/u/luck0r)\
**Post date:** [25 April 2022 10:12 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/18 "2022-04-25T10:12:37Z")

</div>

Yeah, it works. By the way, if anyone has also these problems here is my bugreport:

> <https://github.com/nielsnl68/node-red-contrib-i2c/issues/45>
>
> Hey,
> 
> i have this flow and i can read Temperature and Voltage correct from my …Battery management over (i2c/smbus). But all other (10 commands ) give me wrong results in node-red-contrib-i2c. in i2cget i get the correct values all the time.
> Please see this example:
> !\[image\](https://user-images.githubusercontent.com/67522404/164773635-674998a5-e8b1-44f8-a45f-26a0f3a946a4.png)
> 
> node red v2.2.2
> node --version
> v16.14.2
> node-red-contrib-i2c 0.9.0

---

<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:** [24 June 2022 10:12 UTC](https://discourse.nodered.org/t/any-idea-raspberry4-with-node-red-contrib-i2c-gets-different-values-on-some-registers/61650/19 "2022-06-24T10:12:53Z")

</div>

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