Eight-channel voltage logger
Build it step by step
0 of 7 doneWire the MCP3008
Check the pin numbers twice.
Test one channel with a 1.5 V cell
Read it over serial.
Add the SD module
Format the card FAT32.
Add the clock
Set it with the RTC example.
Log a few lines
Open the CSV on a computer.
Connect real signals
0 to 5 V only.
Set the interval
With the button.
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
- Development BoardsBuyArduino Nano × 1
- Integrated CircuitsBuy
- InterfacesBuy
- SBC AccessoriesBuy
- SensorsBuy
- PassivesBuyResistor 10 kΩ × 8
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| MCP3008 pins 1 to 8 (CH0 to CH7) | Inputs through 10 k series resistors | 0 to 5 V only |
| MCP3008 pins 9 and 14 (DGND, AGND) | Nano GND | Ground |
| MCP3008 pins 15 and 16 (VREF, VDD) | Nano 5V | Supply and reference |
| MCP3008 pin 13 (CLK) | Nano D13 | SPI clock |
| MCP3008 pin 12 (DOUT) | Nano D12 | SPI MISO |
| MCP3008 pin 11 (DIN) | Nano D11 | SPI MOSI |
| MCP3008 pin 10 (CS) | Nano D9 | ADC chip select |
| SD module CS, MOSI, MISO, SCK | Nano D10, D11, D12, D13 | Shares the SPI bus |
| RTC SDA and SCL | Nano A4 and A5 | Timestamps |
| Interval button | Nano D2 and GND | Cycles 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.
| Check | Expected |
|---|---|
| 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 |
| Time stamps | Match 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 →
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.
