Saving voltage reads from sensors in queue from Arduino to an excel file?
5 views (last 30 days)
I am trying to collect voltage data from a sensor that is connected to an Arduino in three analog inputs (the sensor gives voltage in X direction, Y direction, Z direction)
I have written code to acquire the data such that there is a dash after each value so I know when data is read from the next analog input.
voltage = "1.96_" %this is from analog input 1
voltage = "1.3_" %then this is collected from analog input 2
voltage = "1.2_" %then after the second analog input, this is read from analog input 3
I want to store these values, but "voltage" keeps getting overwritten and when I pause the code, it only provides the most recent voltage acquired.
How can I store all of the read values in a matrix and print to an excel file?
Thanks! (new to matlab here)
Here is what I have so far:
while param > 0
for i = 1:3
voltage = read(device,4,"string")
Anshika Chourasia on 20 Jun 2022
I understand you want to store all the read values in a matrix and save it to an excel file.
You can use “writematrix” function to write data to a file and use Name-Value pair argument ('WriteMode','append') to append the data below existing data in a spreadsheet. Please refer to the following link for "writematrix” function details:
I hope this helps!