กลับไปหน้ารวมไฟล์
arduino-nano-fast-pc-loggger-6c0631-en.md

Introduction

Arduino Nano is reading data over SPI from MCP300 (10-bit ADC),

Nano adds the time stamp from Timer1 and

it is all sent to PC with 1000000 baud speed (14350 Sampes/sec).

Details and source code available here:

https://github.com/TomasGaj/Arduino_Nano_MPC3008_logger/tree/main

real experimental setup

Note: This code doesn't work with Arduino Uno, I successfully tested it only on Arduino Nano.

Although UNO and Nano boards have the same processor, they use different chips for USB communication, check the text below.

Project Perspective

Arduino Nano fast PC loggger is a fundamental and innovative data telemetry project. By focusing on the essential building blocks—the Arduino Nano and high-speed serial communication—you'll learn how to orient yourself and monitor sensor data using a specialized software logic and a robust hardware setup.

Technical Implementation: High-Speed Serial Streams

The project reveals the hidden layers of simple data acquisition:

  • Communication layer: The Arduino Nano can send data to your PC at extremely high baud rates (up to 2,000,000 baud) for real-time monitoring of fast-changing signals.
  • Sensing layer: A Potentiometer acts as a simulated analog sensor. Its output (0-1023) is sampled by the Nano and sent to the PC for visualization.
  • Timing Logic layer: The Arduino code follows a specialized "high-frequency" strategy: it requests and performs sensor reads hundreds of times per second (e.g., every 5-10ms).
  • Reception layer: On the PC side, the Serial Plotter or a terminal program (like Putty or a custom Python script) acts as the high-performance receiver and grapher.

Hardware Infrastructure

  • Arduino Nano: The tiny "brain" of the project, managing the high-speed analog-to-digital (ADC) conversion and coordinating the serial data tasks.
  • Potentiometer: Providing a clear and playful visual/analog feedback forEach measurement you simulate.
  • Breadboard: A convenient way to prototype the logger circuit and connect all components without soldering.
  • Micro-USB Cable: Use to program the Nano and provide high-speed serial power and data to your computer.
  • Jumper Wires: Connect all the components together on your breadboard.

How to connect the Arduino Nano board to MCP3008

MCP3008 Atmega328P

V_DD 5v

V_REF 5v

AGND GND

CLK D13

D_OUT D12

D_IN D11

CS D10

DGND GND

The structure of the data:

The first two nibbles are time-stamp from the lower byte of Timer1. Timer1 periodically overflows.

The prescaler of Timer1 is set to 64, and Timer1 is increased each 4us.

The next three nibbles are ADC data values.

And on the end of the message are placed carriage return and new line characters.

Telemetry and Interaction Step-by-Step

The data logging process is designed to be very efficient:

  1. Initialize Hardware: Correctly seat the Nano and potentiometer on your breadboard and prepare for action.
  2. Setup Serial Sync: In the setup() function, initialize the serial communication at a high speed (e.g., 115,200 or 250,000 baud).
  3. Execution Loop: The Nano constantly performs several high-performance sensor reads and updates the Serial port in real-time.
  4. Visual Feedback Integration: Watch as yours sensor data update on the PC screen (Serial Plotter) in real-time, with a celebrating buzzer sound for each successful check.

This code is following two main sources:

I. Youtube tutorials of Anas Kuzechie:

https://www.youtube.com/@AnasKuzechie

II. fast-MCP3008 library written by Dmitriy L.

https://github.com/arithmechanics/fast-MCP3008

About the bug, why the code runs only on Arduino Nano board and not on Arduino Uno boards

It's due to its FTDI chip, the figures below are self-explanatory. After uploading the code into Arduino UNO, you see missing data as in the figure below, after uploading it into Arduino Nano, you'll see a proper record of the sine wave.

I didn't investigate more boards, only UNO and NANO boards.

When I saw it for the first time I thought it was coming from some interruption running in the background, for example from micros(), so I stuck to the C. Problem remained and then I found this thread, I think it is this issue:

https://forum.arduino.cc/t/uno-atmega16u2-maximum-serial-throughput/893662

I think it's due to the buffer overflow in the Atmega chip replacing FTDI, maybe they already fix it in new versions, but I did not investigate it.

Future Expansion

  • OLED Status Dashboard Integration: Add a small OLED display on the logger to show the current "Sample Rate" (Hz) andYours data's peak values.
  • Multi-sensor Climate Sync Synchronization: Connect several more analog sensors (up to 8) and link all their data into a single multi-column CSV or Excel log.
  • Cloud Interface Registration Support: Add a specialized cloud dashboard to precisely control and track yours telemetry history from your smartphone over WiFi.
  • Advanced Velocity Profile Customization Support: Add a small slider or potentiometer to manually adjust the "Logging Frequency" between slow (1Hz) and extremely fast (500Hz).

For capturing data on PC I used:

https://coolterm.en.lo4d.com/windows

Enjoy!

TG

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
  - "1x Excel or Serial Plotter"
author: "shassandanish1"
category: "Lab Stuff"
components:
  - "1x Arduino Nano"
  - "1x Potentiometer (for data simulation)"
  - "1x Breadboard (generic)"
  - "10x Jumper wires (generic)"
  - "1x Micro-USB Cable"
description: "reads data from MCP3008, adds time stamp from Timer 1, and sends to PC with the speed of 1000000 bauds (~14350 Samples/sec)."
difficulty: "Intermediate"
documentationLinks: []
downloadableFiles:
  - "https://github.com/TomasGaj/Arduino_Nano_MPC3008_logger/blob/main/README.md"
encryptedPayload: "U2FsdGVkX1+tpfyjL+HvB5bNL3TA0YE0s0IiJ0QsuEyIp4kCtGFVMJ9fUacIIkWg8+et0BWJiwuTxIUUTdly1D0/8194XXTjJhilRtPWkQ0="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/arduino-nano-fast-pc-loggger-6c0631_cover.png"
lang: "en"
likes: 0
passwordHash: "f2ff603cc88cec7ad50c14d889175c8c1c90cd2eb8d2155a577df3a5a81f4ae8"
price: 2450
seoDescription: "Arduino Nano fast PC logger: Reads MCP3008 data, adds Timer 1 time stamps, and sends to PC at 1M bauds (14350 Samples/sec)."
tags:
  - "data-logging"
  - "pc-logger"
  - "serial-communication"
  - "arduino-nano"
  - "beginners"
title: "Arduino Nano fast PC loggger"
tools: []
videoLinks: []
views: 3125