Reading Analog Data using Box0

Electrical Connection

TODO: electrical connection

Python Code

In [1]:
import box0
import numpy as np

dev = box0.usb.open_supported()

ain = dev.ain()

# We will read data in snapshot mode
# snapshot mode: A snapshot of the signal is captured
ain.snapshot_prepare()

# Set the current speed (10KS/S) and resolution (12bit)
ain.bitsize_speed_set(12, 10000)

# Capture data from Channels [Channel Sequence] = (0)
ain.chan_seq_set([0])

# Capture 100 samples
data = np.empty(100, dtype=np.float64)
ain.snapshot_start(data)

# print the captured data \o/
print(data)

# We are done!
ain.close()
dev.close()
[ 0.0112793   0.0112793   0.0112793   0.0112793   0.0112793   0.0112793
  0.0112793   0.0112793   0.01289062  0.0112793   0.0112793   0.0112793
  0.0112793   0.0112793   0.0112793   0.0112793   0.0112793   0.0112793
  0.0112793   0.0112793   0.0112793   0.01289062  0.0112793   0.0112793
  0.0112793   0.0112793   0.0112793   0.0112793   0.01289062  0.0112793
  0.0112793   0.0112793   0.01289062  0.0112793   0.0112793   0.01289062
  0.0112793   0.0112793   0.0112793   0.0112793   0.0112793   0.0112793
  0.0112793   0.0112793   0.0112793   0.0112793   0.0112793   0.0112793
  0.0112793   0.0112793   0.0112793   0.0112793   0.0112793   0.0112793
  0.0112793   0.0112793   0.0112793   0.0112793   0.0112793   0.0112793
  0.0112793   0.0112793   0.0112793   0.0112793   0.0112793   0.0112793
  0.0112793   0.0112793   0.0112793   0.0112793   0.0112793   0.0112793
  0.0112793   0.0112793   0.0112793   0.0112793   0.0112793   0.0112793
  0.0112793   0.0112793   0.0112793   0.0112793   0.0112793   0.0112793
  0.0112793   0.0112793   0.0112793   0.0112793   0.0112793   0.0112793
  0.0112793   0.0112793   0.0112793   0.0112793   0.0112793   0.0112793
  0.0112793   0.0112793   0.0112793   0.0112793 ]