A student project for ENGR114 at Portland Community College. Uses MATLAB connected to an Arudino over serial to read a pH sensor
The team was required to build the hardware and code to control a pH sensor, in order to measure the pH of the water in a fish tank water. We had to complete the following tasks to achieve our final goal:
- Build the hardware.
- Connect the hardware to Arduino.
- Read the Arduino code in MATLAB.
- Modify the codes to:
- Measure the pH in real time, within the time limit set by the user.
- Record the data, and produce a plot of pH against time.
- Refine collected data by conducting multiples tests, putting the sensor in solutions of different pH, collecting the resulting data, and producing a plot corresponding to the data. (Steps listed above appear a lot easier than they actually are.)
component | vendor |
---|---|
Arduino | SparkFun RedBoard - Programmed with Arduino |
pH Sensor | Vernier pH Sensor PH-BTA |
Sensor Shield | SparkFun Vernier Interface Shield |
Breadboard | Breadboard - Self-Adhesive (White) |
Breadboard Base | Arduino and Breadboard Holder |
Mini-B USB cable | SparkFun USB Mini-B Cable - 6 Foot |
ph 4 solution | Standard Buffered pH 4 Solution - from PCC Engineering Lab |
ph 7 solution | Standard Buffered pH 7 Solution - from PCC Engineering Lab |
ph 10 solution | Standard Buffered pH 10 Solution - from PCC Engineering Lab |
The pH sensor (Vernier part# PH-BTA) was connected to the Vernier Interface Shield (Sparkfun part# DEV-12858) using the white British Telecom Analog (BTA) connector at the end of the pH sensor. The Vernier Interface Shield was placed on top of the Arduino (Sparkfun part# DEV-13975) and carefully seated so that all the pins connected. The Arduino was powered and connected to a laptop computer running MATLAB using a red Mini-B USB cable (Sparkfun part# CAB-11301).
The pH_sensor.ino sketch was uploaded on the Arduino using the Arduino IDE.
The pH_sensor.m script was run in MATLAB. Ensure the Port is set correctly. This may be COM4
but check the device manager to see which Port the Adruino is connected to.
Teams that intend to carry out projects that are similar to ours, in the future, can utilize our code, and maybe improve on the commenting part, or probably on the plot-creating section of the code (we have done our best though). They can also work on collecting more accurate pH samples, and from different solutions, just to show that the hardware setup, and the code works without errors. The websites that will be helpful for them include: i. https://www.mathworks.com/discovery/arduino-programming-matlab-simulink.html ii. https://learn.sparkfun.com/tutorials/sik-experiment-guide-for-arduino---v33/introduction- the-arduino-software-ide-and-code iii. https://learn.sparkfun.com/tutorials/sik-experiment-guide-for-arduino---v33/experiment- 7-reading-a-temperature-sensor
GNU General Public License v3.0