1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00
node-red-nodes/hardware/mcp3008
CD2468 ae4b6bb0bf
Problems with more than one MCP3008 (#823)
* Add files via upload

* Update pimcp3008.js

implementation of the discussion

* Update pimcp3008.js

Co-authored-by: Dave Conway-Jones <dceejay@users.noreply.github.com>
2021-10-27 13:46:00 +01:00
..
.DS_Store add mcp3008 node and bump some packages 2016-09-20 08:19:45 +01:00
LICENSE Update licenses and packages for all nodes 2016-11-06 20:26:19 +00:00
package.json Fix MCP3xxx Readme 2021-10-19 20:34:08 +01:00
pimcp3008.html Problems with more than one MCP3008 (#823) 2021-10-27 13:46:00 +01:00
pimcp3008.js Problems with more than one MCP3008 (#823) 2021-10-27 13:46:00 +01:00
README.md Fix MCP3xxx Readme 2021-10-19 20:34:08 +01:00

node-red-node-pi-mcp3008

A Node-RED node to read from the MCP3xxx Series of Analogue to Digital Converters, such as the Rasp.io analogzero, though it will work with breadboard versions also.

It will appear in the menu as A/D Converter.

Warning: Input voltages must not exceed 3.3V

Pre-requisites

You must ensure that SPI is enabled. For recent (2016) versions of Raspbian you can do this

  • Run sudo raspi-config
  • Select 5 - Interfacing Options
  • Select P4 - SPI
  • Select yes to enable SPI
  • Select OK to confirm
  • Select the Finish button

Install

Run the following command in your Node-RED user directory - typically ~/.node-red

    npm install node-red-node-pi-mcp3008

Note: It will appear in the menu as A/D Converter.

Usage

Reads from an MCP3xxx Analogue to Digital (ADC) chip on the Pi SPI connection.

You can either set a channel in the edit dialogue, or you can set the msg.payload to select the channel dynamically. If so then the payload must be a value from 0 to 7.

You can also select device id 0 or 1 (CE0 or CE1) depending on how you have wired up your device. Defaults to CE0.

And you can also select the SPI bus number 0 or 1 depending on how you have wired up your device. Defaults to 0 for spidev0.

Outputs a numeric msg.payload with a range of 0 to 1023 for MCP30XX family, where 0 = 0V and 1023 = 3.3V (assuming you use the default 3.3V voltage reference). For MCP32XX and MCP33XX the range returned is 0 to 4095.

Hint: use a range node to adjust the values to the range you want.

Also sets msg.topic to adc/{the pin number}