Experiment 7 MSK Raspberry Oscilloscope
Experiment 7 MSK Raspberry Oscilloscope
with RPi
Er. Manoj S. Kavedia
www.kaizenfuturetech.com
www.kavediasir.yolasite.com
9324258878 / 8329988738
Raspberry Pi PinOut
Connection
ADS1115 and Raspberry Pi Connections:
VDD – 3.3v
GND – GND
SDA – Pin3 - SDA
SCL –Pin5 - SCL
$ sudo raspi-config
$ cd ~
Change into the cloned file’s directory and run the setup file
cd examples
Run the sampletest.py example which displays the value of the four channels
on the ADC in a tabular form.
python simpletest.py
Installation Steps
If the I2C module is enabled and connections good, you should see the data as
shown in the image below
If an error occurs, check to ensure the ADC is well connected to the PI and I2C
communication is enabled on the Pi.
Installation Steps
Step 5: Install Matplotlib
To visualize the data, install the matplotlib module which is used to plot all
kind of graphs in python. This can be done by running;’
Lastly, we need to install the drawnow python module. This module helps us
provide live updates to the data plot.
We will be installing drawnow via the python package installer; pip, so we
need to ensure it is installed. This can be done by running;
With all the dependencies installed, we are now ready to write the code.
Python Code
Python Code for Raspberry Pi Oscilloscope:
import time
import matplotlib.pyplot as plt
#import numpy
from drawnow import *
# Start continuous ADC conversions on channel 0 using the previous gain value.
adc.start_adc(0, gain=GAIN)
print('Reading ADS1x15 channel 0')
Python Code
#create the figure function
def makeFig():
plt.ylim(-5000,5000)
plt.title('Osciloscope')
plt.grid(True)
plt.ylabel('ADC outputs')
plt.plot(val, 'ro-', label='Channel 0')
plt.legend(loc='lower right')
while (True):
# Read the last ADC conversion value and print it out.
value = adc.get_last_result()
print('Channel 0: {0}'.format(value))
# Sleep for half a second.
time.sleep(0.5)
val.append(int(value))
drawnow(makeFig)
plt.pause(.000001)
cnt = cnt+1
if(cnt>50):
val.pop(0)
Enjoys Waveform!!!!
Er. Manoj S. Kavedia