Projects / Eight-channel voltage logger

Eight-channel voltage logger

Intermediate2.5 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANOMCP3008

    Wire the MCP3008

    Check the pin numbers twice.

  2. NANOMCP3008

    Test one channel with a 1.5 V cell

    Read it over serial.

  3. NANOMICROSSANDIS

    Add the SD module

    Format the card FAT32.

  4. NANODS323121:11

    Add the clock

    Set it with the RTC example.

  5. NANO

    Log a few lines

    Open the CSV on a computer.

  6. NANO

    Connect real signals

    0 to 5 V only.

  7. NANO

    Set the interval

    With the button.

In short

How do you build an eight-channel voltage logger?

An MCP3008 logs eight voltages to SD at set intervals, for testing chargers, solar or sensors. You need Arduino Nano, MCP3008 8-channel 10-bit ADC, MicroSD Card Module, SanDisk microSD card 32 GB (A1, Class 10), DS3231 RTC module and Resistor 10 kΩ × 8. It takes 7 steps and about 150 minutes.

Level
Intermediate
Time
About 150 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
MCP3008 pins 1 to 8 (CH0 to CH7)Inputs through 10 k series resistors0 to 5 V only
MCP3008 pins 9 and 14 (DGND, AGND)Nano GNDGround
MCP3008 pins 15 and 16 (VREF, VDD)Nano 5VSupply and reference
MCP3008 pin 13 (CLK)Nano D13SPI clock
MCP3008 pin 12 (DOUT)Nano D12SPI MISO
MCP3008 pin 11 (DIN)Nano D11SPI MOSI
MCP3008 pin 10 (CS)Nano D9ADC chip select
SD module CS, MOSI, MISO, SCKNano D10, D11, D12, D13Shares the SPI bus
RTC SDA and SCLNano A4 and A5Timestamps
Interval buttonNano D2 and GNDCycles 1 s, 10 s, 60 s (internal pull-up)

Code

The Nano has only six usable analog pins, so an MCP3008 adds eight 10-bit channels over SPI. Because the same chip reference is the Nano's 5 V, each step is about 5 mV, which is enough for batteries, chargers, solar panels and most sensors. Never put more than 5 V on an input: for higher voltages build a divider outside the logger, for example two equal resistors for up to 10 V, and for anything above about 30 V use a different instrument. Each input has a 10 k series resistor, which limits the current into the chip if a signal goes wrong, but it does not make it safe to connect mains or a car battery. Every line is stamped by the DS3231, so set its time first with the RTClib example. The file is opened and closed each time, so pulling the card between lines does not corrupt the log. Keep the SD module on the same SPI bus as the ADC but with its own chip select. Arduino IDE, board "Arduino Nano" (try the Old Bootloader option if the upload fails).

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Eight-channel voltage logger: MCP3008 over SPI, DS3231 time stamps, one CSV line per interval on the SD card.
// Libraries: SD (built in), RTClib (Adafruit). Board: Arduino Nano. Inputs must stay between 0 and 5 V.
#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include <RTClib.h>
RTC_DS3231 rtc;
const uint8_t CS_ADC = 9, CS_SD = 10, BTN = 2;
const float VREF = 5.00;                         // measure the Nano 5V pin and enter it here
const unsigned long STEPS[] = { 1000UL, 10000UL, 60000UL };
int stepIdx = 1;
unsigned long lastLog = 0;
bool lastBtn = HIGH;
int readMcp(uint8_t ch) {
  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
  digitalWrite(CS_ADC, LOW);
  SPI.transfer(0x01);                              // start bit
  uint8_t hi = SPI.transfer(0x80 | (ch << 4));     // single-ended, channel number
  uint8_t lo = SPI.transfer(0x00);
  digitalWrite(CS_ADC, HIGH);
  SPI.endTransaction();
  return ((hi & 0x03) << 8) | lo;
}
void setup() {
  pinMode(CS_ADC, OUTPUT); digitalWrite(CS_ADC, HIGH);
  pinMode(BTN, INPUT_PULLUP);
  Serial.begin(115200);
  SPI.begin();
  rtc.begin();
  if (!SD.begin(CS_SD)) { Serial.println("SD card not found"); while (true) {} }
  File f = SD.open("log.csv", FILE_WRITE);
  if (f) { f.println("time,ch0,ch1,ch2,ch3,ch4,ch5,ch6,ch7"); f.close(); }
}
void loop() {
  bool b = digitalRead(BTN);
  if (lastBtn == HIGH && b == LOW) { stepIdx = (stepIdx + 1) % 3; delay(40); }
  lastBtn = b;
  if (millis() - lastLog >= STEPS[stepIdx]) {
    lastLog = millis();
    DateTime t = rtc.now();
    File f = SD.open("log.csv", FILE_WRITE);
    if (f) {
      f.print(t.year()); f.print('-'); f.print(t.month()); f.print('-'); f.print(t.day()); f.print(' ');
      f.print(t.hour()); f.print(':'); f.print(t.minute()); f.print(':'); f.print(t.second());
      for (int ch = 0; ch < 8; ch++) { f.print(','); f.print(readMcp(ch) * VREF / 1023.0, 3); }
      f.println();
      f.close();
    }
  }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
1.5 V cell on CH0About 1.5 in the log
Unused inputsFloating, so connect them to GND
Pull the card and reinsertLogging resumes
Time stampsMatch your clock

If it does not work

SD card not found

Check CS on D10 and the card format.

Readings jump

Connect unused inputs to GND and keep wires short.

All values 5 V

Check pins 9, 14 and the ground wiring.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the eight-channel voltage logger?

Arduino Nano, MCP3008 8-channel 10-bit ADC, MicroSD Card Module, SanDisk microSD card 32 GB (A1, Class 10), DS3231 RTC module and Resistor 10 kΩ × 8.

How long does the eight-channel voltage logger take to build?

About 150 minutes for a intermediate maker, in 7 steps.

How do I know the eight-channel voltage logger works?

1.5 V cell on CH0: About 1.5 in the log. Unused inputs: Floating, so connect them to GND. Pull the card and reinsert: Logging resumes.

SD card not found: what should I check?

Check CS on D10 and the card format.

Readings jump: what should I check?

Connect unused inputs to GND and keep wires short.

All values 5 V: what should I check?

Check pins 9, 14 and the ground wiring.