Introduction: CONNECTING MULTIPLE SENSORS TO RASPBERRY PI
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.
- No wiring, no breadboards and no soldering necessary.
- Fully assembled shield easily mount onto Raspberry Pi.
- Built-in isolation protects sensors from interference.
- Connect multiple sensors to a Raspberry Pi.
- Works with the following EZO sensors: pH, salinity, dissolved oxygen, oxidation-reduction potential, temperature, peristaltic pump, and carbon dioxide.
- Raspberry Pi 3B+
- Raspberry Pi power supply
- 8GB micro SD card
- Whitebox Labs T3 shield
- pH circuit & probe
- dissolved oxygen circuit & probe
- temperature circuit & probe
USB keyboard, USB mouse, Monitor with HDMI capabilities, USB micro SD card reader
Step 1: DOWNLOAD AND INSTALL RASPBIAN ONTO SD CARD
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.
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
Step 2: BOOT RASPBERRY PI AND CONFIGURE SETTINGS
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:
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.
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
Step 3: SET SENSORS TO I2C MODE
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.
Step 4: MOUNT SHIELD AND SENSORS TO RASPBERRY PI
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.
Step 5: TEST SETUP
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)
Step 6: MONITOR READINGS AND INTERACT WITH SENSORS
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.