Purpose:
Finally we're ready to start gathering data and porting it into a Jupyter notebook and doing some physics. A standard part of that process is getting the data from our experiment to the notebook. A standard file format for data files is called .csv. (comma separated values). With some care we can make sure the data file we create on the sd card is consistent with csv formats. Then we will take that file to Jupyterlab and learn how to read it an plot it. That will be enough for today.
Procedure:
- For this lab you will need your Arduino, the 9V battery adapter that possibly came with your kit, the SD Card Reader board from the kit, the micro SD card from the kit, a temperature sensor (either the TMP36 or the DHT11 that some of you have), your breadboard, and some jumper wires, and perhaps other miscellaneous stuff.
i) Last time we did a basic data logger which wrote some data to the SD card and read it back through the serial monitor. Now we want to take a reasonable set of data that we will learn to read into a python notebook and plot. An updated version of a data logger sketch is here. As I hope you are learning it is valuable to take the time to work your way through the sketch one line at a time to be sure you understand, at some level, what the code is doing.
Be attentive -- if you don't erase previous versions of your data file the new data will just be added to the end. Notice that this data logger sketch removes any file with the name 'fileName' during the setup part of the sketch. A file with this name is then rewritten pon the SD card. If you wish to change the file name all you have to do is define this variable in the sketch with a different name.
ii) Once we have a .csv file in a standard format we then need to learn how to port it into a Jupyterlab notebook. Go to the PH212 github and Go through the ReadCSVBasics.ipynb notebook. In this notebook I read my own data files and plot them. You will need to download my data files from the github before you run the notebook and save them in the appropriate place.
iii) Use the data logger sketch to create your own csv datea file, copy it or read it onto your computer, and save the file where your install of Jupyterlab can find it. Modify the python notebook to read your datafile and plot it with suitable labels.
iv) Bonus Round: In the Jupyter notebook I provided it also illustrates the power of the Pandas csv file reader by exploring some COVID data using Pandas and dataframes. For your bonus round plot something other than the data I plotted and explain what it tells us about current COVID numbers.
- LAB DELIVERABLES:
-
I) Submit a pdf from your Jupyter notebook showing the read and plot of your CSV datafile.