Node-red-contrib-i2c fails to install

Is there an alternative to node-red-contrib-i2c for getting conductivity and pH readings into node red using my pi? Maybe a function node with a few clever lines of java to grab the reading, is this something possible?

You seem to have i2c working on your machine

But to REALLY use it, you have to understand how to communicate with your particular i2c device

They are all different and you have to study the chip makers information

So, you are saying that 'node-red-contrib-i2c' does not work currently, but if I learn the i2c protocol, and how my chip responds to it I would be able to make a function node with java that would get the readings?

No - it looks like you have it working :slight_smile:

Yes

No :slight_smile:

Function nodes use javascript - not java - they are too completely different programming launguages that share the word java :slight_smile:

Thanks for the clarification, sorry to show my ignorance. Indeed I meant javascript :smiley:

So, let me know if my logic has left the building.

My conductivity chip is at address 100, looking at the documentation for the chip I need to send the command 'R' to address 100 to get a reading back. I cannot insert anything but numbers into the command box in the 'i2c in' node. My only guess is that this is ASCII, so an 'R' would be 082.

However when I use 'node-red-contrib-i2c' to send 082 to address 100 I get 255 returned, which is code for no data to send.

Also, most of the commands are multi-character and the input box only takes 0-255.

I think I'm missing something here, but c'est la vie

I've been a complete idiot with my new install :rofl:

image

Spot the mistake

Starting again with new image - will report back :slight_smile:

Lets start again :slight_smile:

Just installed new image- installed Node-RED (which now comes with node 12.13.1)

Tried
npm install node-red-contrib-i2c
it failed (as before)

Tried
npm install https://github.com/nielsnl68/node-red-contrib-i2c.git

It installed i2c-bus@4.0.11 and node-red-contrib-i2c@0.5.5

And it seems to work (does a successful scan) :slight_smile:

1 Like

So we just need niels to push that version to npm ?

That's what I think (In fact I posted that on the issue on github about 20 mins ago) :slight_smile:

Its all seems to fully work with me using an i2c Pi add-on board (4tronix PiCon Zero)

I can configure inputs to read anlog values and I can make an output switch between 1 and 0 to control a LED
image

:slight_smile:
Logic looks OK (but this i2c node is not very user friendly)

Can I suggest starting a new thread on your specific problem (as this one is about getting the node working at all) and we can go into detail there?

That makes sense.

new topic : Pulling readings from i2c chip into Node-Red

Are you referring to Java or JavaScript? In any case, if you want to write in C, it isn't hard to link your code to Node-RED.

I use to put cpu performance code into the Korn Shell. I just would like to revisit a discussion I had with Bill about pulling in optimized hardware code functions outside the run time compiler.

Anyone got any ideas how to avoid the run time compiler to use some of the better written optimized i2c C functions. I keep seeing issues related to munging up the i2c bus due to timing mismatches.

As a long-time writer of device drivers, I agree it would be madness to rely on any kind of JIT for low-level device access. However the "-contrib-i2c" node appears to have all its driver interface functionality in C++, so possibly the timing issues are coming from the interop layers.

I'd suggest contacting the node's author to see if there are any timing or usage constraints which you might be running into. If that doesn't work out, then you could possibly write a custom node, moving any timing-critical logic into C/C++, and accessing the I2C driver directly.

Has anyone actually done any raw i2c testing on the Pi? It may well be that performance isn't terribly hot anyway.

Remember, the Pi was designed for teaching not for industrial use. The GPIO design on the Pi is actually rather weak I believe.

Certainly, I've never even bothered trying since a general purpose OS like Linux doesn't really sit all that well with the near real-time requirements of GPIO. I've always found it a lot easier to use an Arduino or ESP8266/ESP32 for hardware interfaces. Even though it meant that I've had to learn some C/C++ along the way.

I regularly see people struggling with the Pi GPIO and resorting to Python to try and get things working but this stuff is so cheap now that a couple of dollars spent on an ESP8266 seems like a no-brainer.

1 Like

Linux and Windows are definitely not real-time operating systems, but carefully designed kernel-level device drivers should be able to handle the requirements of even quite demanding devices. The question of where you draw the divide between driver and user functionality is crucial though, and if you leave any kind of time-critical stuff to the user level it will almost certainly fail at some point. (I speak from experience :wink:)

Indeed - I've gone down this route extensively, and nearly all my devices are/will be ESP8266-based, using MQTT to communicate.

That said however, an RPi, if it's not overly loaded with a mass of other tasks, should easily be up to running I2C and Node-RED together. It would be interesting to see some performance tests on various models with similar software setups...

Molesworth, contrib-i2c is using i2c-bus for the low level. Where are you seeing C++ in contrib-i2c?

I now see where i2c-bus has its cc files and plan on exercising them once I can get contrib-i2c to show up in node red console.

My local NPM list it properly installed, but I can see the nodes in node-red. Any ideas as to how to fix this?

node-red-contrib-i2c still needs to resolve the GIT version with the NPM version so I can pull it in to the palette within the console and not with NPM on the command line.

One other thing NPM seems to stop processing the flows after 18-36 hours. Is there any issue with the virtual machine size? This looks a lot like java running out of space. On RPI I think there is a 256 value set I haven't looked into. Not that I'm not an expert on this, but I would like to know if this is known before wasting time looking at this, once I figure out how to get some sort of working dtrace package.

40 years of reading opcode...Woohoo....

The page for node-red-contrib-i2c has a section at the bottom which notes :

And includes a link to the Github repo - https://github.com/fivdi/i2c-bus - which is the driver interface I was meaning. The node itself will be using an interop layer between C++ and Javascript, which is likely where the performance hit comes from.

1 Like

So, you are saying that 'node-red-contrib-i2c' does not work currently, but if I learn the i2c protocol, and how my chip responds to it I would be able to make a function node with java that would get the readings?

"YES" If we can get node-red-contrib-i2c updated from 0.5.2 to 0.5.5 on the NPM server. Its out of date