Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to monitor pH levels in an aquarium using Arduino

By Usman ali Butt April 14, 2021

One of the most important elements of any aquarium is oxygen. Even though water is part oxygen, it’s bonded with hydrogen, which is tough to separate and breathe in — even for fish. In open streams and oceans, oxygen is dissolved in the water through the open air, rainfall, and the flow of the tide. The oxygen enters the water through a process known as gas exchange.

Home or office aquariums, however, require an artificial process to induce oxygen in the water. One solution is to perform ongoing water changes in the fish tank, which are time-consuming and wastes resources. Another solution is aeration, which circulates the water to ensure oxygen absorption.  

But how much is enough is an important question for fish owners. When is the aquarium water healthy enough for its marine life?

In chemistry, pH is used as a scientific measure of the acidity in water and can be used to test the quality of aquarium water. The pH levels range from 0 to 14, where 7 is the neutral point. In an aquarium, a reading above 7 is a good thing.

In this tutorial, we’ll learn how to monitor the pH level of water in an aquarium tank. If it’s less than 7, an aerator or air pump will be used to increase the oxygen in the tank.

To measure the pH, we’ll use the atlas-scientific pH level sensor. Here are the specifications of the sensor…

Communication with an external controller is possible on two protocols: the universal asynchronous receiver-transmitter (UART) and I2C. For the project, we’ll use the UART protocol.

The sensor updates every one second. The operating voltages are also favorable for stand-alone solutions.

Circuit diagram

Typically, aquarium aerators work on 220 volts. The relay is used to switch the aerator on and off. It should be is connected to Arduino UNO’s pin#8.

The code
First, download the default standard libraries from Atlas, which are necessary for this project. The libraries for pH probe are available at the Atlas libraries. You’ll need to import and include them in the Arduino sketch.

Only a few variables are declared, globally. The purpose of each one is included in the code.

In setup function, Arduino’s serial monitor must be initialized and the communication baud rate is set to 9600bps. The Atlas sensor’s default baud rate is also 9600bps. Next, declare the aerator pin’s output. The upcoming “if” statement initializes the pH sensor module. There are a few commands inside of it required for calibration (discussed below). The serial event function is the interrupt handler for the serial port.    

In the loop function, check the variable, input_string_complete. If it’s true, this means that calibration is requested by the user. The calibration steps follow.

The outside loop function’s pH value continuously prints on the serial monitor. The “if” statement maintains that if the pH value is less than 7, then the aerator stays off. (There’s a delay of one second is because the sensor updates to a new value after every second.)

The final step includes the calibration function.

Sensor calibration
The Atlas pH Sensor offers many functions, including calibration. The calibrated values are stored in Arduino’s EEPROM, where the calibration settings will be saved even if the power is switched off.

Three calibrations are possible:

  • Single point
  • Two-point
  • Three-point

Each calibration depends on the three resins that are included with the sensor. These are special chemicals dedicated to determining the low, mid, and high points for calibration.

The calibration commands can be issued through Arduino’s serial monitor while the sensor is in circuit and working. After calibrating, the sensor will start its normal operation. Arduino’s EEPROM saves the values. You can find the EEPROM function that saves the calibrated values in the Atlas libraries.

IMPORTANT: If your code fails to compile or shows an EEPROM error, download the Arduino EEPROM library and include it in the Arduino library repository.

Also note, the sensor settings can be altered and several more operations can be performed (such as, continues response, fix response, communication mode change, entering sleep of standby mode, change baud rate, factory reset, etc.).

Where to purchase the parts:

  • Arduino UNO at Mouser
  • Arduino Relay

 

You may also like:


  • What are the different types of temperature sensors and their…

  • Spectroscopic sensor interface with Arduino

  • Temperature Monitor For Aquariums

Filed Under: Microcontroller Projects
Tagged With: Arduino
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • ADS optimization cockpit window does not open
  • Voltage mode pushpull is a nonsense SMPS?
  • Will this TL084C based current clamp circuit work?
  • How to determine the maximum PAD frequency ?
  • Xiaomi Mijia 1C Robot problem of going backwards while working

RSS Electro-Tech-Online.com Discussions

  • using a RTC in SF basic
  • PIC KIT 3 not able to program dsPIC
  • Siemens large industrial PLC parts
  • Parts required for a personal project
  • Cant log in to Easy PC forum

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection
  • Convection-cooled power controller integrates EtherCat connectivity

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe