2016-09-20 09:19:45 +02:00
|
|
|
node-red-node-pi-mcp3008
|
|
|
|
========================
|
|
|
|
|
|
|
|
A <a href="http://nodered.org" target="_new">Node-RED</a> node to read from
|
2018-01-13 17:42:22 +01:00
|
|
|
the MCP3xxx Series of Analogue to Digital Converters,
|
2016-09-20 09:19:45 +02:00
|
|
|
such as the <a href="http://rasp.io/analogzero" target="_new">Rasp.io analogzero</a>, though it will work with breadboard versions also.
|
|
|
|
|
2016-11-02 22:16:48 +01:00
|
|
|
It will appear in the menu as ` A/D Converter `.
|
|
|
|
|
2016-09-20 09:19:45 +02:00
|
|
|
**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`
|
2017-09-24 20:46:51 +02:00
|
|
|
- Select `5 - Interfacing Options`
|
|
|
|
- Select `P4 - SPI`
|
2016-09-20 09:19:45 +02:00
|
|
|
- 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
|
|
|
|
|
2016-11-02 22:16:48 +01:00
|
|
|
**Note**: It will appear in the menu as ` A/D Converter `.
|
|
|
|
|
2018-01-13 17:42:22 +01:00
|
|
|
### Usage
|
2016-09-20 09:19:45 +02:00
|
|
|
|
2018-01-13 17:42:22 +01:00
|
|
|
Reads from an MCP3xxx Analogue to Digital (ADC) chip on the Pi SPI connection.
|
2016-09-20 09:19:45 +02:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2016-11-06 21:26:19 +01:00
|
|
|
You can also select device id 0 or 1 (CE0 or CE1) depending on how you have wired up your device. Defaults to CE0.
|
|
|
|
|
2018-09-21 14:53:08 +02:00
|
|
|
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.
|
|
|
|
|
2016-09-20 09:19:45 +02:00
|
|
|
Outputs a numeric `msg.payload` with a range of 0 to 1023, where 0 = 0V and 1023 = 3.3V (assuming you use the default 3.3V voltage reference).
|
|
|
|
|
|
|
|
**Hint**: use a `range` node to adjust the values to the range you want.
|
|
|
|
|
|
|
|
Also sets `msg.topic` to `adc/{the pin number}`
|