Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Based pH Monitoring System with Bluetooth Connectivity

Image of Arduino UNO Based pH Monitoring System with Bluetooth Connectivity

Circuit Documentation

Summary of the Circuit

This circuit is designed to measure pH levels using a pH meter and display the results through an Arduino UNO microcontroller. The Arduino UNO also controls a servomotor and communicates with a Bluetooth HC-06 module for potential wireless data transmission. Two pushbuttons are included in the design, possibly for user input to control the system or to trigger certain actions. The servomotor is likely used for some form of physical response or indication based on the pH readings or other inputs. The pH readings are processed by the Arduino, which also toggles an LED based on a timed interval.

Component List

PH Meter

  • Pins: Signal, VCC, GND
  • Description: A sensor that measures the hydrogen-ion activity in water-based solutions, outputting a voltage signal proportional to the pH level.

Arduino UNO

  • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13
  • Description: A microcontroller board based on the ATmega328P, with digital and analog I/O pins, used for controlling the various components in the circuit.

Bluetooth HC-06

  • Pins: VCC, GND, TXD, RXD
  • Description: A Bluetooth module that allows for wireless communication with other Bluetooth-enabled devices.

Pushbutton (x2)

  • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
  • Description: A momentary switch that can be used to trigger events or actions when pressed.

Servomotor SG92R

  • Pins: SIG, VCC, GND
  • Description: A small rotary actuator that allows for precise control of angular position, used for moving parts in the circuit.

Wiring Details

PH Meter

  • Signal: Connected to Arduino UNO A0
  • VCC: Connected to Arduino UNO 5V
  • GND: Connected to common ground net

Arduino UNO

  • GND: Connected to common ground net
  • 5V: Connected to VCC net for PH Meter, Servomotor SG92R, and Bluetooth HC-06
  • A0: Connected to PH Meter Signal
  • D4: Connected to Servomotor SG92R SIG
  • D1: Connected to Bluetooth HC-06 TXD
  • D0: Connected to Bluetooth HC-06 RXD

Bluetooth HC-06

  • VCC: Connected to Arduino UNO 5V
  • GND: Connected to common ground net
  • TXD: Connected to Arduino UNO D1
  • RXD: Connected to Arduino UNO D0

Pushbutton (x2)

  • Pin 4 (out): Connected to common ground net

Servomotor SG92R

  • SIG: Connected to Arduino UNO D4
  • VCC: Connected to Arduino UNO 5V
  • GND: Connected to common ground net

Documented Code

#define SensorPin A0            // pH meter Analog output to Arduino Analog Input 0
#define Offset 0.00            // deviation compensate
#define LED 13
#define samplingInterval 20
#define printInterval 800
#define ArrayLenth  40    // times of collection
int pHArray[ArrayLenth];   // Store the average value of the sensor feedback
int pHArrayIndex=0;

void setup(void)
{
  pinMode(LED,OUTPUT);
  Serial.begin(9600);
  Serial.println("pH meter experiment!");    // Test the serial monitor
}

void loop(void)
{
  static unsigned long samplingTime = millis();
  static unsigned long printTime = millis();
  static float pHValue,voltage;
  if(millis()-samplingTime > samplingInterval)
  {
      pHArray[pHArrayIndex++]=analogRead(SensorPin);
      if(pHArrayIndex==ArrayLenth)pHArrayIndex=0;
      voltage = avergearray(pHArray, ArrayLenth)*5.0/1024;
      pHValue = 3.5*voltage+Offset;
      samplingTime=millis();
  }
  if(millis() - printTime > printInterval)   // Every 800 milliseconds, print a numerical, convert the state of the LED indicator
  {
    Serial.print("Voltage:");
    Serial.print(voltage,2);
    Serial.print("    pH value: ");
    Serial.println(pHValue,2);
    digitalWrite(LED,digitalRead(LED)^1);
    printTime=millis();
  }
}

double avergearray(int* arr, int number){
  int i;
  int max,min;
  double avg;
  long amount=0;
  if(number<=0){
    Serial.println("Error number for the array to averaging!/n");
    return 0;
  }
  if(number<5){   // less than 5, calculated directly statistics
    for(i=0;i<number;i++){
      amount+=arr[i];
    }
    avg = amount/number;
    return avg;
  }else{
    if(arr[0]<arr[1]){
      min = arr[0];max=arr[1];
    }
    else{
      min=arr[1];max=arr[0];
    }
    for(i=2;i<number;i++){
      if(arr[i]<min){
        amount+=min;        // arr<min
        min=arr[i];
      }else {
        if(arr[i]>max){
          amount+=max;    // arr>max
          max=arr[i];
        }else{
          amount+=arr[i]; // min<=arr<=max
        }
      }//if
    }//for
    avg = (double)amount/(number-2);
  }//if
  return avg;
}

This code is designed to read the analog signal from the pH meter connected to pin A0 on the Arduino UNO. It samples the signal at a regular interval, averages the readings to reduce noise, and then calculates the pH value from the averaged voltage. The calculated pH value and the corresponding voltage are printed to the serial monitor every 800 milliseconds. Additionally, an LED connected to pin 13 on the Arduino is toggled with each print interval, serving as a visual indicator of the system's operation.