Logging and Displaying Data on Matlab : Arduino UNO + DS3231 Rtc Module + SDcard Module + LCD 20x4 I2C

by sss2022 in Circuits > Arduino

475 Views, 1 Favorites, 0 Comments

Logging and Displaying Data on Matlab : Arduino UNO + DS3231 Rtc Module + SDcard Module + LCD 20x4 I2C

Photo_18.png

In this project, the DS3231 (real time clock) module has been used to get the current time, date and temperature. They are all displayed on the 20x4 LCD screen and logged onto a microSD card thanks to the microSD adapter module. For future analysis, data is diplayed on Matlab. In other words, the project is aimed at collecting and analyzing data over a longer period of time, rather than just displaying it in real-time. The use of Matlab also implies that the data will be processed and analyzed using more advanced statistical tools and techniques.

---------------------------------------------------------------------------------------------------------------------------------

Dans ce projet, le module DS3231 (horloge temps réel) a été utilisé pour obtenir l'heure, la date et la température actuelles. Elles sont toutes affichées sur l'écran LCD 20x4 et enregistrées sur une carte microSD grâce au module d'adaptateur microSD. Pour une analyse ultérieure, les données sont affichées sur Matlab. En d'autres termes, le projet vise à collecter et à analyser des données sur une période plus longue, plutôt que simplement les afficher en temps réel. L'utilisation de Matlab implique également que les données seront traitées et analysées à l'aide d'outils et de techniques statistiques plus avancés.

Supplies

-----------------------------------------------------------------------

  • Arduino UNO development board
  • USB 2.0 cable type A/B
  • Mini breadboard
  • LCD 20x4 I2C
  • Real time clock DS3231
  • RC2032 battery
  • MicroSD Card module
  • MicroSD Card
  • Cables

-----------------------------------------------------------------------

  • Carte de développement Arduino UNO
  • Câble USB 2.0 type A/B
  • Mini platine d'essai
  • LCD 20x4 I2C
  • Horloge en temps réel DS3231
  • Pile RC2032
  • Module de carte microSD
  • Carte microSD
  • Câbles

----------------------------------------------------------------------

Circuit Diagram / Schéma

Schéma_17.png

The circuit diagram is made using : thttps://www.tinkercad.com/

------------------------------------------------------------------------------------------

Le schéma est réalisé via : thttps://www.tinkercad.com/

Librairies / Bibliotèques

Lib_12_13_LCD_I2C.png
Lib_DS3231.png

The libraries you will need to download are listed above. To open the "Library manager", go to the top menu then click on Tools => Manage Libraries

-------------------------------------------------------------------------------------------------------

Les bibliothèques qu'il faut télécharger, vous allez les trouver ci-dessus. Pour ouvrir le "Gestionnaire de bibliothèque", Allez au menu du haut ensuite cliquez sur Outils => Gérer les bibliothèques

Source Code (Arduino) / Code Source (arduino)

Displaying Temperature on Matlab / Affichage De La Température Sur Matlab

matlab1.png
matlab2.png
matlab3.png
  1. In the file DATA.txt, replace '/' and ':' with ','
  2. Open MATLAB.
  3. Navigate to the folder where the 'DATA.txt' file is located.
  4. Right-click and select 'Import Data.'
  5. In the dialog box that appears, choose 'Comma' as the delimiter and click on 'OK.'
  6. Rename your variables.
  7. Select the variables you want to import, then click 'Import Data.'
  8. You will find all your variables in the workspace.
  9. In the command window, type the following command: save('data_temperature.mat').
  10. A new file 'data_temperature.mat' will appear in your folder, containing all your variables.
  11. Create a new script (plot_temperature.m) and place it in the folder where the files 'data_temperature.mat' and 'DATA.txt' are located.
  12. Next, copy and paste the following Matlab program into the .m file that you have just created.
  13. Execute the file 'plot_temperature.m'.

-------------------------------------------------------------------------------------------------------

  1. Dans le fichier DATA.txt, remplacez '/' et ':' par ','.
  2. Ouvrez Matlab.
  3. Placez-vous dans le dossier où se trouve le fichier 'DATA.txt'.
  4. Cliquez-droit ensuite choisissez 'Importer les données'.
  5. Dans la boite de dialogue qui apparaît, choisissez 'Virgule' comme délimiteur ensuite cliquez sur 'OK'.
  6. Renommez vos variables.
  7. Sélectionnez les variables que vous souhaitez inmporter ensuite cliquez sur 'Importer les données'.
  8. Vous allez retrouvez toutes vos variables dans l'espace de travail.
  9. Dans la fenêtre de commandes, saisissez la commande suivante : save('data_temperature.mat').
  10. Dans votre dossier, un nouveau fichier 'data_temperature.mat' apparaîtra qui contient toutes vos variables.
  11. Créez un nouveau script (plot_temperature.m) et placez-le dans le dossier où se trouvent les fichiers 'data_temperature.mat' et 'DATA.txt'.
  12. Ensuite, copier-coller le programme Matlab si-dessous dans le fichier .m que vous venez de créer.
  13. Exécutez le fichier 'plot_temperature.m'

Source Code (Matlab) / Code Source (matlab)

% Autor / Auteur : Zineb KANDOUSSI (https://www.facebook.com/SchoolSurSeineFR/)

% Creation / Création : Le 05/05/2023

% Close all figures % Fermer toutes les figures 

close all;

% Clear all variables % Effacer toutes les variables 

clear all;

% Load the data from the file "data_temperature.mat" 

% Charger les données du fichier "data_temperature.mat" 

load('data_temperature.mat');

% get the size of vectors % Obtenir la taille des vecteurs

N=length(hours);

% Convert time vectors to seconds % Convertir les vecteurs temps en secondes

for i=1:N

  t(i)=hours(i)*3600+minutes(i)*60+seconds(i);

end

% Set the initial time to zero

% Définir le temps initial à 0

t=t-min(t);

% Plot temperature against time % tracer la température en fonction du temps

plot(t,Temperature,'LineWidth',2,'Color',[0,0.5,0]);

grid;

title('Temperature');

ylim([25,35]);

xlabel('Time (s)');

ylabel('Temperature (°C)');

Video / Vidéo

Logging and Displaying Data on Matlab : Arduino UNO + DS3231 Rtc Module + SDcard Module + LCD 20x4