Sampling of a current signal using Arduino nano

Dear community

Sorry if the question is not very well formulated, but I want to measure a current signal using Arduino nano and ACS712 current sensor. I need a high sampling rate (let's say 20 kHz or more if possible) for the period of 1 sec, and I want to save the recorded data (i.e. the reading from the sensor) for this 1 in a variable and plot it later with Matlab or python or if possible in Arduino.

Is such a project and sampling rates achievable with nano?
Can you please share a sample code, so that I know how to save the variables and use them later for plotting?

Please do not hesitate to ask for more information if the question is not clear.

Thanks for your help in advance.

If you mean the Arduino Classic Nano, it is possible to read the ADC and print the data to a serial port at 20 kHz, but there is not enough memory to save the data.

To save the data on a PC, use the fastest serial Baud rate possible, and a terminal program (like TeraTerm) that can log the data to a file.

@jremington Thanks for your fast response.
I would appreciate, if you can also refer to any available code (in the forum or other resources) related to this matter, that I can start with.

An internet search using "arduino acs712 tutorial" turned up many hits. First one

1 Like

I was using CoolTerm before and I had a problem recording at higher baudrates (higher than 9600), and I didn't use any delays in the code to keep the sampling rate high. But for one time instant, I had several values written one after another, which made the data log unusable.
Maybe TeraTerm will not have this issue.
Anyway, I will update the post, after implementing it. And would compare CoolTerm and TeraTerm.

Very strange. I've never had a problem recording data with either PuTTY or TeraTerm on a Windows PC, or gtkterm on linux, using Baud rates as high as 500000.

Print one reading per line of data.

Here is how it was

Solution: add a new line command at the end to receive each reading in a new line "Serial.print('\n');"

Now I want to try and save the data inside the Arduino program, since I need data for a very short period of time (some milliseconds), maybe it's possible to save it? If not with arduino nano, some other boards do you recommend?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.