Closed thrazu closed 6 years ago
It looks like SPI hasn't been enabled. If a Raspberry Pi is being used, which appears to be the case, then SPI can be enabled with the raspi-config
tool which can be called from the command line with the following command:
sudo raspi-config
Navigate to "5 Interfacing Options >> P4 SPI" and answer the question "Would you like the SPI interface to be enabled?" with "Yes", then answer "Ok", then answer "Finish".
If a fairly recent version Raspbian is being used a reboot should not be necessary. On an older version of Raspbian a reboot will be necessary.
After SPI has been enabled it should work.
This should be mentioned in the README.
Thanks for your straight answer! I have enabled SPI through
sudo raspi-config
command and everything works great now.
That's good news 😄
I'll leave this issue open as a reminder that a note should be added to the README saying that SPI needs to be enabled before it can work.
One additional point, your program contains the following line of code:
console.log((reading.value * 3.3 - 0.5) * 100);
The formula (reading.value * 3.3 - 0.5) * 100
is for a TMP36 temperature sensor so it will need to be changed for a photocell.
Thanks for your advice. I will adapt the formula to work with the photocell.
The README was updated mentioning that SPI must be enabled to use mcp-spi-adc. See 33ed477e613987bf3f31df5b0aadcac3834a8692.
Sorry to re-open this, but I am using an MCP3004 and am getting this when trying to read channels 0, 1, and 2. When reading channel 0 and 1, there are no issues, but reading all 3 produces this error.
@amcelroy I can't reproduce the error. Please open a new issue containing the following information:
Hi. I try to read one photocell / sensor with MCP3008. Got this error code:
My code:
Wiring is ok - just like in readme. Node v9.5.0. Need some help please.