File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ import time
2+ import board
3+ import busio
4+ import adafruit_ads1x15 .ads1015 as ADS
5+ from adafruit_ads1x15 .ads1x15 import Mode
6+ from adafruit_ads1x15 .analog_in import AnalogIn
7+
8+ # Data collection setup
9+ RATE = 3300
10+ SAMPLES = 1000
11+
12+ # Create the I2C bus with a fast frequency
13+ i2c = busio .I2C (board .SCL , board .SDA , frequency = 1000000 )
14+
15+ # Create the ADC object using the I2C bus
16+ ads = ADS .ADS1015 (i2c )
17+
18+ # Create single-ended input on channel 0
19+ chan0 = AnalogIn (ads , ADS .P0 )
20+
21+ # ADC Configuration
22+ ads .mode = Mode .CONTINUOUS
23+ ads .data_rate = RATE
24+
25+ data = [None ]* SAMPLES
26+
27+ start = time .monotonic ()
28+
29+ # Read the same channel over and over
30+ for i in range (SAMPLES ):
31+ data [i ] = chan0 .value
32+
33+ end = time .monotonic ()
34+ total_time = end - start
35+
36+ print ("Time of capture: {}s" .format (total_time ))
37+ print ("Sample rate requested={} actual={}" .format (RATE , SAMPLES / total_time ))
You can’t perform that action at this time.
0 commit comments