Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading from Analog > Digital #46

Closed
nick-jonas opened this issue Feb 3, 2016 · 7 comments
Closed

Reading from Analog > Digital #46

nick-jonas opened this issue Feb 3, 2016 · 7 comments

Comments

@nick-jonas
Copy link

I'm trying to read data from 2x10k potentiometers that are wired to the 1st two inputs of an MCP3008, and then the MCP3008 is hooked up to the RPi like this:

(rpi on the left, mcp3008 on the right):

Pin 19 (MOSI / #10) -> pin 11 (Din)
Pin 21 (MISO / #9) -> pin 12 (Dout)
Pin 23 (SCKL / #11) -> pin 13 (CLK)
Pin 24 (CD0 / #8) -> pin 10 (CS)
Pin 6 (GND) -> pin 14 (AGND) & 9 (DGND)

How do I go about doing this? The only reference code I could find on johnny-five is for the Grove shield and Edison board:

var rotary = new five.Sensor("A0");

rotary.scale(0, 255).on("change", function() {
    // do stuff with this.value
});

How do I create two rotary instances (what would I use for the GPIO pins)?

@fivdi
Copy link
Collaborator

fivdi commented Feb 3, 2016

The MCP3008 is an SPI device but Johnny-Five and Raspi-IO currently don't support SPI devices. What should work is the PCF8591 which is an I2C device. I2C is supported. See http://johnny-five.io/examples/expander-PCF8591/

@fivdi
Copy link
Collaborator

fivdi commented Feb 3, 2016

See also rwaldron/io-plugins#3

@nick-jonas
Copy link
Author

Hmm tried using node-spi from @RussTheAerialist as mentioned in that thread but getting issues on the install with node-gyp:

russtheaerialist-retired-projects/node-spi#25

I'll order a PCF8591, and if there are any other ideas of things to try with the MCP3008, let me know - thanks!!

@fivdi
Copy link
Collaborator

fivdi commented Feb 4, 2016

@nick-jonas what version of Node.js are you using? https://github.com/RussTheAerialist/node-spi supports v0.10 and v0.12, but not v4 or higher

@nick-jonas
Copy link
Author

@fivdi v0.10.36

@nebrius
Copy link
Owner

nebrius commented Feb 19, 2016

Hi @nick-jonas! Just so you're aware, using node-spi and this SPI device won't make the analog data available to Johnny-Five. You can certainly still use it, but you'll have to parse the SPI data yourself, and wire up your own event logic independent of Johnny-Five :(

If at all possible, I'd recommend going with the I2C backpack that @fivdi mentioned.

@nebrius
Copy link
Owner

nebrius commented Mar 21, 2016

I believe the issue was addressed in the previous comments. If there is still an issue that needs to be fixed, feel free to reopen.

@nebrius nebrius closed this as completed Mar 21, 2016
@nebrius nebrius changed the title Reading from Analog > Digital Reading from Analog > Digital Mar 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants