Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Raspberry Pi & Interfacing with the sensors

Justin Tappert edited this page Feb 28, 2018 · 6 revisions

Software Setup

Flash the latest version of Raspbian onto the micro SD card and get your Pi set up by following the documentation. (This will take about 30 minutes to download and install, so this would be a good point to get up and get some coffee ☕ ). Note that these instructions did not use NOOBS, but used the Raspbian Stretch Desktop, directly imaged to the micro SD card.

Start the Raspberry Pi to ensure that it boots.

Update the Wi-Fi settings and ensure that the date and time are correct.

Using NOOBS?

If you installed Raspbian by flashing the full image to the SD card, skip this step.

If you are installing the OS with NOOBS, you may need to expand the filesystem. Run the following command line within the Raspberry Pi’s terminal.

sudo raspi-config

You should see a blue screen with options in a gray box in the center,

Choose option 7 (Advanced Options)

Next,

Choose option A1 Expand Filesystem

Install the Dependencies

Run the following commands in the terminal to update apt-get, upgrade installed packages, and install the project dependencies.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git-core
sudo apt-get install python-dev
sudo apt-get install python-serial
sudo apt-get install python-rpi.gpio

Download this repo

To download the repo code,run the following commands within the Raspberry Pi’s terminal.

cd ~
git clone https://github.com/osu-cascades/dio-controllers.git

Once the repo code has finished downloading, you will be almost ready to begin using the Atlas Scientific™ EZO™ class circuits with your updated Raspberry Pi.

Enable I2C Mode

There are three communication modes that the Atlas Scientific can operate in with the RP3: USB mode, UART mode, and I2C. For this setup we used I2C mode and you must first enable the I2C channel on your RP3. For more information about the different modes reference the Atlas Scientific Sensor Documentation.

Before you enable the I2C Bus you need to install some packages

$ sudo apt-get install python-smbus
$ sudo apt-get install i2c-tools

Once those packages have finished installing, you need to re-open the Raspberry Pi config

$ sudo raspi-config

Go to Interfacing options

Advanced Options

Select I2C

Select I2C

Select Yes

YES

Your Raspberry Pi can now interface with the sensor in I2C mode.

Test Sensor Connection

To ensure the sensor is properly connected to your raspberry pi's I2C Bus, run the following command

$ sudo i2cdetect -y 1

This will report information about each connected I2C device and should display that I2C address (0x61) is in use.

I2c bus in use

Depending on the sensor you are using you will see a different I2C address in use. The pH sensor for example lists (0x63) as its I2C address, refer to the documentation for your sensors specific address. Also note that the documentation lists the address in decimal format, so the pH sensors address is listed as "93" which translates to (0x63) in hexadecimal.

Once you see your devices listed in the I2C bus, you are ready to test communication with the sensor.

After you have downloaded the sample code, open the terminal in the directory and run

$ sudo python i2c.py

If you are not using i2C Mode and would like to use USB or UART go to the provided HERE

This will prompt you with some argument options.

Enter a command

Notice, that in the above screenshot the address is set to 97 because the Dissolved Oxygen sensor was being used which defaults to address 0x61 or 97.

To test if your sensor is communicating enter

POLL,2.0

This will set your sensor to take a reading every two seconds and print it to the terminal window.

Sensor successfully taking readings

The sample code provided by Atlas Scientific has the sensors address set to 99 by default, you can change this address manually in the code or you can adjust the ad