Tuesday, September 30, 2014

Introduction to Raspberry Pi Seismology

Measuring earthquakes is a great motivational tool for students.   In the UK everyone hears about earthquakes in the news or learns about them in lessons but they are not felt very often.   However by using simple and inexpensive sensors that you can build yourself it is possible to detect signals from large earthquakes that have occurred on the other side of the world.

This tutorial will be using the digitsers made by www.mindsetsonline.co.uk



When you plug this digitser into a Raspberry Pi it should automatically appear as device /dev/ttyACM0     if you are using the older SEP digister with a serial interface and a serial-USB convertor then it will appear as device /dev/ttyUSB0 )

The digitsers automatically start creating a stream of digital data as soon as they are plugged in ... by default this will be 16bit integer data at 20 samples per second on a 9600baud link

a simple ls -l  /dev/tty*  will show which device you have

It should now be possible to write a little PYTHON script to print the output from this digitser 

piseis_print.py

# a first script to print what is coming from the digitser
#  we need to import an external library to read the data 
import serial


# the original SEP serial port digitser appers as devive /dev/ttyUSB0
# the new SEP USB digitiser appears as device /dev/ttyACMO
#port_name = '/dev/ttyACM0'
port_name = '/dev/ttyUSB0'

port = serial.Serial(port_name, 9600, timeout=1)

#  this looprints all the data appearing on this port 

while(port.isOpen()):
    sample = port.readline().strip()
    print sample




If you run this script it will print sample values to the screen