Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 8

Sensors for the Raspberry

Pi
158.335
Ultrasonic sensor
HC-SR04 - 5V ultrasonic distance sensor.

The ultrasonic sensor operates at 5v but the


Raspberry Pis logic pins are 3.3v

The Raspberry Pi can still interface with it as


3.3v is enough to register as a high signal in 5v
logic. Also the output of the sensor can be
reduced using a voltage divider (a better
approach would be to use a logic level
converter).
I2C and SPI
I2C and SPI are two forms of serial
interface - both of which the Raspberry
Pi supports at a hardware level.

There are many different sensors and


output devices available that support
both of these protocols - most of these
can be interfaced by the Raspberry Pi.
Enabling I2C and SPI on the Raspberry Pi
Both I2C and SPI are disabled by
default on the Raspberry Pi.

To enable them either set the on


through the graphical Raspberry Pi
configuration or use the raspi-config
command in shell.
I2C
Slower

Only requires two pins SDA (the data line)


and SCL (the clock line)

Can support multiple devices through


addressing - up to 127 devices per bus

You can read what devices are connected to


the Raspberry Pis I2C bus by using the
i2cdetect command in shell.
I2C Light Sensor
The GY-30 is a digital light intensity sensor
that uses the I2C protocol.

We can interface with an I2C device fairly


easily once we know its address and what
commands it accepts.
SPI
Faster than I2C

Can have multiple devices in a master / slave configuration

Requires 4 lines (SCLK (serial clock), MOSI (Master Out Slave In), MISO
(Master In Slave Out) and SS (Slave Select))

Simpler than I2C


SPI Thermocouple
A thermocouple is a type of temperature sensor.

The Adafruit MAX31855 is a thermocouple amplifier with a SPI interface.

Using a Python library we can easily interface with this sensor.

git clone https://github.com/adafruit/Adafruit_Python_MAX31855.git


cd Adafruit_Python_MAX31855
sudo python setup.py install

You might also like