Node-red-contrib-i2c how to initialize I2C bus

I am using Sequent Microsystem's 8relay board. It works perfectly using SM's cmd-line tool with an exec node in node-red.
But as I do not like command line integration, I rebuild the functionality of the cmd-line program using node-red-contrib-i2c and js. It works perfectly but I have to to call the cmd-line program once after rebooting my raspi before using my node-red flows. I assume, that the cmd line program does the i2c initialization.
how can a do this with node-red-contrib-i2c?

Which command do you have to issue after every reboot?

Some of the i2c modules are very dated and do not load correctly anymore. The one that does work well and is still actively supported is i2c-bus (contrib variant). But it does not have ability to do a i2c bus reset.

In fact that entire concept of a 'true' i2c bus reset is a bit in the shadows and misleading. The only way to truly reset the i2c bus when a slave has locked up the bus is to power down the bus, or if the coding is sufficient on the slave at some point it times out and releases the bus. A common thread is sending 9 clock flips to get everything to give up the bus, I have never got such working right, or consistently thus far.

Can you post what you are doing?

I am not sure I understand what you mean by initialization. I found it easier to add a transistor or simple GPIO pin controlled switch to the VCC line of the i2c setup, so I can effectively power down and up all the chained i2c devices on the given bus, and in effect do a bus reset. But this is only applicable to the slaves and not the master, if the master is stuck or hung, the owning microcontroller, i.e. Pi needs a reboot.

If I do a scan bus with node-red-contrib-i2c after reboot it returns empty.
After a read of relay 1 with the cmd-line-program the node-red-contrib-i2c scan returns the right adress of the 8relay board. Now node-red-contrib-i2c works perfectly.

In a sequent Microsystem c program they are doing a wiringPiSetup for exactly the board adress.
How can I access wiringPi from Node-Red?

I believe wiringPi is a C library for the Pi. I don't think you can access that from NR.
Howevr, if you have a command line program that initialises the i2c bus, why don't you run that from a command node at startup?

Weird, I have never had that specific issue.... of a blank scan from the i2c scan node, after reboot or NR restart. Oh, is the device showing UU for the expected address? initially? if so, some other driver or the kernel is trying to own i2c device. This can definitely cause issues with the i2c scanning or device acess.

this is what I am doing right now but I would prefer to have a JS only solution.

after carefully checking the c and python program I finally got it working. Please find attached main flow and 2 subflows.
main flow.txt (33.4 KB) sub flow status.txt (1.5 KB) sub flow switch.txt (1.7 KB)

Just for clarity... Flows are downloads, not inline exhibits because of the sizing limit on comments.

for my understanding this are downloads. I thought this will help people who are going to implement this 8 relay boards. Please explain how you would like to share such flows.

What you did is the only option, because inline presentation of flows is limited to a size control, imposed by the forum entries. Typically you insert the flows as an inline object. For example...

[{"id":"500b7256.41dddc","type":"inject","z":"6ce4f6d0.4b95f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":80,"wires":[["80809512.b43d88"]]},{"id":"80809512.b43d88","type":"debug","z":"6ce4f6d0.4b95f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":330,"y":80,"wires":[]}]

But if the flow is quite large, the forum will not let you post your flow in this format, manner.. So I commented on this, that your flows are beyond the size limit for inline presentation as exhibited above.

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