If you don't connect the power supply ground to your Beaglebone ground it will not work, and you should indeed see only noise, since AIN0
will be sampling the Beaglebone's ground. You have to connect them in order to AIN0
see the signal of interest.
See the "missing connection" wire. If you don't have that you have no return path for the current coming from the power supply (blue arrows), so there can't be any voltage across the pontentiometer (remember Ohm's law: voltage = resistance x current
. If current is zero, the sampled voltage must also be zero).
As for the script part, you can directly write the sampled data to a file with this:
with open('sampled_data.csv', 'w') as f:
while True:
f.write(','.join(str(adc.read(AIN0)*1800)))
time.sleep(T)
When you interrupt the script you'll get the sample_data.csv
file, with all values separated by commas (,
), which is easily importable to a spreadsheet or other software you use to plot it.