IOT Lab Experiment No. 9
IOT Lab Experiment No. 9
Apparatus Required:
Theory: Soil pH is a key factor that influences the availability of nutrients to plants. Smart
agriculture systems use real-time pH monitoring to ensure optimal soil conditions for crop
growth. A pH sensor measures the hydrogen ion concentration, providing a pH value that
helps determine whether the soil is acidic, neutral, or alkaline.
The Arduino Uno acts as the processing unit, receiving data from the pH sensor, converting
analog signals to digital readings, and displaying the pH value on an LCD or OLED display.
1. Connect the VCC and GND pins of the pH sensor module to the Arduino’s 5V and
GND pins.
2. Connect the analog output pin of the pH sensor to the A0 pin of the Arduino.
3. For an LCD:
o Connect RS, E, and D4-D7 pins to digital pins on Arduino.
o Connect a potentiometer to adjust the contrast.
4. For an OLED display:
o Connect SDA and SCL pins to the Arduino’s A4 and A5 pins, respectively.
5. Power the Arduino through USB or an external power source.
Procedure:
1. Hardware Setup:
o Assemble the circuit as per the diagram.
o Ensure all connections are secure to avoid short circuits.
2. Software Setup:
o Open the Arduino IDE.
o Install the required libraries, such as LiquidCrystal for LCD or Adafruit
SSD1306 for OLED.
o Write the Arduino code to read the pH sensor output, process the data, and
display the pH value. Use calibration formulas provided by the sensor
datasheet.
3. Calibration:
o Calibrate the pH sensor using buffer solutions (e.g., pH 4.0, 7.0, and 10.0).
o Note the voltage readings for each buffer and adjust the code for accurate
results.
4. Testing:
o Place the pH sensor in the soil sample or buffer solution.
o Observe the pH value displayed on the screen.
o Record the readings and compare them with expected values.
Code:
#include <LiquidCrystal.h>
void setup() {
lcd.begin(16, 2);
lcd.print("pH Sensor Test");
delay(2000);
lcd.clear();
}
void loop() {
voltage = analogRead(pH_pin) * 5.0 / 1023.0;
pH_value = 7 + ((2.5 - voltage) / 0.18); // Example calibration formula
lcd.setCursor(0, 0);
lcd.print("Voltage: ");
lcd.print(voltage);
lcd.setCursor(0, 1);
lcd.print("pH: ");
lcd.print(pH_value);
delay(1000);
}
Precautions:
Result: The pH sensor system was successfully implemented using Arduino, and the pH
value of the soil sample was accurately measured.