Saving sensor data to a file: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| Line 13: | Line 13: | ||
* Learn how to save data to a new empty file | * Learn how to save data to a new empty file | ||
* Learn how to read a saved file and check for data integrity | * Learn how to read a saved file and check for data integrity | ||
== Converting numerical data to a String == | |||
* In this example we will build on the python program from the previous lesson. | |||
* Our python program was used to download data from a sensor (temperature, atmospheric pressure, battery voltage). | |||
* We will now convert this data into a String and put all the data into a single variable named data. | |||
* Each piece of data will be separated by a comma. | |||
=== Open up the Python file named atm_sensor_get.py === | |||
* From the Raspberry Pi main menu drop down select '''Programming > Python3 (IDLE)'''. | |||
[[File:Screen Shot 2021-12-23 at 9.43.04 am.png]] | |||
* This will open the Python Shell. | |||
[[File:Screen Shot 2021-12-23 at 9.43.52 am.png]] | |||
* From the '''File drop down menu''' select '''Recent Files'''. | |||
[[File:Screen Shot 2021-12-23 at 9.44.41 am.png]] | |||
* Choose the file named '''atm_sensor_get.py''' | |||
* Edit the file so that it appears like the example below. | |||
[[File:Screen Shot 2021-12-23 at 9.45.31 am.png]] | |||
* '''Saving''' and '''Running''' the file should produce an output in the Python Shell like the output below. | |||
[[File:Screen Shot 2021-12-23 at 9.47.13 am.png]] | |||
Revision as of 22:47, 22 December 2021
Overview
- In this lesson we are going to learn how to save our sensor data to a file.
- Saving data to a file will keep it safe.
- Once data is in a file, we can read the data again and make a graph.
- Reading, saving a graphing data is very important for all environmental and Citizen Science activities.
- Sensors often deliver data a numerical data. Some simple examples are temperature, time, speed, counts, etc.
- In this example we are going to save our data as a String (or text).
- Most files store data as text. In this example we also need to separate the data using commas (,).
- If data is separated by commas it makes each data element human readable and other programs, such as Spreadsheets, can also read the file more easily.
Learning Objectives
- Learn how convert numerical data into a String (or text)
- Learn how to save data to a new empty file
- Learn how to read a saved file and check for data integrity
Converting numerical data to a String
- In this example we will build on the python program from the previous lesson.
- Our python program was used to download data from a sensor (temperature, atmospheric pressure, battery voltage).
- We will now convert this data into a String and put all the data into a single variable named data.
- Each piece of data will be separated by a comma.
Open up the Python file named atm_sensor_get.py
- From the Raspberry Pi main menu drop down select Programming > Python3 (IDLE).
- This will open the Python Shell.
- From the File drop down menu select Recent Files.
- Choose the file named atm_sensor_get.py
- Edit the file so that it appears like the example below.
- Saving and Running the file should produce an output in the Python Shell like the output below.




