fivdi / i2c-bus

I2C serial bus access with Node.js
MIT License
348 stars 57 forks source link

Update README.md #108

Closed PizzaProgram closed 2 years ago

PizzaProgram commented 2 years ago

Changing directory to .node-red is a MUST before installing. Wasted 2 days to find this out.

fivdi commented 2 years ago

The i2c-bus Node.js module doesn't have anything to do with Node-RED, other than that it can be used from Node-RED.

As such, while it may be necessary to execute npm i i2c-bus from within the Node-RED directory, in a Node-RED context, it is not generally necessary to call npm i i2c-bus from within the Node-RED directory.

Adding the suggested statement to the installation instructions would cause confusion to everyone who doesn't use Node-RED. The statement would be incorrect everywhere, except in a Node-RED context.

I'm afraid I can't accept this PR. It would be more appropriate to mention this limitation somewhere in the Node-RED documentation, if it isn't mentioned there already.

fivdi commented 2 years ago

Perhaps it should be mentioned in this repository https://github.com/PizzaProgram/mcp23017-pfc8574-aio ?

PizzaProgram commented 2 years ago

Ohh... sorry, I did not know it can be used from outside Node-Red. But still, many of us Node-Red beginners buy I2C devices as start-setup to build the first project, so it would be important somehow to notify them.

How about splitting the installation part into 2? Something like:

Installation for Node-Red

cd .node-red
npm i i2c-bus

Installation for other

npm i i2c-bus

I'd like to spare alllll the trouble I had for the other people....

fivdi commented 2 years ago

Which Node-RED Node were you trying to install?

fivdi commented 2 years ago

I'm not familiar with Node-RED, but my assumption is that you will have a similar issue when trying to install many other modules for usage with Node-RED. Why should every other module document special installation instructions for Node-RED? This doesn't make sense to me.

PizzaProgram commented 2 years ago

Yes, normally you are right:

But !

Why?

That means, Your module is an exception!

Because it can not be installed directly from palette manager. It is usually called + used from a custom "Function Node".

That means people are calling required('i2c') from JS scripts, but first they have to install it manually from terminal + allow to use it from Node-RED's settings.js file. Or if they develop a new custom node (like I've tried) they need to install it first to be able to call it. In either case it is too complicated, especially for beginners, and they will not understand:

PS: Anyway it's a great piece of work!!! Congratulation and thanks for sharing.

PizzaProgram commented 2 years ago

But it's OK, if you do not want to help others, I can understand.

Actually it would be best to create a whole separate page with step-by-step instructions, but you are right about that it should be part of the Node-Red docs and you could simply create a link to that page.

fivdi commented 2 years ago

That means people are calling required('i2c') from JS scripts, but first they have to install it manually from terminal + allow to use it from Node-RED's settings.js file.

This means if people are calling require('onoff') or require('spi-device') they will have the same issue, correct? And that the same documentation would be needed for onoff and spi-device, correct?

PizzaProgram commented 2 years ago

Yes, you are right.

The only difference is, I've never heard of 'onoff' or 'spi-device' modules. Also I've asked around and 4 of 5 users, how also bought a Raspberry Pi for any automatisation project, bought some i2c devices and tried to use those with Node-red first. And they ALL have failed because problems like this. (And ended up using Arduinos instead, as i2c drivers, connected to RPi.)

(Also 70% of those who tried OpenHAB or other home automatisation first, ended up using Node-RED at the end.)

I know all these things because I've spent more than 1 year only to read forums about those who have tried.

Currently I'm working on an "All-in-One IO" node that could work with Node-Red almost plug&play, to drive the 2 most famous "starter kit" IO boards: MCP23014 and PFC8574.

But many newcomers will buy something else, like temp sensors and will try to install Your code first.

fivdi commented 2 years ago

The only difference is, I've never heard of 'onoff' or 'spi-device' modules.

It's not particularly important whether or not you have heard of onoff or spi-device. The point is, you will have the same issue with any additional module that you would like to use.

I did Google search for the string "install node.js modules in node-red" and clicked the first hit which lead me here. This Node-RED discourse thread deals with the issue you were experiencing. It's also points at the Node-RED documentation for "Loading additional modules" which can be found here. The documentation explains explains two ways of loading additional modules, one of which doesn't required the use of the command line.

The Node-RED documentation is far better than anything that can be provided in the readme of the i2c-bus module. The Node-RED documentation will also be maintained and kept up to date.

fivdi commented 2 years ago

I'll go ahead and close this.