How to use mcp3008 library in Node-RED on RPi?

1,220 views
Skip to first unread message

Michael Doroshenko

unread,
Oct 31, 2016, 3:36:43 PM10/31/16
to Node-RED
I have installed this library in my ~/.node-red directory:
https://www.npmjs.com/package/node-red-node-pi-mcp3008

However, even after I restart node-red and the pi, I still don't see the mcp3008 node on the left pane.
What am I doing wrong???

Zenofmud

unread,
Oct 31, 2016, 4:03:53 PM10/31/16
to node...@googlegroups.com
Did you make sure SPI is enabled? 
--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/d9eea90b-b303-4c6b-a273-48e34774af14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Doroshenko

unread,
Oct 31, 2016, 4:04:58 PM10/31/16
to Node-RED
Yes, I enabled it as stated in the instructions.

Mark Setrem

unread,
Oct 31, 2016, 5:33:57 PM10/31/16
to Node-RED
What version of node-red? What version of nodejs? What version of npm?

Which Pi?

Michael Doroshenko

unread,
Nov 1, 2016, 4:21:50 PM11/1/16
to Node-RED Mailing List
RPi 3
Linux 4.4.23-v7+ arm LE
npm 2.15.9
node v4.6.1
Node-Red v0.15.2

Please advise.
Thanks.



On Mon, Oct 31, 2016, 5:33 PM Mark Setrem <mse...@gmail.com> wrote:
What version of node-red? What version of nodejs? What version of npm?

Which Pi?

--
http://nodered.org

Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/nJxiBNHC4iw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send an email to node...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--

Mark Setrem

unread,
Nov 2, 2016, 5:04:11 AM11/2/16
to Node-RED
I just tried installing the node on a new instance of node-red using the same version of nodejs as you

If I install it and have NOT configured SPI to be on I get the same as you, no error messages if I start node-red with the command "node-red -v"

However when I then use "sudo raspi-config"  and enable SPI and reboot and the node is then displayed.

One confusing thing is it displays under "Raspberry_Pi" but with the name "A/D Converter" rather than the name "pimcp3008" which the flows.nodered.org page suggests.


Michael Doroshenko

unread,
Nov 2, 2016, 4:15:51 PM11/2/16
to Node-RED
Thank you. I was able to find it under the name "A/D Converter". Not obvious at all...

Now, however, I am facing a different issue: the values I am getting from the 8 channels are constant, even though the board appears to have been wired appropriately (it works fine with a different Python library, which produces non-zero outputs only on adc/0 and adc/1). Specifically, I am alwyas getting these same values from all channels:

02/11/2016, 16:13:41f3b87a22.ccce18function : (warn)adc/0:384
02/11/2016, 16:13:41f3b87a22.ccce18function : (warn)adc/1:400
02/11/2016, 16:13:41f3b87a22.ccce18function : (warn)adc/2:416
02/11/2016, 16:13:41f3b87a22.ccce18function : (warn)adc/3:432
02/11/2016, 16:13:41f3b87a22.ccce18function : (warn)adc/4:448
02/11/2016, 16:13:41f3b87a22.ccce18function : (warn)adc/5:464
02/11/2016, 16:13:41f3b87a22.ccce18function : (warn)adc/6:480
02/11/2016, 16:13:41f3b87a22.ccce18function : (warn)adc/7:496

Is there a problem with this library or am I doing something wrong again?
Thanks!

Michael Doroshenko

unread,
Nov 3, 2016, 9:20:44 PM11/3/16
to Node-RED
This new development is, unfortunately, blocking my project...
I was hoping the node implemented by the Node-RED creator would have a better support.
Please, let me know if you've got any ideas about why I am always getting the same values from the A/D converter node.

Dave C-J

unread,
Nov 4, 2016, 5:06:18 AM11/4/16
to node...@googlegroups.com
Hi,
sorry for the slow response - but I do have a day job as well, that isn't to do with Node-RED. I'll try to look at it this weekend if I get time.
The node is a simple wrapper around the https://github.com/fivdi/mcp-spi-adc library.
Luckily you are a computer scientist and this is an open source project so you can help debug it. Thanks.

Michael Doroshenko

unread,
Nov 4, 2016, 3:59:17 PM11/4/16
to Node-RED
Hello, Dave!
Thank you for the link. We investigated for a couple of hours, and realized that our MCP3008 was connected to channel CE1, because CE0 was already taken by an RFID reader.
As soon as we reconnected the MCP3008 to channel CE0, your node provided the correct values.

Due to our operational constraints (we cannot modify the hardware setup of the already deployed systems) we would prefer if we could connect your Node-RED MCP3008 node to CE1.
It would be ideal to have this option in GUI, but, if that's not possible, even modifying the node code would be an acceptable acceptable to us.

We tried to reprogram the node
fs.statSync("/dev/spidev0.0"); --> fs.statSync("/dev/spidev0.1");

but it didn't seem to help (although we might have made a mistake somewhere else...)
Is there anything else in the code we would have to modify in order to switch the connection from CE0 to CE1???
Thank you.

Michael Doroshenko

unread,
Nov 4, 2016, 4:20:37 PM11/4/16
to Node-RED
Perhaps, linking all of the A/D converter nodes to a single configuration node where you can specify CE0 or CE1 would be a nice addition for the GUI control.

Mark Setrem

unread,
Nov 4, 2016, 4:51:59 PM11/4/16
to Node-RED
well it is an open source project...

Dave C-J

unread,
Nov 4, 2016, 6:06:50 PM11/4/16
to node...@googlegroups.com
Hi

try changing line 26
from    -    mcp3008.push(mcpadc.openMcp3008(i, function (err) {
to       -    mcp3008.push(mcpadc.openMcp3008(i, {deviceNumber:1}, function (err) {

and report back.. If it works I'll have a look at adding to the UI.

Dave C-J

unread,
Nov 5, 2016, 9:04:30 AM11/5/16
to node...@googlegroups.com
Hi

took a punt - and published it anyway  - now version 0.0.6 on npm.

Michael Doroshenko

unread,
Nov 5, 2016, 6:43:15 PM11/5/16
to node...@googlegroups.com
Thank you, Dave, and sorry for the delay.
Fantastic work! I seem to be getting the correct values from CE1 now.
Hopefully, this will be helpful to the community as well!




On Sat, Nov 5, 2016, 9:04 AM Dave C-J <dce...@gmail.com> wrote:
Hi

took a punt - and published it anyway  - now version 0.0.6 on npm.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/nJxiBNHC4iw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages