Trybotics Logo

CONNECTING MULTIPLE SENSORS TO RASPBERRY PI

DESCRIPTION

In this project, we will be connecting three of Atlas Scientific's EZO sensors (pH, dissolved oxygen and temperature) to a Raspberry Pi 3B+. Instead of wiring the circuits to the Raspberry Pi, we will be using the Whitebox Labs Tentacle T3 shield. These stackable shields plug into the pins of the Pi after which the EZO circuits and probes connect to the shield. Interacting with the sensors is done using the command terminal in Raspbian.

ADVANTAGES:

MATERIALS

Supplies:

USB keyboard, USB mouse, Monitor with HDMI capabilities, USB micro SD card reader

Description:

a) Download the Raspbian zip file onto your computer from the following LINK. "Raspbian Buster with desktop and recommended software" is used in this project.

b) To install Raspbian onto the SD card an image writing tool is needed such as Etcher. Download and install Etcher onto your computer.

c) Insert the micro SD card into the USB card reader and plug the reader into your computer. In case your SD card needs formatting you can use the SD Formatter program.

d) Open the etcher program.

  • Select the Raspbian file download from step a.
  • Select your SD card.
  • Click on the "Flash!" tab to begin writing to the SD card

Description:

a) Connect the monitor, keyboard, and mouse to your Raspberry Pi.

b) After the Raspbian image installation on the SD card is finished, remove it from the computer and insert it into the Raspberry Pi. Turn on the power to the Pi.

Default raspberry credentials: user name is pi and password is raspberry

c) Since this is the first time booting Raspbian, you will be asked to adjust a few settings such as language, time zone and adding internet connectivity. Be sure to connect to the internet as this will be needed in later steps.

UPDATE AND UPGRADE PACKAGES

d) Open the command terminal from the Raspbian desktop. Update the system's package list by entering the following command sudo apt-get update

e) Upgrade the installed packages to their latest versions with the command sudo apt-get upgrade

DOWNLOAD SAMPLE CODE

f) In the terminal run the following commands:

cd ~

git clone https://github.com/AtlasScientific/Raspberry-Pi-sample-code.git

This will add the repository of sample code from Atlas Scientific to the Raspberry Pi. Only the i2c code is needed for this project.

I2C SETTINGS

g) Install and enable the I2C bus on the Raspberry Pi. Run the following commands:

sudo apt-get install python-smbus

sudo apt-get install i2c-tools

h) Next, open the configuration window by entering sudo raspi-config

Choose "Interfacing Options" (image 1 above).

i) Choose "I2C" (image 2 above).

j) You will be presented with the question "Would you like the ARM I2C interface to be enabled?" Choose "Yes" ( image 3 above).

k) Hit "Ok" (image 4 above). Then reboot the Pi with command sudo reboot


Description:

The Tentacle T3 shield is I2C compatible only. As such the EZO sensor must be in I2C and not UART mode. If you have multiple of the same sensors (for example 2 pH) be sure to assign unique I2C addresses to each. Failure to do so will result in communication conflicts.

For instructions on how to change between protocols and assigning I2C addresses, refer to the following LINK.

Description:

a) Ensure that power to the Raspberry Pi is turned off.

b) Mount the tentacle shield onto the pins of the Pi.

c) Insert the EZO circuits onto the shield. Be sure to match the pins correctly.

d) Connect probes to the female BNC connectors of the shield.

Description:

a) Turn on the power to the Pi.

b) Open the terminal and enter sudo i2cdetect -y 1

The program will report information about each connected I2C device. Image 5 above provides a demonstration. The hex representation of the I2C addresses are shown. (dissolved oxygen = 0x61, pH = 0x63, temperature = 0x66)

Description:

a) Open the directory that has the sample codes cd ~/Raspberry-Pi-sample-code

b) Run the I2C script sudo python i2c.py

Each time the script is executed, the user is presented with the menu shown in example 1 above.

Example 2: List the addresses of the connected sensors and query each for the device information.

Example 3: Continuously poll pH sensor

Example 4: Check if the dissolved oxygen sensor is calibrated.

Refer to the datasheets for all appropriate commands. ( pH datasheet, dissolved oxygen datasheet, temperature datasheet)


YOU MIGHT ALSO LIKE