Last active
January 27, 2020 14:19
-
-
Save LS80/b6e31b4127bfea1261857db23bde517c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 time | |
import csv | |
import math | |
import board | |
import digitalio | |
import busio | |
import adafruit_lis3dh | |
spi = busio.SPI(board.SCK, board.MOSI, board.MISO) | |
cs = digitalio.DigitalInOut(board.D5) # Set to appropriate CS pin! | |
lis3dh = adafruit_lis3dh.LIS3DH_SPI(spi, cs) | |
lis3dh.range = adafruit_lis3dh.RANGE_2_G | |
lis3dh.data_rate = adafruit_lis3dh.DATARATE_1344_HZ | |
timestamp = int(time.time()) | |
print(timestamp) | |
with open('data/xyz_{}.csv'.format(timestamp), 'w') as f: | |
csv_writer = csv.writer(f) | |
while True: | |
try: | |
csv_writer.writerow(lis3dh.acceleration) | |
f.flush() | |
except KeyboardInterrupt: | |
break | |
# python3 -m http.server 8080 --directory data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment