Now that we were able to do some measurements, we had one last challenge to overcome : How could we store the data we just measured ?

In fact, we were able to read our measurements in the serial monitor of the Arduino IDE but we could not store them. We could have ctrl + C/ ctrl + V the serial monitor but it was not a satisfying solution from our point of view. We thought of 2 other solutions :

  • Recording the data on an SD card by using dedicated Arduino Libraries
  • Recording the data on the computer linked with Arduino by using an external piece of code written in python for instance

We chose the last solution because we had notions in python and moreover it allowed us to have a graphical interface for the recording of the data. We used the python package pyserial which allows a user to send and read informations via the USB port of a computer. Here is an excellent tutorial to learn the basics of the package and how to use it with Arduino (sorry it is in French but I guess some good tutorials also exist in english). Basically, this package will allow your computer and the Arduino to understand each other and to communicate.

In the .ino file you will be able to read what you sent by USB port with a dedicated function we wrote :

String readSerialMonitor(int t_letter) {  
String command;  
while (Serial.available() > 0)//Check if there is some data in the monitor  
{    
     t_letter = Serial.read();    
     command += char(t_letter);    
     delay(1);  
}  
return command;
}

And you will be able to send to your computer (via the USB port) the data read by the Arduino (Serial.print()) and deal with them in the python code. We could have done a mere python code to store the measured data in a .txt file but we decided to code a GUI to make our device more convinient to use

Leave a Reply