-
-
Save JGarrechtMetzger/ada3040ecd6b06a0c819669d25a26008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tmp102 | |
import csv | |
import time | |
#### Initialize communication with TMP102 | |
tmp102.init() | |
temp_c = round(tmp102.read_temp(), 2) | |
#### Write CSV | |
x_value = 0 | |
y_value = 0 | |
fieldnames = ['x_value','y_value'] | |
with open('data_1s.csv','w') as csv_file: | |
csv_writer = csv.DictWriter(csv_file, fieldnames=fieldnames) | |
csv_writer.writeheader() | |
while True: | |
with open('data_1s.csv', 'a') as csv_file: | |
csv_writer = csv.DictWriter(csv_file, fieldnames=fieldnames) | |
info = { | |
"x_value": x_value, | |
"y_value": y_value | |
} | |
csv_writer.writerow(info) | |
print(x_value, y_value) | |
x_value += 1 | |
y_value = round(tmp102.read_temp(), 2) | |
time.sleep(.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment