In this project, we will learn how to logging data from Raspberry Pi using Python and Excel which collect data and save the output of the collection or analysis.

It’s a quite quick project and can be used either on its own or part of something bigger. Check it out >> Integrated Weather Station(IWS).

Step 1: List of Material

For this project, we will be using:

- Raspberry Pi (mine Raspberry Pi 2)

- Flashdrive cost: ~5.00 USD

Step 2: Hardware Connections

In general, the connections are fairly easy. Just connect Flash Drive to Raspberry PI with USB slot and check the name of Flash Drive in Raspberry pi by type "ls /media" in Raspberry Pi terminal, the result should be content Flash Drive's name and you are good to go.

Step 3: Raspberry Pi Programming

Below is the Python code. Edit the code in any way you prefer, run the module , and you should have no problems.

import os
import time 
from time import sleep
from datetime import datetime

file = open("/home/pi/data_log.csv", "a")
if os.stat("/home/pi/data_log.csv").st_size == 0:
while True:
now = datetime.now()

Step 4: Read Your Data Log

Your file that located in your /home/pi/ or any location you prefer is a comma-separated value(CVS) file. Comma-separated values (CVS) file is a formatted file that stores tabular data (numbers and text) which separated by comma. To open and modify this file, simply double click on it, or open it with Microsoft Excel. You can plot your data with Chart tools that available in Microsoft Excel.

Step 5: Enjoy!

After making sure that everything works correctly, you can take this project into bigger project or integrated it with Real Time Clock (RTC) for accurate logging. Check it out >> Raspberry Pi - Real Time Clock (RTC) !

Power through power bank or a plug and you’re good to go!

<p>The data logging gave me ideas on saving data collecting from RasPi.</p>
<p>Can you use this to log data off of a blood glucose monitor?</p>
<p>Hello,<br>I'm having a really hard time understanding your guide and how to use it in my project... maybe its me, since im a total newbie with python... will read the other two guides you shared tho, and try to understand how this data logger works.<br><br>But.... is it possible to explain what does the &quot;file.write(str(now+&quot;,&quot;+.....&quot; actually do? <br>Thank you for your time! </p>
<p>Hi Adrie,</p><p>How do I get more information on how to use the Raspberry Pi data logger</p>
Will this be more useful than sqlite if you want a webinterface?
<p>nope, sqlite for the database that could be access easily from server but .sdv datalog require further code that affect in its simplicity.</p>
<p>Very cool! Thanks for sharing!</p>
<p>thanks kooth, your welcome!</p>
<p>Hello, I've been looking for a simple data logger for the PI, thanks. </p><p>I know I must be missing something here but what is the Arduino code for ? have we got to translate it to PI code ? also how do you get the data in to the pi for reading? what pins is the logger reading etc...</p><p>Sorry to have the questions I must be having a dumb moment...</p><p>Thanks</p>
<p>looking at code, &quot;arduino&quot; looks like a typo</p>
Thanks for the reply. I still can't see where the data comes from to log .. Ot how this interfaces with something to get the data. That's what I thought maybe the Arduino would be for...
<p>Sorry for long time to reply. Arduino in this case as the data source which give raspberry pi data to be logged. You could use another microcontroller or even use your module in raspberry pi (module sensor, adc reading, etc. etc.). <strong>Good luck dude!</strong> Inform me if you did well.</p>
<p>yup, i just copy the AWS instructables step and edit it for <u>efficiency</u> Sir! Btw i already edit the instructables. Thanks dude!</p>
What would be some real life applications of this project?
<p>Data logging for example =D</p><p>It logs data from sensors, and that's the real life application. Weather monitoring, movement tracker, use your imagination ^^</p>
<p>i like statistics like this , very nice well done!</p>
<p>Wow, I like it!</p>

About This Instructable




Bio: A candle loses nothing of its light when lighting another
More by AdrieSentosa:LED Acrylic Trophy / Placard Raspberry Pi - Remote Desktop Connection IoT Service Robot 
Add instructable to: