Accessing GPIO on PI 4

Hi,
I am trying to get data from a MPU6050 motion sensor, which is connected to my Pi 4 via the GPIO-Pins (I'm pretty sure, that it is wired correctly as reading the information with a python script is possible). However, I can't read anything with Node-RED which runs in a container in my pi. Using "pi-gpiod in" from "node-red-node-pi-gpiod" I either get OK if I don't read the initial state or 1 once if I read the initial state. In some videos I saw, that the input should change to 0 if I disconnect the corresponding cable but in my case it always stays at 1.
If my general approach is flawed in some way, I am open to alternate suggestions.

@DonkeyKong Welcome to the forum!

  1. What OS are you running on the Pi?
  2. what version of NR and node.js are you running? (you can get this from the NR startup log)
  3. To be clear, you are running nine-red Docker...correct?

Thanks for your answer.

  1. I'm running updated Pi OS (Kernel version 6.1)
  2. NR 3.1.3 and node.js v16.20.2
  3. I'm very bad at docker which is why I use IOTstack to manage my containers (I intend to display the sensor data in a Grafana-Dashboard later so I'm running a few containers with IOTstack)

In that case why are you using Docker?

Did you make sure that pigpiod is installed as mentioned in the requirements?

There are a few other things running on the pi and I wanted to reduce the chance of things breaking each other. Also thanks to IOTstack I did not have to do anything related to docker as it does most things for me.

But do you do that from inside the container?

You do know containers typically isolate software from the OS & hardware and to do things like hardware access often requires specific setup.

To rule out the container, just install node-red natively. There is a quick and easy installer script that does all the hard work for you.

Yes, I also startet pigpiod with "sudo pigpiod". Otherwise I get a connections refused from the pins.

I have now installed Node-Red without a container and the nodes behave the same way. If I disconnect a cable the states still stay at 1 and I don't get any data. Maybe my general understanding of these nodes is wrong and I have to get the sensor data to Node-Red another way?

I've lost track after 17 days.

Lets recap:

  1. Do you get any state change at all (i.e. do these nodes work when the cable is connected and you operate the device)?
  2. When using Python, do the values instantly update to 0 when you disconnect cable?

Where is this video? did they provide wiring instructions and sample flow that you followed?

Alternatively, have you tried this flow: Read an i2c-based mpu6050 accelerometer on a raspberry pi (flow) - Node-RED

Alternatively 2, this node node-red-contrib-mpu6050rpi (unpublished on NPM) could be tried (you would need to do npm i jeanole/node-red-contrib-mpu6050rpi from inside the .node-red directory)

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