1
\$\begingroup\$

I am using an MCP3008 ADC connected to a Seeed Studio Xiao nRF52840.
I am using the adafruit library #include <Adafruit_MCP3008.h>
It operates as expected, but after taking readings I would like the MCP to 'turn off' or enter into sleep mode.

Before I call the function adc.begin(pin_adcCS); the current draw of the circuit is 150uA, once the MCP turns on, it draws about 1mA.

In the datasheet, it says you can set the CS pin high in order to set the MCP into "low-power" mode. However, I don't observe a change in current consumption.

I am attempting to put it into low-power mode by calling:

adc.begin(pin_adcCS); //turn on adc
doorVal = adc.readADC(1); //take reading
pinMode(pin_adcCS, OUTPUT); //change CS pinmode
digitalWrite(pin_adcCS, HIGH);//write to the MCP
delay(100);
pinMode(pin_adcCS, INPUT);//Change back to INPUT to reduce current consumption

I tried to keep the pin high for longer and see if the current dropped, but there was no change, it appears to have no effect.

Any ideas about what I could be missing here?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Are you aware that the pin is "floating" in input mode? If you don't have other measures, any level is the result. Why do you think it reduces the power consumption to put it into input mode? -- What happens if you just do nothing in loop() even after one conversion? \$\endgroup\$ Commented Mar 16, 2023 at 6:42
  • 1
    \$\begingroup\$ Is this "MCP2008" in your question in contrast to "MCP3008" in the title a typo? \$\endgroup\$ Commented Mar 16, 2023 at 6:49
  • \$\begingroup\$ Good catch, that was a typo. It is MCP3008. I thought output mode caused additional current draw but this was something else entirely, you are correct, input/output has no effect on current draw. \$\endgroup\$
    – MattG
    Commented Mar 16, 2023 at 11:00

2 Answers 2

0
\$\begingroup\$

Normally the CS pin is high between SPI bus transactions, because that's the purpose for being able to select between multiple chips on SPI bus.

The chip even needs CS to go high to complete a SPI transaction.

So since the driver likely leaves the SPI already high, the ADC is already in powerdown mode, so it does not change anything if you manually try to set CS pin as input or high.

\$\endgroup\$
4
  • \$\begingroup\$ I thought it would be smart enough to automatically go into low-power mode, but that doesn't seem to be the case. If I delay before calling adc.begin(pin_adcCS); the current draw is low, but immediately after it is high, and stays high even after adc.readADC(1); has been called. I would expect after the reading is complete it would go back to the current consumption before .begin() was called. \$\endgroup\$
    – MattG
    Commented Mar 16, 2023 at 11:04
  • \$\begingroup\$ Looking at the adafruit library, it does put the cs_pin HIGH when it is done the SPI transaction. So I have no idea why it continues to draw so much power. \$\endgroup\$
    – MattG
    Commented Mar 16, 2023 at 11:19
  • \$\begingroup\$ Well, it should consume less. But you are using Arduino library, and you don't know what it does unless you read the source code, and we don't know what the hardware looks like. You might have a pull resistor which consumes current just because the SPI bus is initialized to idle state. \$\endgroup\$
    – Justme
    Commented Mar 16, 2023 at 11:24
  • \$\begingroup\$ It's setup like the datasheet suggests, no pull resistors. I suspect it is the adafruit library. I will dig into it further. \$\endgroup\$
    – MattG
    Commented Mar 16, 2023 at 11:32
0
\$\begingroup\$

Turns out you need to call SPI.end() and also set pinMode(MCP3008_CS_PIN, INPUT_PULLUP); as it does continue to draw current when set as output and HIGH. This will put the MCP3008 into low-power mode. I also imported arduino SPI.h (which I was before too).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.