Giter Club home page Giter Club logo

Comments (5)

fivdi avatar fivdi commented on June 15, 2024

I expect that when I connect the 3.3V rail to pin 5 on the MCP3008, the value that the Pi logs should be 1023, right?

Correct, but not with the test program posted above. The test program above is for channel 0 (pin 1). For channel 4 (pin 5) it should be:

const sensor = mcpadc.open(4, {speedHz: 20000}, err => {

rather than:

const sensor = mcpadc.open(0, {speedHz: 20000}, err => {

One thing that I don't understand is that the Pi doesn't throw an error when I disconnect the MCP from it. I'd have thought that if it couldn't communicate with the MCP it would throw an error?

With SPI, if no device is connected everything still appears to work. In this case, the Linux SPI driver still reads from the SPI MISO line and every bit read is typically 0.

Do you have any suggestions about what steps I could take to troubleshoot it?

The code posted looks correct. The Linus SPI driver doesn't appear to see the MCP3008.

  • Are you sure that the MCP3008 that you are using functions correctly?
  • Please post the complete contents of the file /boot/config.txt.
  • Please post the output of the command node -v
  • Please post the output of the command uname -a
  • Please post the output of the command ls -l /dev/spi*

from mcp-spi-adc.

stacy-hunt avatar stacy-hunt commented on June 15, 2024

The test program above is for channel 0 (pin 1). For channel 4 (pin 5) it should be:

Right - I changed it to channel 0, but I did try connecting 3.3V to each of the input pins one by one in case I had specified it incorrectly. But none of the pins produced any output other than 0.

With SPI, if no device is connected everything still appears to work

Ah OK.

Are you sure that the MCP3008 that you are using functions correctly?

Yes, but I don't know how to test it. I bought 4 of them and this one is fresh out of the box. I tried it with a second new one as well just in case it was faulty, but not difference.

Please post the output of the command node -v
Please post the output of the command uname -a
Please post the output of the command ls -l /dev/spi*

Here you are:

image

from mcp-spi-adc.

stacy-hunt avatar stacy-hunt commented on June 15, 2024

Oh yeah one more thing you asked for:
config.txt

from mcp-spi-adc.

stacy-hunt avatar stacy-hunt commented on June 15, 2024

Ahhhh... Hey Brian, I got it working!

I hadn't realised that your Raspberry Pi has a different pinout pattern from mine. I traced each cable and checked the name of the pin and discovered that the pattern was different. So I had the connections going to the wrong pins on my Pi (which is a model 4). So I just had to look up each pin by name, find it on the Pi and connect to the right pins.

I hope I didn't waste your time, although just going through your list made me think of checking that so you did help a lot!

Problem solved. Your module is awesome, thanks for making it.

from mcp-spi-adc.

fivdi avatar fivdi commented on June 15, 2024

If you check the pin numbers on the Pi 4 and Pi 1 GPIO headers you'll see that they are the same. Anyway, good to hear that it's working now.

from mcp-spi-adc.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.