-
Notifications
You must be signed in to change notification settings - Fork 2
Datalogging with Python
##Overview With a sensor and our time established, we have the groundwork necessary to start writing sensor log files. For this, we need to get the time inside a python script and then write our information to a .csv file.
##Getting the time with Python Our Raspberry Pi now knows the time without the internet, and we can use the python library datetime to get the current time of the day.
If you have not already acquainted yourself with the Python interpreter, see Getting acquainted with the Python interpreter.
>>> from datetime import datetime
>>> datetime.now()
~ ~ ~
>>> datetime.now().date()
~ ~ ~
>>> datetime.now().strftime("%Y_%m_%d")
~ ~ ~
Datetime will pull the local date from the computer, and store it as a "python object". From there, the various date fields (i.e. month, day of the week) can be accessed.
Strftime is short for "string format time" and is very commonly used amongst programming languages. It is not important to learn specific syntax, but Google, Stack Overflow, or the documentation will be very helpful to find a particular format.
##Python CSV writer
Wiki for Rhewlab Environmental Sensing Project
- Setting up Raspberry Pi
- Getting started with GPIO
- Reading Temperature and Humidity with DHT
- Adding a RTC to the Raspberry Pi
- Datalogging with Python
- Connecting to ADC with Raspi
- Finishing up
Digital
Analog