Node-red-contrib-i2c -- assistance

Hi Folks, New to Node-Red and I2C. I installed node-red-contrib-i2c on my Raspberry Pi 4 running Bullseye the debug displays "empty" using the scan node. The I2C has been enabled.

Can you scan the inc bus from a terminal window? Try running this command:
sudo i2cdetect -y 1

What do you get back?

Yes, “sudo i2cdetect -y 1” return the following. UU is a Pi-Plates POWERplate real time clock.

just took a look on a Pi4 running Buster and it works fine. I'm now upgrading it to bullseyeand will test it when It finishes installing. (first thing tomorrow morning)

Well I've got bullseye installed and both the i2cdetect and I2C scan node works:

pi@raspberrypi:~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- 76 --                         

What I2C device do you have attached to the Pi?

(The UU seems to be allocated by a kernel driver for a Wolfson audio device)

Thanks for the assistance

I have a POWERplate connected. Please look at the documentation section, I followed the real-time clock instructions.

https://pi-plates.com/power-plate/

Following the instruction the number changed to UU.

This just went above my pay grade (grin). I suspect the device tree overlay
dtoverlay=i2c-rtc,pcf8523
is the cause of the issue.

What do you want to use I2C with that device for? To read the RTC clock? If so you shouldn't need I2C, the timestamps in NR should be what the RTC is feeding to the operating system. So an inject node settng msg.payload to timestamp should be accurate.

Thanks for your assistance. I am now able to use the SCAN function and I can see all the attached devices. How to I interact with the devices? Can you post an example?

Not having that device it would be a bit difficult don’t you think?
What have you tried so far?

What devices do you have ?

As far as I can tell the power plate has some python code to control / monitor it's features. But these do not comunicate over i2c port.

I would suggest you follow the product instructions to install and setup the relevant python software.

There are some nodes to communicate with Pi-Plates, but I cannot see anything specific to the power plate.
contrib-pi-plates

One thing you might want to try is flashing another SD card with buster and see if that would work. There seems there might be an issue with i2c and node.js v14

Take a read of [UPDATE] node-red-contrib-ezo: v1.4.0 - #4 by MaddyP

Looking at the docs, i2c is only used for the RTC and as such you really shouldn't be interacting with it directly from Node-RED.

You load the correct Linux Kernel module and that's it, It will then make sure the clock is always right (with a minimal degree of drift) when ever the pi is powered back on and before it can (or if it can't) connect to a network time server.

The UU in the i2cdetect output shows that the RTC has been claimed by the kernel and as such is unavailable to do anything else with.

There is nothing useful you can to with a RTC directly from Node-RED really.

Everything else on that board is controlled via the SPI bus.

2 Likes

To get started with I2C in Node-Red I would like to do something very simple like a switch.

I got the following !@C switch. I can see it with the SCAN node.

SparkFun Qwiic Button - Green LED

https://www.sparkfun.com/products/16842

Just need assistance with get this to work. Once I got this worked I can add more advanced devices.

I have five PI-Plates running with all functions available on all boards.

So have you looked at this node ?

I don’t want to sound patronising but obviously I don’t know what your knowledge level is :wink:

But i2c is basically a wiring standard rather than a communication protocol.

So while many devices can communicate over the i2c bus they require their own specific drivers in order to send and receive the correct information.

It looks like there is Python software you need to install and use, which is designed to communicate with all of the iplate devices.

If you install this and get it working correctly, then you can install the node-red-contrib-pi-plates nodes.

This should allow you to get information to and from the pi-plate devices, but as described in the node info, these make use of underling Python code.

So in short to use the pi-plate kit you do not need to worry about i2c ! (unless you have the skills to write your own drivers for each device)

Hi, very much appreciate the assistance.

My skill level is very, very novice. Here is a summary of what I have accomplished so far:

  • RPI 4 B is running Bullseye without issues.
  • Have the following Pi-Plates installed in a stack: (1) DAQCplate, (2) RELAYplate, (1) POWERplate
  • All Pi-Plates are functioning very, very well. Very nice nice boards.
  • Have created a Node-Red Dashboard (2nd photo) and tested I/O functions, they work great!

I want is use I2C for additional sensors. The Node-red-contrib-i2c scan function correctly identifies all I2C boards I have in the chain.

I am not sure how to send commands and receive data using the Node-Red Node-red-contrib-i2c.

Just need a working example to move forward. Do I use Pyton in the nodes, or Java?

Thanks

Here is an updated dashboard and the !2C scan in the debug.

OK looks like you are making progress :wink:

To use i2c sensors with Node-red, other than the ones covered by the pi-plate nodes, you would need to check if there are nodes for the sensors you want to use.
As I mentioned each sensor has its own protocols, if there isn't a node for the sensor then you would need to create your own (not really a beginner task!)

If there are Python drivers etc then you may be able to interact with them via an exec node, or even modify the Python to send values via MQTT. (again this may not be easy)

I would have a think about what types of sensor you need and then look to see what nodes are available.

A few examples

ads1x15_i2c
mcp23008
digital-light-sensor
bme280