In this project, you'll learn how to build a low-cost, multi-channel data acquisition (DAQ) system using an Arduino Uno and Python. The system collects sensor data from multiple channels in real time and automatically saves the measurements to a CSV (Comma Separated Values) file for easy analysis in spreadsheet software or other data processing tools.
Source CodesAll the source codes can be downloaded from our website using the below link
IntroductionThe DAQ system is designed to monitor temperature from four independent sensors simultaneously, and it can be expanded to support additional channels if needed. This makes it ideal for experiments, environmental monitoring, and educational projects.
The hardware consists of an
- Arduino Uno,
- an LM324 operational amplifier-based analog front end,
- and four LM35 temperature sensors.
The analog signals from the sensors are conditioned by the LM324 circuit before being sampled by the Arduino's built-in 10-bit ADC (ATmega328P).
After digitizing the sensor readings, the Arduino transmits the data to a Windows PC or Mac over a USB virtual serial port. A Python application receives the data, displays it in real time, and logs every measurement to a CSV file for permanent storage and later analysis.
What Are CSV Files and How Do They WorkA CSV (Comma Separated Values) file is one of the simplest and most widely used formats for storing tabular data. In a CSV file, each row represents a single record, while commas separate the individual values or fields within that row. Because of its plain-text format, a CSV file can be created, viewed, and edited using a text editor, spreadsheet applications such as Microsoft Excel or Google Sheets, or programming languages like Python.
Hardware Design of the Python Arduino DataloggerThe low-level analog signals produced by the LM35 temperature sensors are first amplified using an LM324 quad operational amplifier before being applied to the Arduino Uno's analog inputs.
Each amplifier stage is configured with a voltage gain of 3.44, increasing the sensor output voltage to improve the measurement resolution of the Arduino's 10-bit ADC.
The signal conditioning circuit is built around a single LM324 quad op-amp, with one amplifier dedicated to each of the four LM35 temperature sensors. A detailed explanation of the amplifier design, including the circuit diagram and gain calculations, is available in the LM35 amplifier design article.
The amplified outputs are connected to the Arduino Uno as follows:
- Amplifier Channel 1 (AN1) → Arduino A0
- Amplifier Channel 2 (AN2) → Arduino A1
- Amplifier Channel 3 (AN3) → Arduino A2
- Amplifier Channel 4 (AN4) → Arduino A3
The Arduino Uno is connected to the computer through its USB interface, which also functions as a virtual serial (COM) port. This serial connection allows the Arduino to transmit temperature measurements to the Python application running on the PC in real time.
After sampling the four analog input channels and converting the sensor voltages into digital values, the Arduino sends the temperature readings over the serial port in a simple, comma-separated format. Each serial message contains the readings from all four LM35 temperature sensors in the following order:
Temp1, Temp2, Temp3, Temp4
For example, a typical serial data packet may look like this:
25.3, 24.9, 26.1, 25.7
The Python application continuously reads each incoming data packet, separates the four temperature values, displays them on the screen, and stores them in a CSV file for later analysis and visualization.
Software Architecture of Python Datalogger SystemThe Python datalogger code begins by creating a unique CSV file for storing the temperature measurements.
The filename is automatically generated using the current date and time, ensuring that each logging session is saved to a separate file.
After creating the file, the program writes a header row containing the names of each data column.
Next, the Python application opens a serial connection to the Arduino using the PySerial library. Since the Arduino automatically resets when the serial port is opened, the program briefly waits for the board to restart before beginning data acquisition.
Once communication has been established, the datalogger enters a continuous acquisition loop. During each iteration, the Python program sends the '$' character to the Arduino as a request for a new set of temperature readings. In response, the Arduino measures the four LM35 sensors and returns the data as a single line of text in the format:
Temp1, Temp2, Temp3, Temp4
The Python program receives this data, records the current date and time from the computer, and combines the timestamp with the four temperature values to create a complete log entry.
This entry is then appended to the CSV file, and the process repeats continuously, allowing temperature data to be recorded in real time.
The program also installs a CTRL + C (SIGINT) signal handler, enabling the user to stop data logging safely at any time. When the user presses CTRL + C, the acquisition loop exits gracefully, the CSV file is properly closed, and the serial port is released before the program terminates.
Running the Python Data Logger CodeBefore running the Python datalogger, make sure the PySerial library is installed on your Windows computer.
If you are new to PySerial, refer to our PySerial tutorial, which explains how to install the library and communicate with serial devices using Python.
Next, determine the COM port number assigned to your Arduino Uno.
You can find this by opening Device Manager in Windows and expanding the Ports (COM & LPT) section.
Note the COM port associated with the Arduino, as you will need to specify it in the Python program.
After updating the COM port number (if required), open a Command Prompt, navigate to the folder containing the Python script, and run the program using:
python datalogger.pyIf your system uses the Python Launcher, you can also start the program with:
py datalogger.pyOnce the program starts, it will connect to the Arduino, create a new CSV file with a timestamped filename, and begin logging temperature data in real time.
After the data logging session is complete, you can open the generated CSV file in Microsoft Excel, LibreOffice Calc, or any other spreadsheet application that supports CSV files. From there, you can organize, filter, and analyze the recorded temperature data
You can use Quick Analysis tool in MS Excel to generate graphs or charts to display your data in an intuitive manner.


_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)





Comments