[Arduino] how to save serial monitor in the text file?

Click For Summary

Discussion Overview

The discussion centers around the challenge of saving data from the Arduino serial monitor to a text file. Participants explore potential methods and limitations related to this task, including programming techniques and platform constraints.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • Nate seeks assistance on how to save serial monitor output to a text file, providing a code snippet that generates random numbers.
  • One participant mentions that there is no filesystem on Arduino, suggesting that data can only be sent via the serial communication link.
  • Another participant inquires if Nate is familiar with writing to files in C, referencing a specific chapter in a well-known programming book.
  • There is a discussion about recognizing the Arduino platform based on the structure of the provided code, which resembles Processing sketches.

Areas of Agreement / Disagreement

Participants do not reach a consensus on how to save the serial monitor output, with differing views on the capabilities of the Arduino platform regarding file handling.

Contextual Notes

The discussion highlights limitations related to the Arduino's lack of a filesystem, which affects the ability to save data directly to a text file.

Nate Duong
Messages
125
Reaction score
4
Dear everyone,

I trying to save serial monitor in the text file, but I still do not know how, could you please help on this problem?

Here is the codes with random numbers are set up, and I would like you save all data into the text file,

Thank you very much,
Nate Duong,

C:
long Channel1a;long Channel1b;
long Channel2a;long Channel2b;
long Channel3a;long Channel3b;

long Channel4a;long Channel4b;

int count1 = 0;
int count2 = 0;
int n1 = 1000        +1;  //  +1 is missing count
int n2 = 2         +1;

void setup(){
  Serial.begin(9600);
  randomSeed(analogRead(0));
}

void loop(){while(count2<=n2){
  //Serial.print("nate1\n");
   while(count1<=n1){
     if ((count1==2)|(count1==1)){
               Serial.print("     Q1     I1     Q2     I2     Q3     I3     Q4     I4 \n");  // print out the channels
                   }
     Channel1a = random(300); Channel1b = random(300);
     Channel2a = random(300); Channel2b = random(300);
     Channel3a = random(300); Channel3b = random(300);
     Channel4a = random(300); Channel4b = random(300);

     Serial.print("    "); Serial.print(Channel1a); Serial.print("    ");
     Serial.print(Channel1b); Serial.print("    ");
     Serial.print(Channel2a); Serial.print("    ");
     Serial.print(Channel2b); Serial.print("    ");
     Serial.print(Channel3a); Serial.print("    ");
     Serial.print(Channel3b); Serial.print("    ");
     Serial.print(Channel4a); Serial.print("    ");
     Serial.print(Channel4b); Serial.print("    \n");
     count1 = count1 +1;
     delay(500);
                      }
                 }
     count2 = count2  +1;
     Serial.print(" \n");}
 
Last edited by a moderator:
Technology news on Phys.org
Hi Nate, I added code tags to your post to make it more readable. Click Reply on your post to see what the code tags look like.

On your question, are you familiar with how to write to files in C? It's in chapter 7 of the Kernighan & Ritche book on C (2nd Edition). :smile:
 
Thread moved to the Programming forum for more views... :smile:
 
Last edited by a moderator:
how did you know it was an Arduino?
 
By the sketch model of setup() and loop() which is similar to Processing sketches which uses setup() and draw() loop methods.
 
Hi Nate, I added code tags to your post to make it more readable. Click Reply on your post to see what the code tags look like.

On your question, are you familiar with how to write to files in C? It's in chapter 7 of the Kernighan & Ritche book on C (2nd Edition). :smile:
thank you very much, berkeman.
 
post: 5219108 said:
By the sketch model of setup() and loop() which is similar to Processing sketches which uses setup() and draw() loop methods.
thank you very much, jedishrfu.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K